Forums

First page in category (4 posts)

  1. Starlet
    Member
    Posted 3 years ago #

    Howdy good folks, hope I am posting this is the right section.

    What I would like to do is have a dynamic link to the first post in a category -- so when you click into say the 'Site News' category where the links for 'Next page' and 'Previous page' are there would also be a link for 'First page'.

    Is this possible with either a bit of code or a plugin? I've searched and searched but not been able to come up with any thing myself.

    Any help would be appreciated :)

  2. msbrauer
    Member
    Posted 3 years ago #

    I'm trying to figure this out, too. Did you find a solution?

  3. Dr.Aether
    Member
    Posted 3 years ago #

    Not sure if this is the right way, but it was a way that worked for me to create a link back to the first post of a category:

    at the top of the particular page of interest I created this block:

    <?php
    $cat = 0;
    $p_count = 0;
    $cat_start_link = '';
    foreach((get_the_category()) as $category) {
    $cat = $category->cat_ID;
    $p_count = ($category->count);

    // combine to get the final link with cat=#&paged=#
    $cat_start_link = get_category_link($cat) . '&paged=' . $p_count;
    }
    ?>

    Then down in the content I created a link something along these lines (styled of course):

    ">First Post!

  4. Dr.Aether
    Member
    Posted 3 years ago #

    Hm it deleted the last part... lets try that again:

    <a href="<?php echo $cat_start_link ?>">First Post!</a>

Topic Closed

This topic has been closed to new replies.

About this Topic