If else statement based on referral URL

a $_GET variable would be the better option. try var_dump($_GET); on the page before the conditional and see exactly what you need to test against It seems that there is something more to the puzzle that we are missing. Is the file not showing up correctly? Could that be because the file paths are wrong? … Read more

Best Method to Switch Between Terms (Custom Taxonomy)

If I am reading your code and description correctly, you can simplify that to: $taxonomy = ‘delivery_option’; $do = get_the_terms($post->ID,$taxonomy); if (!empty($do) && !is_wp_error($do)) { $do = array_shift($do); // assuming a single value as per the description. $term = str_replace(‘-delivery’,”,$do->slug); get_template_part(‘includes/sidebar-part’,$term); } else { echo ‘<p>No custom include!</p>’; } Note, I used WordPress’s get_template_part() instead … Read more

Widget logic conditional widget

Before I start, I must say that your terminology is quite confusing and plain wrong. You should take your time and read through my answer to this question: Is There a Difference Between Taxonomies and Categories? As I stated before, there is no in_term() function to check if a post has a specific term. There … Read more

Loading scripts only if a particular shortcode or widget is present

You can use the function is_active_widget . E.g.: function check_widget() { if( is_active_widget( ”, ”, ‘search’ ) ) { // check if search widget is used wp_enqueue_script(‘my-script’); } } add_action( ‘init’, ‘check_widget’ ); To load the script in the page where the widget is loaded only, you will have to add the is_active_widget() code, in … Read more