elliotlewis
Forum Replies Created
-
Glad you got it working. If you check out the PHP date link there’s many ways you can format the displayed date.
This will only fail if a timestamp doesn’t exist. You should error check for that. Obviously that will happen if you don’t set and Expiration date/time.
$expiration_timestamp = get_post_meta( get_the_ID(), '_expiration-date', TRUE ); if( empty( $expiration_timestamp ) ) { echo 'No end date'; } else { echo date( 'l F jS, Y', $expiration_timestamp ); }
If you’re doing this in a template you need to know what you’re doing with PHP.
The time is stored as a timestamp, a universal time code (the number of seconds since the epoch). All dates/times can be worked out from this. Eg. there’s 20 seconds difference between a timestamp of 300 and 320.
https://uk3.php.net/manual/en/function.date.php
$expiration_timestamp = get_post_meta( get_the_ID(), '_expiration-date', TRUE ); echo date( 'l F jS, Y', $expiration_timestamp );
Thanks @angelo, but that won’t work for me as I am using EMs locations to display a location on the event. I’m just not using a location archive page to list locations.
As soon as I override the PT name WP errors.
Makes sense.
But any help on why it’s 404’ing at not showing an archive template? And how to get around the route issue.
You’ve not answered if EM does anything with rewrite rules for ‘location’.
OK, I’ve re-read this thread a couple of times, and it’s clear how WP is getting confused, as EM creates it’s own CPT called ‘location’ for it’s Locations.
So WP should load an archive template for /location/ but it 404’ing, so EM is doing something with WP rewrites.
It’s a bit of a ‘sledge-hammer’ CPT name using ‘location’, wouldn’t ’em-location’ be better? I’m sure others will find this a problem (like @ Damien).
@angelo What would be the conflict?
The site went live yesterday, so it might help for you to have a look?
https://www.theengineroom.org.uk/directory/This possibly isn’t directly an EM issue but a WP routing one. I’m assuming EM is setting some rules for directing URLs though, and also one of those routes is to handle ‘location’?
Ah, I see.
I’m using pretty permalinks, so I hadn’t considered WP would be trying to evaluate query variables. WP routes is a constant pain. I don’t understand how it can be a 404 because there is a template that works fine without query variables in the URL, ie WP loads the right page. What I mean is, without pretty links it would be:
https://example.com/?page_id=43&location=uk
Why is WP getting confused with that? I’ve tried it and you’re right it does 404.
Unfortunately I am using the built in locations, so I can’t disable it. I already have the ‘solution’ of, ‘use a different GET variable name’. I’m using ‘locations’.
It would be good to understand how I can configure WP to understand the URL though and not load EMs ‘location’ template. (I’m not using EM location view, just an event list > click > view event.)
This is site isn’t live yet. Why would it be a problem with the form submitting using GET? It’s most likely to be EM getting confused with it’s permalinks as event pages are showing.
I’ve written the form code (this isn’t a plugin). The form is submitted to the same page:
https://example.com/directory/Via GET so:
https://example.com/directory/?location=ukI’m then picking up the vars from the URL to manipulate the view. Except with that GET variable WP redirects to an event.
Install the plugin and go to settings > Post Expirator
Shortcode is [postexpirator]. And default to the settings on the settings page.
Attributes are dateformat, timeformat.
Eg.
[postexpirator dateformat='l F jS, Y']
To get this in a template I’ve just checked the database and the date is stored as a timestamp with a meta_key of _expiration-date.
get_post_meta( get_the_ID(), "_expiration-date", TRUE );
This is happening in a few places.
I have a custom usermeta field called location.
I have page that outputs all users. On this page I have a form with a select dropdown that lists some locations (it doesn’t matter how this list is generated), but the select name=’location’. This form submits via ‘get’.There are other selects to choose from all matching custom usermeta as well. These selects submit OK and I can access the values to display a filtered view.
BUT with a select with a value of ‘location’, on submit, WP goes to an events page (‘events’ is the slug EM uses to display an event page).
Is EM looking out for the word ‘location’ from any form submit and then acting on it?
That’s the easy bit! Automatically saving the data when someone submits the (EM) form is the problem.
EM isn’t going to automatically parse and save the ACF fields to the DB. Are you suggesting hooking into EM and writing all the code to save data? I’m not aware of an API for ACF to help.
I’ve tried it, and there isn’t in WP Admin.
Sorry, should have been specific. Any custom fields added via ACF do not show up in a Front-end template, like Add an Event.
EM is not aware of the custom fields so they don’t appear in front-end forms.
OK, thanks.
Feature request / suggestion: As EM just saves Custom Attributes / WP Custom Post Fields as post-meta is there a way for you to tie in to Advanced Custom Fields or Types?
It would bypass having to reinvent the wheel but allow a lot more flexibility with the type of content that’s saved against an event.
Thanks for confirming that’s the only way. I’d already got some templates files.
For other readers, place the file in:
plugins > events-manager > forms > event-editor.phpI’m finding the Custom Attributes limiting as well. Any other fields other than text input and selects? I need a checkbox.
This still looks to be the same? Custom Taxonomies can’t be used on Repeating Events.
This is a big problem as, it makes the ability to add custom taxonomies almost redundant. You highlight the feature in your docs as something that can be done but neglect to say it doesn’t work for repeating events. Similar to Jack completely messed up what Iv’e built so far.
https://wp-events-plugin.com/tutorials/using-additional-custom-taxonomies/
Are Event Categories normal CT? If not do you plan to make them so any number ofCT can be used for both normal and repeating events?