Support

Home Forums Event Espresso Premium EE4 Shortcodes and Single Event page not working immediately upon install.

EE4 Shortcodes and Single Event page not working immediately upon install.

Posted: April 24, 2014 at 3:11 pm


Chad Carlberg

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.)


Lorenzo Orlando Caum

  • Support Staff

April 24, 2014 at 3:24 pm

Hi Chad,

Is this a new install or an update from a prior version of Event Espresso?

Any errors in the site error_log?


Lorenzo


Chad Carlberg

April 24, 2014 at 3:41 pm

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.


Lorenzo Orlando Caum

  • Support Staff

April 24, 2014 at 5:29 pm

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?


Lorenzo


Chad Carlberg

April 25, 2014 at 7:57 am

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.


Chad Carlberg

April 25, 2014 at 7:58 am


Chad Carlberg

April 25, 2014 at 8:07 am

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…


Tony

  • Support Staff

April 25, 2014 at 8:19 am

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?


Chad Carlberg

April 25, 2014 at 8:35 am

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.


Chad Carlberg

April 25, 2014 at 9:29 am

Managed to get rid of all these errors. Still displaying a blank white page and no shortcode functionality


Chad Carlberg

April 25, 2014 at 11:03 am

Can you provide a list of required template files, such as single.php?


Josh

  • Support Staff

April 25, 2014 at 12:17 pm

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:

http://codex.wordpress.org/FAQ_Troubleshooting#How_do_I_solve_the_Headers_already_sent_warning_problem.3F


Chad Carlberg

April 25, 2014 at 1:50 pm

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:
<pre class=”brush: php; gutter: true; first-line: 1; highlight: []; html-script: false”>echo do_shortcode('[ESPRESSO_EVENTS]');
does not work in any custom page template.

We’ve also noticed a curious issue:
We have custom shortcodes to populate OG tags, and EE4 seems to be hijacking those, but not other shortcodes. So instead of:
<pre class=”brush: html; gutter: true; first-line: 1; highlight: []; html-script: false”><meta property="og:title" content="title">
we see:
<pre class=”brush: html; gutter: true; first-line: 1; highlight: []; html-script: false”><meta property="og:title" content="
<div id="espresso-notices"="">

If we exclude these tags for now, EE4 seems to function just fine (aside from the issue above, which could be related?)


Chad Carlberg

April 25, 2014 at 2:08 pm

Sorry the code tags didn’t work.


Josh

  • Support Staff

April 25, 2014 at 8:23 pm

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:

We have custom shortcodes to populate OG tags, and EE4 seems to be hijacking those, but not other shortcodes.

Can you check to see if your custom shortcodes echo their content or return their content?


Chad Carlberg

April 27, 2014 at 10:35 am

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.


Chad Carlberg

April 27, 2014 at 11:27 am

I spoke too soon! The wp_query works. But it’s still quite odd the shortcodes do not…


Josh

  • Support Staff

April 29, 2014 at 6:54 am

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?


Chad Carlberg

April 29, 2014 at 8:29 am

https://github.com/presencemaker/page-meta

Here is the github with a basic header.php, functions.php and various included files.


Josh

  • Support Staff

April 29, 2014 at 1:15 pm

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');


Chad Carlberg

April 29, 2014 at 1:30 pm

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!


Josh

  • Support Staff

April 29, 2014 at 2:41 pm

You’re welcome.


Chad Carlberg

April 30, 2014 at 2:53 pm

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.


Josh

  • Support Staff

April 30, 2014 at 3:27 pm

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; 
?>


Josh

  • Support Staff

September 11, 2014 at 2:06 pm

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.

Event Espresso