Tagged: categories
-
AuthorPosts
-
April 20, 2020 at 4:47 am #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
April 21, 2020 at 2:44 pm #1205807Hey 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,
VictoriaApril 23, 2020 at 9:57 pm #1206693Great 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.
April 24, 2020 at 6:25 pm #1206896Hi codyw,
Well, this will require a custom query, something like in this thread:
If you need further assistance please let us know.
Best regards,
VictoriaApril 24, 2020 at 8:28 pm #1206948Hey 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.
April 24, 2020 at 10:30 pm #1206982Hey 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;
}
‘April 24, 2020 at 10:32 pm #1206983Oh, 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
April 29, 2020 at 6:45 am #1208073Hey 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.
April 29, 2020 at 6:06 pm #1208228Hi 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:
If you need further assistance please let us know.
Best regards,
VictoriaApril 29, 2020 at 7:09 pm #1208268Thank 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 ‘]’
April 29, 2020 at 7:14 pm #1208276So 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;
}April 29, 2020 at 7:20 pm #1208281Is 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!
May 5, 2020 at 6:51 am #12098085 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.
May 5, 2020 at 7:00 am #1209815Please 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?
May 9, 2020 at 3:16 pm #1211391Hi 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 -
AuthorPosts
- You must be logged in to reply to this topic.