• I’ve been working for quite a few months on a redesign of https://createdigitalmusic.com – migrating from Mambo to WordPress in the process.

    One of the features of our new template is little inter-post navigation links, as seen on https://treehugger.com/.

    You can see my version on https://createdigitalmusic.com, they show up as little up and down arrows underneath the red date header box for each post.

    When on a home template page they let you go up and down between posts, and when on a single page they are next_post and previous_post links. This is all good.

    However, for the bottom post on pages using the home template, I’d like the Next button (down arrow) to point to the next page, so https://createdigitalmusic.com/page/2/.

    Over several sessions of trying and forum searching I haven’t been able to achieve this.

    I thought my problem may be something like this – https://www.ads-software.com/support/topic/57912 – as I use a custom query to run the loop twice. However I’m using a query like this:

    <?php $my_query = new WP_Query('category_name=highlight&showposts=3');
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;?>
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_excerpt(); ?></a>
    <?php endwhile; ?>

    … in the header, followed by a normal loop to run the main posts.

    I may have missed something very obvious, but I haven’t been able to get wordpress to create a link to the next page.

    I was thinking I could just get php to create a “hardcoded” link to /page/#/, # being the current page number + 1, but I haven’t been able to find how to access the paged…

    So, while writing that my brain put everything together and told me that I already did know how to access the paged variable, it’s mentioned in the forum topic I linked above. However it doesn’t seem to work as I expected. I’m using this:

    <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>

    Which from that topic seems like it should return “1” if query variable “paged” is empty, or another number if query variable “paged” has something in it. However for me it’s returning “1” every time.

    Any pointers to fix this?

Viewing 13 replies - 16 through 28 (of 28 total)
  • Hmm, I know why it gave that error but no clue what caused it.

    Disable ALL plugins one by one. It could be plugin ’cause I have same code with no error.

    Will do. One Sec….

    Not much help as disabling some plugins causes a the full page to go down (call to undefined function). Any ideas on a workaround that I could link to directly (I’m currently using home.php instead of index.php). I tried to set up index.php with a normal loop and then link it href="?index.php". No luck as it still goes to home.php. I understand the template hierarchy for the most part but haven’t figured this out yet.

    Getting “call to undefined function” as you disable plugins is normal. So, do you know which plugin causes the error you mentioned?

    Not sure I understand how to debug the page when disabling one plugin causes a fatal error (call to undefined function was just a little error). When the whole page goes down, I can’t debug any plugin. As far as I can tell, to fully debug this I would have to strip all code that is specific to a plugin out of the page. Is this what you would recommend?

    You would disable plugin one by one until you dont get that error below. No need to delete any code.

    WordPress database error: [Not unique table/alias: ‘wp_post2cat’]…

    I tried that, but deleting one (ex: fold_page_list plugin) ends any processing of any of the scripts below. Here’s list of what plugins I’m using. Not sure it will help. Sorry for any frustration.

    * Todo List Plugin (admin)
    * Customizable Post Listings
    * Fold Page List
    * podPress
    * Post Image
    * Random Posts
    * Recent Posts
    * Sideblog WordPress Plugin

    well, then, I guess you have to remove all code used by plugins. Then start adding it one by one until you get the error. I’m not gonna look into those plugins you list–too much.

    Thanks for the help. I give it a try in the morning. ZZZZZZZZZZZZ…….

    Awake and working again. Got something working. I had to compromise a bit but that’s ok. Thanks so much for your help alphaoide.

    I need one more tweak to get this going. I have pasted the code here:
    https://wordpress.pastebin.ca/174379

    Here’s the thing. I’m trying to exclude multiple categories in WordPress loop w/o screwing up the post nav at the bottom. I’ve got it working but the only problem is when the newest post is in the excluded category, the loop returns nothing. I realize I need to provide an “else” statement to tell the loop to go back to a post that is in the allowed categories, but I’m not sure how to go about it. Any help would be great. Thanks.

    There might be another way. This page talks about putting this in the loop

    <?php if (in_category('3')) continue; ?>

    I’ve tried it verbatim with no luck. I know there has to be a way to exclude mulitiple cats in the loop and still be able to use the post navigation. I’m gonna keep looking.

    Real quick. I’m thinking now the loop is working correctly but since I have my home page set to show only 1 post, it just doesn’t show anything. I have to make this section show only one post though. Back to the search.

    I’ve found that the SideBlog Plugin does a great job of excluding cats from the standard loop. I’m going to see if I can use this to my advantage.

Viewing 13 replies - 16 through 28 (of 28 total)
  • The topic ‘Custom next page link outside loop, access to paged variable – get_query_var?’ is closed to new replies.