The filter will try to detect the usage of the short code in the loaded page. When you call do_shortcode
directly you are bypassing that detection. For those instances, you can, instead of calling add_filter( 'a-z-listing-tabify', '__return_true' );
replace it with:
add_action( 'init', 'a_z_listing_force_enqueue_tabs' );
To target one specific listing to be tabbed is more difficult. You need to call the add_action
or add_filter
appropriately depending upon the page being created. One way to do this is to ensure you’re using a unique template in your theme for each of the pages and before the call to wp_head();
run the add_action
or add_filter
in the template that is applied to the specific page you want to be tabbed.
Another method is to use the global $wp_query
object to determine the page being loaded and run the add_action
or add_filter
when you’re sure you’re loading the relevant page to be tabbed. You would want to perform this in an action that occurs before the template is loaded, for example pre_get_posts
.