Fix custom query pagination without changing site-wide posts-per-page settings

I assume you have a custom post type: publication in functions.php place that code: function mk_parse_query($query) { if ($query->query_vars[‘post_type’] == ‘publication’)) { set_query_var( ‘posts_per_page’, 5 ); } } if( !is_admin() ) { add_filter(‘parse_query’,’mk_parse_query’); } Similar code works for me, but in my case I was struggling with 404 on custom taxonomies paged urls. Hope this … Read more

MySQL query performed 4 times inside loop

Using a plugin to run PHP code inside your content is not the sanest thing to do, especially when said code is not idempotent. Basically, you cannot guarantee that your code will only run once per page load, since several different things in the system may be processing your content, and thus executing your code, … Read more

Related Posts loop – offset

Do you mean you want to display three blocks of four related posts, and flip between the three blocks using scrollable? If so, does the below help (not tested)? Assuming scrollable needs its content in separate divs, you could do something like this. It should produce a containing div with up to three divs inside, … Read more

How to have different content in the loop and single

you can add additional information to your posts through using post meta: http://wp.tutsplus.com/tutorials/plugins/how-to-create-custom-wordpress-writemeta-boxes/ If you want to check if WordPress is going to display just a single post/single page or more, you could use something like this before your loop: $single_page = false; if(is_single() || is_page()) $single_page = true; And then in your loop you … Read more

as a shortcode within the loop?

Using the the_posts filter: Here’s one idea using the the_posts filter, that fires before setup_postdata() is activated: /** * Replace [nextpage] with <!–nextpage–> through the ‘the_posts’ filter. * * @see http://wordpress.stackexchange.com/a/183980/26350 */ ! is_admin() && add_filter( ‘the_posts’, function( $posts ) { $posts = array_map( function( $p ) { if ( false !== strpos( $p->post_content, ‘[nextpage]’ … Read more

How to show related posts by category or custom post type?

<?php $related = get_posts( array( ‘category__in’ => wp_get_post_categories($post->ID), ‘numberposts’ => 5,’post_type’ => ‘news’, ‘post__not_in’ => array($post->ID) ) ); if( $related ) foreach( $related as $post ) { setup_postdata($post); ?> <li> <?php the_post_thumbnail(); ?> <a href=”https://wordpress.stackexchange.com/questions/151897/<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></a> </li> <?php } wp_reset_postdata(); ?>

Previous and Next Post link doesn’t work

EDIT Referring back to one of your previous questions I’ve answered, you are using custom taxonomies, so this is most likely your problem then. You then have to set the taxonomy parameter accordingly. See my original answer ORIGINAL ANSWER There are a few things to check here Where is your next_post_link. Did you leave out … Read more