Tag Info

New answers tagged

0

After trying to ask help from others, I got my solution and here I am sharing that below. First there is no use of 'in_same_cat' => false, in upper code and second get_next_post(true);, get_previous_post(true); is used to show next/prev post from current post categories but if you want to show all posts in next/prev then you have to use only ...


1

Thanks for @PieterGoosen for his help, I found the solution for my problem. In my functions.php, I construct the next function: function mod_query($query){ if ( !is_admin() && $query->is_main_query() && $query->is_category('6')){ //My Category ID $query->set('posts_per_page',2); } } ...


0

Using query_posts is generally not recommended. Looking at the Codex, it specifically states: Note: This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it ...


3

Static pages doesn't work with paged query variable, they need the page variable. This is the reason why your second code block makes the query work: it uses the page var when available. However, your paginated links code always use paged: ... 'format' => '?paged=%#%', ... So you are sending paged query var but looking for page var. Solution is to ...


0

I got my solution. <?php // move pagination links above other end-of-post content additions, like related posts etc. function move_pagination( $content ) { if ( is_single() ) { $pagination = wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', ...


0

Depending on your theme, you may look into the template where your comments output reside and include calling pagination before it. For example in TwentyEleven comments output is governed by comments.php


0

This doesn't answer the question you asked, but based on your comment, you don't need two queries to do what you want. A query object is basically just a collection of posts with an internal counter. You can start / stop / manipulate that counter to get the output you want. if( have_posts() ){ the_post(); // output post #1 here } // stuff in ...


1

You could also create a template tag like what the Twenty Fourteen default theme includes rather than hard code it into the single file. if ( ! function_exists( 'twentyfourteen_post_nav' ) ) : function twentyfourteen_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = ( is_attachment() ) ? get_post( ...


2

You will need to add %link to the first parameter ($format) of next_post_link and previous_post_link This will generate the html links to the respective posts EDIT 1 Just on your statement about custom queries, did you had a look at how pre_get_posts can be used to alter the main query as needed. It is never a good idea replacing the main query with a ...


2

After reading a bit on regex and preg, starting from a previous example of a similar problem and testing it I was able to answer my own question. I added this function to functions.php: <?php /** Plugin Name: WPSE (#167237) Redirect after comment */ add_filter('comment_post_redirect', 'redirect_after_comment'); function ...


0

//redirect single add_filter('redirect_canonical','pif_disable_redirect_canonical'); function pif_disable_redirect_canonical($redirect_url) { if (is_single()) $redirect_url = false; return $redirect_url; } I found something similar on wp forum, then you add the js or whatever custom loop that support pagination in single.php


0

Below code will fetch all posts from all categories. Here we have given limit for one page as 10. Then you have to check the permalink structure of ur site. Please check the code I think it will work. /* it will fetch all posts */ $post_args = array( 'posts_per_page' => -1, 'orderby' => ...


2

This can be done with a very short plugin. function posts_on_home_page( $posts_per_page ) { if ( is_home() ) return 5; return $posts_per_page; } add_filter( 'pre_option_posts_per_page', 'posts_on_home_page' ); This is actually pretty close to the Codex example for pre_option_(option_name).


0

Most pagination relies on the $wp_query global. Try changing $loop to $wp_query And put this wp_reset_postdata(); after the endwhile.



Top 50 recent answers are included