Forums

Link directly to the latest post from the category link (7 posts)

  1. brisimmons105
    Member
    Posted 1 year ago #

    I've currently got a page that lists out all of the categories on my site...there are quite a few and they only have a few posts each.

    When someone clicks on one of the categories, it currently takes them to a "category archives" page, and in there are all of the posts that are in that category.

    Instead of going to the category archives, I'd like for them to be automatically taken to the most recent post in that category.

    The thing is, I have to generate the category ID's dynamically, as I will be adding them frequently...

    I'm not great at php, but I can usually power through it.

    I would be very grateful if you could help me out.

    Thanks

  2. Jonas Grumby
    Member
    Posted 1 year ago #

    In the Settings you could specify that you only want to show 1 post and in your theme's archive.php file you could display the_content rather than the_excerpt. Just beware of being penalized by search engines for duplicate content.

  3. brisimmons105
    Member
    Posted 1 year ago #

    Thanks for responding Jonas, but I'd rather not do anything like that to get this running.

    I know there is a way to do it within a category loop...I think i'd just have to change the category URL call to the latest post url call.

    I'm just not good enough at php yet to figure it out.

  4. Jonas Grumby
    Member
    Posted 1 year ago #

    You could also do it by replacing the loop in your archive.php with something that uses query_posts but it seems like it would be much easier to do it the other way, especially if you want all of your categories to do the same thing.

  5. brisimmons105
    Member
    Posted 1 year ago #

    Yea, I'd like to have all of the categories do the same thing. To be honest, I'm not sure the best way to go about doing it, but I'd like to to go directly to the posts page altogether, and not have to redirect, or anything like that.

  6. Jonas Grumby
    Member
    Posted 1 year ago #

    The easiest way would be to set your admin to only show one post on the blog pages. It would not require a redirect.

  7. brisimmons105
    Member
    Posted 1 year ago #

    @alchymyth [referring to your last comment from the post that was moved here]
    It somewhat worked...
    It listed out the categories, but only 5 of the 7 were hyperlinks. The 5 that were hyperlinks worked great.

    Unfortunately, the icons were not working.
    When I uncommented the wp_list_categories it called the categories with the icons like normal, and then listed them out again, like above, linking 5 of the 7 to the posts.

    Do you think I could modify the wp_list_categories function to always go to the posts?
    That way it should keep the icons there, and go straight to the posts.

    Thanks for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.