Conditional display faults

is_page() returns boolean true or boolean false. The way you’ve called it looks like it would have no effect. Try this: if ( is_page( array( ‘web-design-portfolio’, ‘web-design-portfolio-2’ ) ) ) { ?> <!– All your display code code –> <?php } // ends the if() statement

do code if current url = value

global $wp; $current_url = add_query_arg( $wp->query_string, ”, home_url( $wp->request ) ); $is_specific_network = stripos( $current_url, ‘specific_domain_or_ip_address’ ); if( $is_specific_network !== false ) { // do the task below } else { // do something else or leave it blank } N.B. : You need to replace the IP address or specific domain name above to … Read more

I need use is_single in functions.php

is_single most likely only works inside of The Loop, and functions.php loads before you’re in The Loop. You could try something like this: add_action( ‘wp_head’, function(){ var_dump(is_single()); }); And now you see that is_single() returns true. EDIT: I was probably off for suggesting it only works inside The Loop, but there’s definitely better places for … Read more

Sub-category single post styling?

Try this if statement instead: if ( is_category() && ( is_category( 59 ) || cat_is_ancestor_of( 59, get_queried_object_id() ) ) ) Update: To work for single posts: if ( is_single() && $terms = get_the_category( get_queried_object_id() ) ) { foreach ( $terms as $term ) { if ( $term->term_id == 59 || cat_is_ancestor_of( 59, $term->term_id ) ) … Read more

Conditional tags not working

instead of echoing your styles anywhere, you can hook your code at wp_head to add it in head or wp_footer to add it in your footer, see if it works for you, function my_custom_style(){ global $post; if ( !empty ( $post->post_name ) && $post->post_name == ‘events’ ){ ?> <style type=”text/css”> #main { background-image: none; } … Read more

If page displays posts conditional

Both will do the same job in the end of the day. You can however improve on the first code. is_archive() returns true on all archives page, which includes the following taxonomy archive pages category archive pages date archive pages author archive pages tag archive pages So, if you need to target all these pages, … Read more

Why is this is_page conditional not working?

“Bangles” isn’t a page. It’s a Product Category Archive. is_page() checks: Is the query for an existing single page? Which product categories are not. See the Template Hierarchy to get an idea of the different types of ‘pages’ in WordPress. If you want to check if you are viewing a product category archive, use is_tax(), … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)