[Support request] Show only post parents – Show only post children

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Show only post parents – Show only post children

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35365

    Hello good morning Tom and team ❤️, I am very happy to see your photo, it brings back good memories.

    I need to do this:
    First.
    Show only the post parents.
    EJMPLO:
    *SHORCODE IS HERE ROOT
    PARENT1 (YES DISPLAY)
    CHILD1 IN PARENT 1 (NO DISPLAY THIS)
    CHILD2 IN PARENT 2 (NO DISPLAY THIS)
    PARENT2 (YES DISPLAY)
    PARENT3 (YES DISPLAY)

    Second:
    Show only child posts within a parent post.
    EJEMPLO:
    PARENT1 *SHORCODE IS HERE (NO DISPLAY THIS POST)
    CHILD1 IN PARENT 1 (YES DISPLAY)
    CHILD2 IN PARENT 1 (YES DISPLAY)
    CHILD3 IN PARENT 1 (YES DISPLAY)
    CHILD3 IN PARENT 1 (YES DISPLAY)

    THANK YOU VERY MUCH 🙏

    #35399
    elvin
    Moderator

    Hi Juan,

    by “post parents” do you mean Parent Pages? (static page that have child pages)

    IF so, we’ll need to use wp_show_posts_shortcode_args.

    But to be able to use it properly you need to either use the beta version – https://wpshowposts.com/wp-show-posts-1-2-0/

    Or make this change in your wp-show-posts.php as Tom suggests here –
    https://github.com/tomusborne/wp-show-posts/commit/286caf1164db8b6b6f38b85d3a011b519a27f4de

    and then do this filter for the list you want to display post parents only.

    add_filter( 'wp_show_posts_shortcode_args', function( $args, $settings ) {
        if ( 1234 === $settings['list_id'] ) {
            $args['post_type'] = 'page';
    	$args['post_parent'] = '0';
        }
    
        return $args;
    }, 20, 2 );

    Change 1234 to the WPSP list ID you want this to apply to.

    For the second one which lists child pages only:

    Do you want to specify parents? Or you want to display child pages of ALL parents?

    If it’s for a specific parent, How would you like to determine the parent? Is it the current page where the child page listing will be displayed?

    Let us know.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.