Community Forums › Forums › Archived Forums › Design Tips and Tricks › Unable to Specify Categories on a Blog Page
Tagged: blog page, blog template, posts page, query_args
- This topic has 16 replies, 3 voices, and was last updated 3 years, 6 months ago by
fattony69.
-
AuthorPosts
-
March 12, 2020 at 8:28 am #497295
fattony69
ParticipantHello, I am currently building out a family member's site. I am currently stuck because I am trying to limit the type of posts to be on the blog page,. No matter what I do, it doesn't allow me to sort out the categories I don't want to see. Would appreciate any help. Currently have a custom field of querty_args setup with the following:
https://kneblesauto.com/blog/cat=2390, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2419, 2405, 2416, 2417, 2423, 2406, 2407, 2418, 2408, 2409, 2411, 2412;category__not_in=-2, -2213,-2216,-2215,-2236,-2201,-2203,-2207,-2204,-2214,-2206,-2210,-2202,-2205,-2212,-2209,-2217,-2211,-2208
March 12, 2020 at 8:55 am #497296Brad Dalton
ParticipantI tested this again and it works.
Try removing the minus sign - before each category id when using category__not_in
March 12, 2020 at 10:18 am #497297fattony69
Participant@braddalton. Thank you for responding. That is the tutorial I used, but unfortunately it still doesn't work. This is what I am using now after updating.
cat=2390, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2419, 2405, 2416, 2417, 2423, 2406, 2407, 2418, 2408, 2409, 2411, 2412;category__not_in=2, 2213,2216,2215,2236,2201,2203,2207,2204,2214,2206,2210,2202,2205,2212,2209,2217,2211,2208
March 12, 2020 at 11:04 am #497299Anita
Keymaster@fattony69 those look like the Page ID numbers and not the Category ID numbers.
Love coffee, chocolate and my Bella!
March 12, 2020 at 4:50 pm #497302fattony69
Participant@anita I am under the impression it isn't. I am grabbing the ID's from the category edit links:
https://kneblesauto.com/wp-admin/term.php?taxonomy=category&tag_ID=2390&post_type=post&wp_http_referer=%2Fwp-admin%2Fedit-tags.php%3Ftaxonomy%3Dcategory
March 12, 2020 at 8:27 pm #497304Anita
Keymaster@fattony69 okay. The id numbers are large. I normally see them as lower numbers.
From this StudioPress tutorial:
To exclude a specific category, add a minus symbol (in other words, a dash) in front of the category ID parameter in the value field as described below.
* In the Name field, enter or select query_args.
* In the Value field, enter cat=all. All posts from all categories will be displayed on the page.
* Click Add Custom Field to preserve your settings.And normally, you do not include the spaces after the comma (i.e., 1,2,3)
You also have a semicolon in your code which should probably be a comma.
;category__not_in=2
Maybe take all of that out of there completely and only include the items you do not want to have displayed.
Love coffee, chocolate and my Bella!
March 12, 2020 at 8:50 pm #497305Brad Dalton
ParticipantThe semicolon is used to separate each argument.
There's no need to use cat and category__not_in
You either include the categories you want to display or exclude the ones you don't.
Also note, are you using the id for parent categories or child categories?
March 12, 2020 at 8:52 pm #497306Anita
KeymasterMarch 12, 2020 at 9:35 pm #497307fattony69
Participant@anita and @braddalton I appreciate your help very much. I took what you both said and replaced it with the following, but for some reason, nothing changed.
cat=-2,-2213,-2216,-2215,-2236,-2201,-2203,-2207,-2204,-2214,-2206,-2210,-2202,-2205,-2212,-2209,-2217,-2211,-2208
Also, to answer your question, it is both the parent and child categories.
March 12, 2020 at 9:44 pm #497308Brad Dalton
ParticipantAre they the parent id's or child category id's?
Would need to see the entire custom field value field which includes your other arguments.
Please take a screenshot of the custom field which includes the key and value fields.
March 12, 2020 at 9:49 pm #497309fattony69
Participant@brad "2" is the parent category id and the subsequent numbers are the child category id's. Here are the custom field key and values.
March 12, 2020 at 9:58 pm #497311Brad Dalton
ParticipantSee here https://developer.wordpress.org/reference/classes/wp_query/#category-parameters
Try category__not_in with the parent category id's only.
March 12, 2020 at 10:05 pm #497312March 12, 2020 at 10:32 pm #497313Brad Dalton
ParticipantMarch 12, 2020 at 10:34 pm #497314fattony69
Participant@braddalton Ah. I have fixed it to what you showed and unfortunately still doesn't change.
March 12, 2020 at 10:51 pm #497315Brad Dalton
ParticipantAnd you added the parent category id's or child id's?
You set the Settings > Reading > posts page to the page using the custom fields?
Based on my testing it works.
March 12, 2020 at 11:02 pm #497316fattony69
Participant@braddalton Solely the parent category id and yes I chose the correct page.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.