if is_page(‘slug’)
Solved, this is what I was looking for: <?php elseif (preg_match( ‘#^any-page-with-this-text-in-slug(/.+)?$#’, $wp->request)) : ?>
Solved, this is what I was looking for: <?php elseif (preg_match( ‘#^any-page-with-this-text-in-slug(/.+)?$#’, $wp->request)) : ?>
I like to split this kind of thing to more than one conditional, as it makes it easier for me to read. if( !( in_category( ‘videos’ ) || post_is_in_descendant_category( 9 ) ) ) { if( get_the_author_meta( ‘ID’ ) != 3 ) { } } Given, it’s a bit more code, but that’s the way it … Read more
I don’t know the plugin, but with a rapid eye on it, it seems that what you want is not, but you can rely on widget_content filter fired by the plugin you are using. So, in your theme function.php put: if ( function_exists(‘widget_logic_redirected_callback’) ) add_filter(‘widget_content’, ‘my_widget_for_user’, 10, 2); function my_widget_for_users ($widget_content, $widget_id) { $allowed_users = … Read more
Yes because your code has syntax error. It should be this. if ( is_singular(‘my_cpt’) && ( has_term( ‘myterm’, ‘mytaxonomy’, $post->ID ) ) ) { } Did you notice if condition should close just after is_singular(‘my_cpt’).
Look at the docs (please read the docs) for is_taxonomy_hierarchical(). You need to tell it which taxonomy you’re checking: if ( is_taxonomy_hierarchical( ‘my_taxonomy_name’ ) ) { } If you’re template isn’t specific to a taxonomy, and you need to know which taxonomy you’re viewing, use get_queried_object() to figure it out (you were already told how … Read more
You’re missing } before elseif: <?php if (is_page (’20’)){?> print this <?php } elseif (is_page (’50’)){?> then print this <?php } else { ?> print this <?php } ?> Remove the PHP tags and you’ll see why: if ( is_page( ’20’ ) ) { elseif ( is_page( ’50’ ) ) { } else { }
If the conditional works when using is_page( ‘products’ ), but does not work when using is_page( ‘blog’ ), then that means that WordPress isn’t finding a static page with the slug blog. First thing to do: verify your slug name. A second alternative is that the static page blog is using a custom page template, … Read more
The conditional tags must be run after WP object is set up. The wp action hook is the first one where you can use these conditionals safely. See the warning message in the conditional tags documentation. So, you should hook into wp action or later event; also, the correct function name is add_action, not add_Action: … Read more
There’s some code missing from your question – the code where your slides are actually output. The foreach loop you’ve posted only sets the variables, and the actual output happens below the loop. So, all you’re doing on the fourth slide is avoiding setting the variables… hence the slide is still output, but using the … Read more
Here are two alternative for you based on your actual query. If you’re querying $projects->have_posts() on WP default blog (Post) you can use query like $projects = new WP_Query( array( ‘tag__in’ => array( 52, 53 ) ) ); Another is if you’re querying on Custom Post Type you can use following query to get posts … Read more