Viewing 6 replies - 31 through 36 (of 36 total)
  • Danny

    (@dannyfoo)

    I’m facing difficulty with this too. And it took me a really long time to just get the blog working especially with custom permalinks so my posts would display /blog/post-name/.

    This is what I’m currently using; https://pastebin.com/f12a445fb.

    Anyone got a solution yet?

    Fix: paging in WordPress under IIS

    For the last few minutes, I have been trying to figure out why next_posts_link() did not work on a template for a clients’ blog, under IIS.

    I found a great tip, but I prefer standard functions over things that work.

    Then I found out under IIS, PHP returns a wrong value for $_SERVER[“REQUEST_URI”]. The link to the previous page was index.php/Index.php/page/2/. Notice there are two “index.php” (for Windows, index and Index are just the same.)

    The real, working, clean and easy solution is to add a simple line of code in the clean_url() function in wp-includes/formatting.php:

    $url = str_replace(‘index.php/Index.php’,’index.php’,$url);

    just put this at the beginning of the function before any “if Statements” only thing is you have to remember to do this again if you upgrade word press.

    Hope this helps you out.

    My Site https://blog.ebookzones.com you will see my PageNav now works great.

    Don

    Ok, this has bothered me for a long time and now i have finally found a solution on a website.

    Where’s the problem? query_posts() is a powerful function, but in this situation it has a flaw: it overrides nearly everything in the standard posts object query, including what the paged offset is.

    How to fix it? To get proper pagination with query_posts() we need to recreate it through the ‘paged’ parameter or query. Best way to do this is to ask WordPress for the “page” we happen to be on, and use that as our ‘paged’ value. There’s the code for it

    <?php if (have_posts()) : ?>
    <?php query_posts(“category_name=somecat”); ?>
    <?php while (have_posts()) : the_post(); ?>

    replace with

    <?php if (have_posts()) : ?>
    <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts(“category_name=somecat&paged=$paged”); ?>
    <?php while (have_posts()) : the_post(); ?>

    And that’s it! The $paged = line above uses what’s called a ternary operator to test whether the ‘paged’ query variable is available. If it is, $paged receives its value. If it isn’t, we assume we’re on the first page and assign it ‘1’. Then we tell query_posts() what page we’re on with the addition of &paged=$paged.

    Many thanks rizwanashraf! That did it perfectly for me ??

    Hi rizwanashraf, I use Original Premium News theme, I have the same problems with page navigation and I didn’t find the code you were talking about. Where should I look for it, in the theme’s pages or in WordPress pages? I have tried everything I read on this forum, but still I can’t figure it out.

    Please, if you have the time to look at the problem, I’ll be happy to give you more details. My blog is https://www.movietrailerworld.com

    Thank you.

    Sorry for the mistype that’s https://www.movietrailersworld.com

Viewing 6 replies - 31 through 36 (of 36 total)
  • The topic ‘Next/Previous Links not working’ is closed to new replies.