Search Results: Differentiate posts and pages

<?php if(get_post_type() == ‘page’): // Only pages ?> <div class=”recent_postMetaSingle”> <img src=”https://wordpress.stackexchange.com/questions/31727/<?php bloginfo(“template_directory’); ?>/images/eye.png” alt=”Views” title=”views” /> <?php print_page_views(get_the_ID(”)); ?> <p>This is a static page!</p></div> <?php elseif(get_post_type() == ‘post’): // If not page, Only posts ?> <div class=”recent_postMetaSingle”> <img src=”https://wordpress.stackexchange.com/questions/31727/<?php bloginfo(“template_directory’); ?>/images/eye.png” alt=”Views” title=”views” /> <?php print_page_views(get_the_ID(”)); ?> &nbsp;&nbsp;&nbsp; <img src=”https://wordpress.stackexchange.com/questions/31727/<?php bloginfo(“template_directory’); ?>/images/comments2.png” alt=”Comments” title=”comments” … Read more

conditional statement for custom taxonomy

I’m pretty sure you shouldn’t use negation in your conditions… If you check ! is_tax… it will be true not only for other taxonomy pages, but also for singular pages, and any other… So it should look like this: <?php if ( is_tax(‘taxonomy-name’,’taxonomy-one’ ) ) {?> <div class=”test” style=”color: red”><?php the_field(‘field_name’); ?></div> <?php } elseif … Read more

wp_head hook by page ID [closed]

If you want to use different meta tags for different pages I recommend you to use custom field values. If you prefer to do it with conditional functions, try this: add_action( ‘wp_head’,’carlos_head_meta_page’ ); function carlos_head_meta_page() { if ( is_page(‘4’) ) { $description = ‘tag1’; } else { $description = ‘tag2’; } ?> <meta name=”description” content=”<?php … Read more

WordPress conditionals not working

The problem is that you’re wrapping your add_action() calls inside of the conditionals, but at the point at which those add_action() calls are executed, neither the query nor the query conditionals are available yet. Solution: put the conditionals inside the callbacks: function faq_start_shortcode( $atts, $content = null ) { if ( is_single() || is_page() ) … Read more

Using Conditional Statement in functions.php

Basically, you put the second block into the first. And wait until the last moment: add_action( ‘pre_get_posts’, ‘wpse_71899_start_filter’ ); function wpse_71899_start_filter() { // wrong page if ( ! is_page( ‘Home’ ) ) return; // stop here. add_filter(‘posts_orderby’, ‘edit_posts_orderby’); add_filter(‘posts_join_paged’,’edit_posts_join_paged’); } function edit_posts_join_paged($join_paged_statement) { global $wpdb; $join_paged_statement = “LEFT JOIN “.$wpdb->prefix.”wpv_voting ON “.$wpdb->prefix.”wpv_voting.post_id = $wpdb->posts.ID”; return … Read more

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