Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi @hector7,

    Thank you for your question.

    Yes you can hide sub-wikis from wikis listing page by adding following code in the functions.php file of your child theme

    function exclude_child_wikis($query){
    
        if ( $query->is_post_type_archive('incsub_wiki') ) {
            $query->set('post_parent', '0');
        }
        return $query;
    }
    
    add_filter('pre_get_posts', 'exclude_child_wikis');

    Best Regards,
    WPMU DEV

    Thread Starter hector7

    (@hector7)

    Hi,

    Thanks you so much !!

    Best regard
    Hector

    Thread Starter hector7

    (@hector7)

    Hi Again,

    It’s great, but…this function cancel all sub-wikis !
    I absolutely need to have sub-wikis, but I want these sub-wikis be visible only into the wiki parent page
    I mean, keep the ability to have sub-wikis, but not see them on /wiki/ page

    Thanks !
    Hector

    Hi Hector,

    Thank you for your reply.

    Try using the following code instead of previous one.

    function exclude_child_wikis($query){
    
        if ( $query->is_post_type_archive('incsub_wiki') && ! is_singular('incsub_wiki') ) {
            $query->set('post_parent', '0');
        }
        return $query;
    }
    
    add_filter('pre_get_posts', 'exclude_child_wikis');

    Kind Regards,
    WPMU DEV

    Thread Starter hector7

    (@hector7)

    Hi,

    Thanks again, and thanks to be here even for a “non-profit” customer !
    In fact the code works, I can see sub-wikis into their parent page, and these sub-wikis are hide on /wiki/ page.
    The point is sub-wikis exist but I can’t manage them from the admin dashboard, there are hide from here too.
    Would you have another code portion, to get them visible from the admin dashboard, and hide from the /wiki/ page ?

    Thanks
    Hector

    Hi Hector,

    Here’s the following another code portion.

    function exclude_child_wikis($query){
    
        if ( $query->is_post_type_archive('incsub_wiki') && ! is_singular('incsub_wiki') && ! is_admin() ) {
            $query->set('post_parent', '0');
        }
        return $query;
    }
    
    add_filter('pre_get_posts', 'exclude_child_wikis');

    Don’t hesitate to ask if you face any more issue.

    Cheers,
    WPMU DEV

    Thread Starter hector7

    (@hector7)

    Hi,

    It’s ABSOLUTELY PERFECT !!!
    Thank you so much !

    Cheers,
    Hector

    Hi @hector7, you’re most welcome! Glad our awesome developer was able to assist. ??

    Any further questions, feel free to ask. We’re happy to help!

    Cheers,
    David

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Hide sub-wikis from the list’ is closed to new replies.