I take advantage of a conditional assertion to show a shortcode relying on which class archive is being displayed. The difficulty I’ve is that if I take advantage of get_queried_object_id, the archive web page for the father or mother time period reveals the shortcode for the father or mother time period and the primary baby time period.
Here is the code which returns the father or mother and the primary baby time period shortcodes.
$emk_current_term_id = get_queried_object_id(); // Mum or dad Time period if ( ($emk_current_term_id==141293) || in_category(array(141293)) ) { echo do_shortcode('[emk_shortcode_01]'); } // Baby Time period if ( ($emk_current_term_id==305) || in_category(array(305)) ) { echo do_shortcode('[emk_shortcode_02]'); }
The best way I’ve bought round that is to stipulate which end result from the returned array to base the conditional assertion on by utilizing sq. brackets, like this.
$emk_current_term_id = get_queried_object_id(); // Mum or dad Time period if ( ($emk_current_term_id[0]==141293) || in_category(array(141293)) ) { echo do_shortcode('[emk_shortcode_01]'); } // Baby Time period if ( ($emk_current_term_id[0]==305) || in_category(array(305)) ) { echo do_shortcode('[emk_shortcode_02]'); }
So every conditional assertion solely takes under consideration the primary returned worth within the array.
Is that this one of the best ways to return the present time period id solely, i.e., is there any strategy to exclude baby phrases from the outcomes array for get_queried_object_id().
Thanks