• Resolved v.jette

    (@vjette)


    I’m trying to use the Post Masonry to display the child page of any given pages but alast it’s not working the way I intended it to be.

    While you can limit the post to a certain category, there’s no way to limit the pages being displayed. I’d like to be able to display only the child page, or at least have to option to use keywords or categories. Is there a way I can achieve such a result?

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter v.jette

    (@vjette)

    Or at the very least could I enable “Categories” on the pages and limit/exclude certain pages?

    Plugin Support Team Brainstorm Force

    (@brainstormteam)

    Hello @vjette ,

    I’m not sure if I fully understood your question. Could you please provide more details about your requirements? If you could provide some screenshots, a video, or some more details, that would help greatly.

    Looking forward to hearing from you.

    Regards,
    Sweta

    Thread Starter v.jette

    (@vjette)

    Yes sure.

    So I know you can use the Post Masonry block to display posts and pages.
    There are some options for the posts but no options for the pages.

    What I’d like to achieve is to be able to use the Post Masonry block to display a number of pages, more specifically the child pages of a given page.

    So lets say I have the following pages :

    Current research
    – Child current 1
    – Child current 2
    – Child current 3

    Past Research
    – Child past 1
    – Child past 2
    – Child past 3
    – Child past 4
    – Child past 5

    In Current research I’d like to limit the block display to Child current 1, 2 and 3.

    I have also enable categories on my pages, so I could also limit the block by categories or tags (I could tag my child page with “current” for example and limit the display with the tag/category).

    Plugin Support Team Brainstorm Force

    (@brainstormteam)

    Hello @vjette ,

    You can achieve this by using our filter/action hooks. Please refer to this document.

    Here is the custom code to display child pages of parent page –

    function filter_post_query( $query_args, $attributes) {
    	// Modify $query_args values.
    	// 3106 is id of parent page.
    	$query_args = array(
    		'post_type'      => 'page',
    		'posts_per_page' => 2,	// to limit the pages
    		'post_parent'    => 3106,
    	 );
        return $query_args;
    } 
    add_filter( 'uagb_post_query_args_grid', 'filter_post_query', 10, 2 );

    The above code displays the child pages of the parent page i.e 3106 and also increases posts_per_page as per your requirement.

    I hope this helps.

    Regards,
    Sweta

    Thread Starter v.jette

    (@vjette)

    But this will only work for a given page that’s correct? I can’t reuse this on multiple pages?

    Plugin Support Team Brainstorm Force

    (@brainstormteam)

    Hello @vjette ,

    You can achieve the same for all pages. You just need to fetch/get the post ID of the current page.

    Like this –

    function filter_post_query( $query_args, $attributes) {
    	// Modify $query_args values.
    	global $post;
    	// $post->ID is id of current page.
    	$query_args = array(
    		'post_type'      => 'page',
    		'posts_per_page' => 2,	// to limit the pages
    		'post_parent'    => $post->ID,
    	 );
        return $query_args;
    } 
    add_filter( 'uagb_post_query_args_grid', 'filter_post_query', 10, 2 );

    Please note that the current page must have child pages.

    I hope this helps.

    Regards,
    Sweta

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Use Post Masonry to display Child page/limit pages’ is closed to new replies.