Dev: Fix Shortcode-output of current page-content, instead of shortcode-id-page
-
First of all thank you for this great plugin! : )
I am massively using the Shortcodes of the Plugins on diferrent pages.
When I updated my System and Plugin, I ran into a problem with thestaff-directory
-Shortcode and all the sub-Shortcodes asbio_shortcode
,photo_url_shortcode
.The Shortcodes did not show the content/post-data of the page given by the ID-Param anymore, but of the page the Shortcode was embedded (i.e bio/the content, featured image and so on).
This is due to the Usage of native Content-Accessing-Functions like
get_the_content
in thebio
-shortcode function which refers to the currently set-up post-data.So I had to add setup_postdata/the_post directly after the custom wp_query in
plugins/staff-directory/classes/staff-directory-shortcode.php
to “enable” the native “content-accessing-functions”:Approximately line 223:
//Store in class scope so we can access query from staff_loop shortcode Staff_Directory_Shortcode::$staff_query = new WP_Query( $query_args ); $output = ''; if ( Staff_Directory_Shortcode::$staff_query->have_posts() ) { Staff_Directory_Shortcode::$staff_query->the_post(); // !!!!!!!!!!!!!!! $output = self::retrieve_template_html($params['template']); } wp_reset_postdata(); // !! wp_reset_query();
…and to finish what we’ve started: after the wp_query-processing there is actually no need to reset the query with
wp_reset_query()
. We just need to set the post data back up withwp_reset_postdata()
.I hope this might help others who ran into this a little annoying issue like me. : )
- The topic ‘Dev: Fix Shortcode-output of current page-content, instead of shortcode-id-page’ is closed to new replies.