Tagged: 

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1205377

    Hello there!

    We are trying to create a nested blog post category structure and have a simple request:

    How do we stop the child categories from displaying in the Blog Posts list/grid/etc when we select the parent category? We want to be able to choose which pages display the child categories and which just show the parent categories.. It seems like it should be simple as if we wanted to show the child categories we would simple select them along with the parent category in your handy category picker in the content element.

    Please help!

    Cody

    #1205807

    Hey codyw,

    Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?

    Best regards,
    Victoria

    #1206693

    Great thanks! You will see on our website that at the bottom of the main page, we are working on this grid system. It has 8 posts that should be there, and any others that are in the child categories shouldn’t be (such as Member Deals or Membership Directory, which should only show up on the grid once people click).

    Also, if you look at something like 30% Off Bumper to Bumper: It shows up on both the Community Board grid and Membership Grid and Member Deals grid, although it needs to only show up on Member Deals grid and not the parent grids.

    I hope this is possible and simple! Seems like a common issue that would be needed for these sorts of things.

    Also, ideally, there would be times when we could make it work this way, but we can always just select to show all the child and parent categories in a grid rather than have it automatic.

    #1206896

    Hi codyw,

    Well, this will require a custom query, something like in this thread:

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1206948

    Hey there thank you, is there any custom coding we need outside of a system like this one?

    Could you please paste code that would work here for our homepage and then I can adapt for other pages as needed? I am having a bit of a hard time figuring out how to make it work and I bought support again just for this one question.

    #1206982

    Hey there!

    So I used the code in that post and changed it to work for our site, I think, but it isn’t working.

    Can you please check? Here is the code I used to try and hide “membership” and “membership-deals” from the homepage

    `// exclude categories
    add_filter( ‘avia_blog_post_query’, ‘avia_blog_post_query_mod’, 10, 2 );
    function avia_blog_post_query_mod($query, $params) {
    if( is_page(‘landing-page’) ) {
    // exclude category when the current page is “landing-page”
    $query[‘tax_query’][] =
    [
    ‘taxonomy’ => ‘category’,
    ‘field’ => ‘name’,
    ‘terms’ => ‘membership’,
    ‘operator’ => ‘NOT IN’,
    ];
    }

    if( is_page(‘landing-page’) ) {
    // exclude an array of categories on the “fish” page
    $query[‘tax_query’][] =
    [
    ‘taxonomy’ => ‘category’,
    ‘field’ => ‘name’,
    ‘terms’ => array(‘membership’, ‘member-deals’, ‘member-directory’),
    ‘operator’ => ‘NOT IN’,
    ];
    }

    return $query;
    }

    #1206983

    Oh, also, I added the code in the bottom of the “Functions.php” file. I am not sure if I did something wrong but it doesn’t seem to hide them

    #1208073

    Hey there, still waiting and wondering if there is any support for this? We are trying to launch a page to help our community in the face of COVID-19 and would love your support.

    #1208228

    Hi codyw,

    Here is the code you can put in your funtions.php

    
    // exclude categories
    add_filter( 'avia_blog_post_query', 'avia_blog_post_query_mod', 10, 2 );
    function avia_blog_post_query_mod($query, $params) {
        if( is_page('home') ) {
            // exclude meat category when the current page is "home"
            $query['tax_query'][] =
            [
                'taxonomy' => 'category',
                'field'    => 'name',
                'terms'    => array('membership', 'member-deals', 'member-directory'),
                'operator' => 'NOT IN',
            ];
        }	
    
    
    
        return $query;
    }
    

    Please make the account admin.

    You need to add the code after this line:
    Image 2020-04-29 at 19.06.00.png

    If you need further assistance please let us know.

    Best regards,
    Victoria

    #1208268

    Thank you!

    Having a bit of issues where it gives this notice when I paste that code into the fields you mentioned:

    Your PHP code changes were rolled back due to an error on line 26 of file wp-content/themes/enfold/functions.php. Please fix and try saving again.

    syntax error, unexpected ‘=’, expecting ‘]’

    #1208276

    So I tried using that code and got the error above. I modified it and used this code, but it still has the same blog categories showing up on the page: (The name of the page is ‘landing-page’ so I am assuming to use that). I put it under line 17 as you sent in the photo

    // exclude categories
    add_filter( ‘avia_blog_post_query’, ‘avia_blog_post_query_mod’, 10, 2 );
    function avia_blog_post_query_mod($query, $params) {

    if( is_page(‘landing-page’) ) {
    // exclude an array of categories on the “fish” page
    $query[‘tax_query’][] =
    [
    ‘taxonomy’ => ‘category’,
    ‘field’ => ‘name’,
    ‘terms’ => array(‘membership’, ‘member-deals’, ‘member-directory’),
    ‘operator’ => ‘NOT IN’,
    ];
    }

    return $query;
    }

    #1208281

    Is there some sort of option to select to activate this part that it is inside?

    if(isset($avia_config[‘use_child_theme_functions_only’])) return;

    ?

    Getting close I can feel it!

    #1209808

    5 days and still waiting to hear about if this is going to work folks… Please help us? We were supposed to launch this page tomorrow and the only thing holding us back is this seemingly simple issue. We really need to be able to select each category and not have the children all show up unless we select them individually in the masonry grid.

    #1209815

    Please please help me here, I am getting frustrated and need your support. We have a zoom meeting tomorrow with our community to talk about launching this and they won’t understand the issue. We gave you login info, can you please look at the site and see how we can just display 1-deep category or select the categories we want to show? Or do we need to re-design the entire website or use another theme?

    #1211391

    Hi codyw,

    Sorry, I could not get to this thread earlier.

    I asked you to make the account admin, I cannot see the editor, the categories, and the theme options. Can you do that?

    Best regards,
    Victoria

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