Posted: April 24, 2014 at 3:11 pm
|
Using wordpress 3.9, EE 4.2.2reg We are building a site on a staging environment, and I’ve installed EE4 to begin working with the event pages. It functions on the back-end and I added 1 event. The shortcode does not display the event, and navigating to the individual event page produces a blank white page. (Note: I cannot publicly link to the staging environment.) |
Hi Chad, Is this a new install or an update from a prior version of Event Espresso? Any errors in the site error_log? — |
|
|
I had EE3 installed, but I did the full removal and have tried doing a fresh install due to this issue. In both cases, the same result: No shortcodes, no individual event pages. But the back-end functions fine. I do have a custom theme, and it seems to be stripping almost everything out of the head of my documents. |
Could you check to see if there are any warnings on the EE4 critical pages in WP-admin –> Event Espresso –> General Settings –> Critical Pages. Any errors in the site error_log? — |
|
|
Sorry for the delayed response, I was updating some of our custom theme functions attempting to resolve the issue. There is no site error_log. With event espresso deactivated, wordpress is enqueuing all of our scripts properly. With event espresso activated, for some reason it loads a div within the <head> portion of the site, which is preventing any further JS from loading. I’ve attached screenshots, before activating EE and after. *NOTE: all our meta tags and scripts load dynamically via php through the functions.php file. |
|
|
|
Or not. Anyway, All critical pages look good. No other JS errors. When I remove our custom shortcodes the head loads properly but STILL the shortcodes don’t work and the individual event page doesn’t work… |
Hi Chad, Regarding your images you’ll need to host them online and link them here for us to view them or you can email them to support@eventespresso.com with a link to this thread so we know what they are in regards to. Without viewing the page and/or the code it will be hard to pinpoint the reason for this. If you enable WP_DEBUG is there an error message displayed on the blank page? |
|
|
I had the images hosted with imgur and was linking appropriately. You get the idea though. Here are the errors on the individual event page: Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /Applications/MAMP/htdocs/mrba/wp-includes/functions.php on line 3245 Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at /Applications/MAMP/htdocs/mrba/wp-includes/functions.php:3245) in /Applications/MAMP/htdocs/mrba/wp-content/plugins/event-espresso-core-reg/core/EE_Session.core.php on line 247 So there is definitely an issue with our custom theme. I’m looking into that portion now. |
|
Managed to get rid of all these errors. Still displaying a blank white page and no shortcode functionality |
|
Can you provide a list of required template files, such as single.php? |
Hi Carl, index.php would be the only one that’s required as an absolute minimum, since WP will automatically fall back to index.php if it can’t find a single.php or an archive.php: https://codex.wordpress.org/Template_Hierarchy Here is some information that will help you track down what’s causing the Headers already sent warning: |
|
|
Thanks Josh. We did narrow it down to an issue with single.php and managed to get individual events displaying correctly, along with the custom post type for events. However, the shortcode [ESPRESSO_EVENTS] only works on the default event-registration page, but declaring it via php with: We’ve also noticed a curious issue: If we exclude these tags for now, EE4 seems to function just fine (aside from the issue above, which could be related?) |
|
Sorry the code tags didn’t work. |
Hi Chad, Since Event Espresso events are a post type, you can use a custom query to display a list of events instead of using a shortcode. Here’s an example: <?php $args = array( 'post_type' => 'espresso_events', 'posts_per_page' => 3 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); get_template_part( 'content', 'espresso_events' ); endwhile; ?> With this issue:
Can you check to see if your custom shortcodes echo their content or return their content? |
|
|
Our shortcodes return their content. As a precaution, I even added a prefix to them just in case there were any conflicting titles. Oddly enough, the WP_Query doesn’t display anything either. The page template has multiple wp_query below the intended location for the event list, and those are functioning properly and querying custom post types as well. |
|
I spoke too soon! The wp_query works. But it’s still quite odd the shortcodes do not… |
We’ll have to add support for loading the Event Espresso shortcodes directly from a template with a do_shortcode in a later update. Can you post your custom shortcodes and their usage in a pastebin or github gist so we can investigate the issue with the espresso notices? |
|
|
https://github.com/presencemaker/page-meta Here is the github with a basic header.php, functions.php and various included files. |
Hi Chad, I looked at the code and there’s really no reason to use do_shortcode for these metatags, and creating a new loop for each of these shortcodes is going to slow down the page load and create all kinds of issues. I’d recommend downloading and reviewing the code from some of the more popular SEO plugins or something simpler like the WP Open Graph Meta plugin to see how they add meta tags to the head of the document. To help further, I rewrote your get_meta_description function (removed the unnecessary loop and shortcode stuff) to help show how you can add the meta description by means of the wp_head action hook instead of adding a shortcode and calling the shortcode in the template. Here is the example code: function get_meta_description() { $pmpress_meta_description = get_post_meta( get_the_ID() , 'page_description', true ); if( $pmpress_meta_description == '' ): $pmpress_meta_description = get_bloginfo( 'description' ); endif; echo '<meta name="description" content="' . esc_attr( strip_tags( stripslashes( $pmpress_meta_description ) ) ) . '"/>' . "\n"; } add_action('wp_head', 'get_meta_description'); |
|
|
This makes complete sense and offers a superior solution. The shortcodes were part of an early boilerplate and I’ll be incorporating and expanding on this for future versions. Thank you! |
You’re welcome. |
|
|
In regards the WP_Query you posted on the other page, I modified it to attempt an orderby for the start date of the event and can’t seem to leverage the meta data that way. $args = array( ‘post_type’ => ‘espresso_events’, ‘posts_per_page’ => 3, ‘order’ => ‘DESC’, ‘orderby’ => ‘meta_value_num’, ‘meta_query’ => array(array(‘meta_key’ => ‘event_start_date’)) ); Any insight? Sorry to keep this thread going. |
Hi Chad, The start date isn’t stored in the post meta. Instead of directly querying where the event’s start date is stored, there’s a helper class that you can use that’s also used by the ESPRESSO_EVENTS shortcode that you can use in a custom query like this: <?php $args = array( 'limit' => 3, 'sort' => 'DESC', 'order_by'=>'start_date' ); $loop = new EE_Event_List_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); get_template_part( 'content', 'espresso_events' ); endwhile; ?> |
|
Hi Chad, A little Follow-Up: The EE shortcode can be used in a page template starting with Event Espresso 4.4.0.p, released today. |
|
The support post ‘EE4 Shortcodes and Single Event page not working immediately upon install.’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.