Support » Fixing WordPress » How to redirect (or change) permalinks to a WP_query loop?

  • So I have a page called ‘comics’ which uses a custom template containing a WP_query loop of the posts in my site (1 comic strip per page, with prev/next buttons for navigation). I also have an archive page that lists down all the posts within the ‘comics’ category.

    By default, the links on the archive page link to the specific post itself, but how can I change it to link to the post in the WP_query loop?
    e.g. What I need – http://localhost:8888/wordpress/weekly-comics/page/2/
    What it’s linking to – http://localhost:8888/wordpress/sample-post-2/

    I know I can use 301 redirect plugins and put in the correct link for every post, but I’m doing this for a client so it would be better if I could make things easier for her.

    If you need to know, here’s the WP_query loop in the comics.php page:

    $comics_loop = new WP_Query(
            'posts_per_page' => 1,
            'paged' => get_query_var('paged'),
            'category_name' => comics
    if($comics_loop->have_posts()) :
    echo '<ul class="comic-slider-container">';
    while($comics_loop->have_posts()) : $comics_loop->the_post();
        <li><h1 id="comic-slider-title" class="page-title">Weekly Comics  |  <span class="title-alt"><?php the_title(); ?></span>   <a href="<?php bloginfo('url') ?>/category/comics/" id="archive-button" class="big-button">Archives</a></h1></li>
        <li><?php the_post_thumbnail( 'full' ); ?></li>
        <li><?php the_content(); ?></li>
        <li><p class="byline vcard">
                printf(__('Posted <time class="updated" datetime="%1$s" pubdate>%2$s</time>', 'bonestheme'), get_the_time('Y-m-j'), get_the_time(__('F jS, Y', 'bonestheme')) );
    echo "</ul>";

    and the archive page’s title links by default:
    <h3 class="h2"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>

  • The topic ‘How to redirect (or change) permalinks to a WP_query loop?’ is closed to new replies.