[Resolved] Custom category archive page

Home Forums Support [Resolved] Custom category archive page

Home Forums Support Custom category archive page

Viewing 13 posts - 16 through 28 (of 28 total)
  • Author
    Posts
  • #1784839
    Tom
    Lead Developer
    Lead Developer

    Can you try the updated second function?

    #1789145
    Nemanja

    Hi Tom,

    I tried the updated function, posts are now displayed correctly but they are still duplicated.

    Link below.

    #1790082
    Tom
    Lead Developer
    Lead Developer

    Aha, that makes sense. The archive query is built before WPSP is rendered, so it’s not aware of the posts that WPSP is going to display yet.

    Hmm, tough one. We would need a way to know which posts WPSP will be showing before it’s actually rendered. Maybe they’re in a specific category? A set list of IDs?

    #1792296
    Nemanja

    Hi Tom,
    thank you for your quick response.

    I have put both WPSP lists inside block-hook element and hooked them inside container, and than removed (.generate-columns-container{display:none}) default WP posts. So it works as it should now.

    But now I can’t display posts by author. Is there any similar shortcode ( [wp_show_posts id=”123″ settings=”taxonomy=category&tax_term=current”] ) I can use, so i can display posts by author??

    Thank you so much for your time.

    #1792869
    Tom
    Lead Developer
    Lead Developer

    You can use the author parameter in the shortcode which accepts the author ID: https://developer.wordpress.org/reference/classes/wp_query/#author-parameters

    You may need some additional PHP if you’re wanting to get that author ID dynamically.

    #1794951
    Nemanja

    Hi Tom,
    Yes , I need that snippet because I want to get that ID dynamically.
    So please if you can sand me that I would be grateful.

    Thank you!

    #1796293
    Tom
    Lead Developer
    Lead Developer

    Where would the ID come from? Is this for an author archive page?

    #1796366
    Nemanja

    Maybe it can take name of an author from link and yes it is for an author archive page.

    Link below.(currently showing WPSP list with specified author ID)

    #1797620
    Tom
    Lead Developer
    Lead Developer

    This might help: https://wordpress.stackexchange.com/questions/35249/echo-author-id-in-author-php

    I would try this one:

    $author = get_queried_object();
    $author_id = $author->ID;
    #1801026
    Nemanja

    Hi Tom,
    I don’t understand where to put that code, can you please be more specific?

    Thank you so much for your time.

    #1801782
    Tom
    Lead Developer
    Lead Developer

    The first thing to do would be to install this version of WPSP: https://wpshowposts.com/wp-show-posts-1-2-0/

    Then, you could try this filter:

    add_filter( 'wpsp_query_args', function( $args, $settings ) {
        if ( 123 === (int) $settings['list_id'] && is_author() ) {
            $author = get_queried_object();
            $args['author'] = $author->ID;
        }
    
        return $args;
    }, 10, 2 );

    You’ll just need to update 123 with the ID of the list you’re targeting.

    #1806338
    Nemanja

    Hi Tom,
    I found another way to display those posts with CSS.

    Thank you so much for your time and help.
    You guys are great !!

    #1807592
    Tom
    Lead Developer
    Lead Developer

    No problem! 🙂

Viewing 13 posts - 16 through 28 (of 28 total)
  • You must be logged in to reply to this topic.