Count post views in loop

Few remarks: You should consider using a prefix on your meta key, for example lars_views, to minimize the risk of other plugins messing around with it. If you want to hide it from the edit screen, you can use an underscore: _lars_views. Consider wrapping the part of your code, that updates the counter, with if( … Read more

Move Genesis Single Page/Single Post Title

Try this: add_action( ‘template_redirect’, ‘wpse_124609_remove_titles’ ); /** * Move or remove some post titles. */ function wpse_124609_remove_titles() { if ( is_front_page() ) { remove_action( ‘genesis_post_title’, ‘genesis_do_post_title’ ); } else if ( is_page() || is_single() ) { remove_action( ‘genesis_post_title’, ‘genesis_do_post_title’ ); add_action( ‘genesis_after_header’, ‘title_slider’ ); } } /** * Add Title Slider to some post titles. … Read more

get_posts output always same post

This is because you are not passing the parameters in the correct way, taxonomy param needs to be passed under tax_query. Please replace the $args with the below:– $args = array( ‘posts_per_page’ => 4, ‘tax_query’ => array( array( ‘taxonomy’ => ‘tag’, ‘field’ => ‘slug’, ‘terms’ => ‘pp’ ) ) ); For more details check the … Read more

How can I display other user avatars on an author profile page?

Have you tried to specify the $userID parameter of get_the_author_meta(), like shown below: echo get_avatar(get_the_author_meta( ‘ID’, $post->post_author ), 150); This uses the post_author key from your secondary query, which has the ID as value, that said you should be able to shorten your code to: echo get_avatar( $post->post_author, 150);

Posts in loop all show the same author when there are many authors

You need to move the bulk of your code into the loop proper. This part: $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); $ids[]= $post->ID; endwhile; } When the_post() executes, it populates the $post global upon which a number of template functions depend. The problem is that you are running your … Read more

How to append a query string to pagination?

Refer this: Paginate Codex I can see that you are using custom query so you put this below and outside the while loop <?php global $wp_query; $big = 999999999; // need an unlikely integer $args = array( ‘base’ => str_replace( $big, ‘%#%’, esc_url( get_pagenum_link( $big ) ) ), ‘format’ => ‘?page=%#%’, ‘total’ => $wp_query->max_num_pages, ‘current’ … Read more