Use conditionals with wp_enqueue_style to attach stylesheet according to post type displayed

The issue in your first block of code is syntax: if( get_post_type() == ( ‘activity’ OR ‘dining’ OR ‘heritage’ OR ‘hiking’ OR ‘nightlife’ ) ) : this isn’t proper use of OR and will evaluate true regardless of what get_post_type() returns. The issue in your second block is again syntax, you have to break; at … Read more

show div only if have a related post inside

move the div section from the start to after the if(have_posts()) { line, and move the corresponding closing divs to just before the closing bracket } of this if statement; full code: <?php global $post; $terms = get_the_terms( $post->ID , ‘movies’, ‘string’); $do_not_duplicate[] = $post->ID; if(!empty($terms)){ foreach ($terms as $term) { query_posts( array( ‘movies’ => … Read more

Conditional Tag Based on Age of Post [duplicate]

<?php $today = date(‘r’); $articledate = get_the_time(‘r’); $difference = round((strtotime($today) – strtotime($articledate))/(24*60*60),0); if ($difference >= 3) { ?> this is a three day old post <?php } ?> the 3 in if ($difference >= 3) { ?> is 3 days old, you can change that to whatever you want. How I could do it, is … Read more

Using has_tag() outside loop

The has_tag() conditional does not have to be used inside the Loop; it can be passed a $post object as a second parameter: has_tag( $tag, $post ); Since has_tag() defaults to the current post, you simply need to pass it the object for the next adjacent post. Fortunately, WordPress provides a function to retrieve adjacent … Read more

page 1 is not paged

do you mean you want a conditional for page 1 of all home queries which have more than one page as result? try to use $wp_query->max_num_pages; example: if (is_home() && $wp_query->max_num_pages > 1 && !is_paged()) echo ‘/page/1’; else echo “https://wordpress.stackexchange.com/”;

Trying to place shortcode/css/html into an IF conditional statement

Instead of getting all terms, looping over them and then searching your array, you can use the has_termconditinal tag ex: if( has_term( ‘z’, ‘product_cat’,$post->ID ) ) { ?> <div id=”post-timer”> <p class=”timebuy”>Time Left To Buy:</p> <div id=”timer-wrap”> <?php echo do_shortcode( ‘[tminus cid =”12″ omitweeks=”true” days=” ” hours=” ” minutes=” ” seconds=” “/]’ ); ?> </div><!–end … Read more

Conditional Custom Image Header

you could try the following right before you call the body_class() function: <?php $header_image = get_header_image(); if( !empty( $header_image) ){ $custom_body_class=”has-header-image”; } else { $custom_body_class=”no-header-image”; } ?> <body <?php body_class($custom_body_class); ?>>

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