Support

Home Forums Event Espresso Premium Page using shortcode of event categories only showing top price

Page using shortcode of event categories only showing top price

Posted: June 30, 2013 at 12:17 pm


Carol Stambaugh

June 30, 2013 at 12:17 pm

I created a page that list all events in a single category. However, the page only displays the first of the two prices (We have a price for non-member and member). I found this in the forum https://eventespresso.com/forums/2010/10/post-type-variables-and-shortcodes/ and see there is template code for event price. However, I am not sure which template file to add this to.

Will adding this code indeed show both the Member and non-member price on all pages that list the events in a category?

Thank you,
Carol


Dean

July 1, 2013 at 12:34 am

Hi Carol,

The old forum post you linked is from 2010, so its best to be careful with that information as sometime sits out of date.

Here is the current shortcode information https://eventespresso.com/wiki/shortcodes-template-variables/#event-price

It depends on how you have the prices set up. If you are using WP User Integraton (members) add on to create the member price, then unfortunately no it wont show those prices.

If you have the price as just an alternative price then yes that shortcode will work.

It can be added into the event_list_display.php template file.

There are also these code options that show the prices in a range or list instead

https://gist.github.com/sethshoultes/ab1e992668cf3166a686
https://gist.github.com/sethshoultes/f05ae8b0c2f549a94d67

Again, if you are using WP User Integration then they will show the logged in price or the logged out price.


Carol Stambaugh

July 1, 2013 at 3:44 pm

Thanks so much, Dean. I’m not a php person, so I have to ask, can the code be inserted anywhere in the template? It looks like this is the code snippet that I need, but I just get paranoid editing the php. πŸ™‚

<?php do_action(‘action_hook_espresso_price_list’, $event_id);?>

Thanks so much!


Seth Shoultes

  • Support Staff

July 1, 2013 at 4:16 pm

Yes, you should be able to add that line of code in the event_list_display.php template file. As long as the section you are adding it to isn’t wrap in opening and closing () PHP tags.

Does that make sense?


Carol Stambaugh

July 3, 2013 at 2:47 pm

I added this line of code immediately under the current price and it still isn’t showing the list. Here is the url of the page.

http://nasw-wa.org/continuing-education/special-events/licensing-prep-courses/

Any other ideas?

Thank you,
Carol


Seth Shoultes

  • Support Staff

July 3, 2013 at 3:09 pm

Did you add the code, in the first code sample (event_espresso_price_list.php), into your theme’s functions.php file (wp-content/themes/theme-name/functions.php) or in the custom files addon (wp-content/uploads/espresso/custom_functions.php file)?


Carol Stambaugh

July 3, 2013 at 3:19 pm

Doh, I had not done that. But when I just added it, I got a parsing error at line 22. Here is the from line number 110 to 140 and the error said 122.

<code>function no_generator() { return &#039;&#039;; }  
add_filter( &#039;the_generator&#039;, &#039;no_generator&#039; );
function explain_less_login_issues(){ return &#039;&lt;strong&gt;ERROR&lt;/strong&gt;: Entered credentials are incorrect.&#039;;}
add_filter( &#039;login_errors&#039;, &#039;explain_less_login_issues&#039; );
/** Customize the entire footer */
remove_action( &#039;genesis_footer&#039;, &#039;genesis_do_footer&#039; );
add_action( &#039;genesis_footer&#039;, &#039;custom_footer&#039; );
function custom_footer() {
    ?&gt;
    &lt;p&gt;&amp;copy; Copyright 2013 | Website by: &lt;a href=&quot;http://techtoolsonline.com/&quot;&gt;Tech Tools, LLC&lt;/a&gt; &amp;middot; All Rights Reserved&lt;/p&gt;
    &lt;?php
}
&lt;?php
//This function should be added to the custom files addon, in the wp-content/uploads/espresso/custom_functions.php file, or your in your theme, in the wp-content/themes/theme-name/functions.php.
if (!function_exists(&#039;event_espresso_price_list&#039;)) {
 
    function event_espresso_price_list($event_id) {
    	$html = &#039;&#039;;
        global $wpdb, $org_options;
		$sql = &quot;SELECT id, event_cost, surcharge, surcharge_type, price_type&quot;;
		$order_by = &#039;event_cost&#039;;
		if ( function_exists(&#039;espresso_members_installed&#039;) &amp;&amp; espresso_members_installed() == true &amp;&amp; is_user_logged_in() ) {
			$sql .= &quot;, member_price, member_price_type &quot;;
			$member_event = TRUE;
			$order_by = &#039;member_price&#039;;
		}
		$sql .= &quot; FROM &quot; . EVENTS_PRICES_TABLE . &quot; WHERE event_id=&#039;&quot; . $event_id . &quot;&#039; ORDER BY &quot; . $order_by . &quot; ASC&quot;;
		$results = $wpdb-&gt;get_results( $wpdb-&gt;prepare($sql, &#039;&#039;) );
        if ($wpdb-&gt;num_rows &gt; 1) {	
			//Create a dropdown of prices
			$html .= &#039;&lt;ul id=&quot;price-list-&#039; . $event_id . &#039;&quot; class=&quot;espresso-price-list&quot;&gt;&#039;;</code>


Seth Shoultes

  • Support Staff

July 3, 2013 at 3:42 pm

You probably need to remove the opening and closing PHP tags from the code you posted. Eg.


Carol Stambaugh

July 3, 2013 at 3:51 pm

I am not getting the parsing error so that is good. However, it still isn’t inserting the list.

I inserted the top code from https://gist.github.com/sethshoultes/ab1e992668cf3166a686 into functions.php. Then I entered the one line of code in the second window into the event_list_display.php file. In put it in right after the event price around line 72. Any other suggestions?

Btw, thanks so much for hanging in there with me on this.


Seth Shoultes

  • Support Staff

July 3, 2013 at 4:34 pm

The code in your event_espresso_price_list.php file may be a little different than mine, but you should probably add that one line of code within line 70, as seen in this screenshot: http://www.screencast.com/t/CXqjnbXZIEV

If you just want to see how it looks, you should probably just add the code after line 73.

Does that all make sense?


Carol Stambaugh

July 3, 2013 at 6:07 pm

Still nothing. πŸ™ Here is a screenshot of my code.

http://screencast.com/t/3EIkxRLw Line 70. πŸ™

Here is my page view. http://screencast.com/t/pjF8kKbdN4


Seth Shoultes

  • Support Staff

July 3, 2013 at 6:21 pm

Did you move your template files to the /wp-content/uploads/espresso/templates? If so, please make sure you are making your edits in the /wp-content/uploads/espresso/templates/event_espresso_price_list.php file.

If that is in fact the location that you are making your edits, and they are still not showing, then it may be a file permissions issue in that directory and the files contained within it. In that case you will need to make sure the file and directory permissions are set to 755.

The support post ‘Page using shortcode of event categories only showing top price’ 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