Creating a block-based theme Category page template for Custom Post Types
I’ve been experimenting with building block-based themes. In order to create a category page template you would create a /block-template directory and add a category.html file. Then you can jump into the block editor, drop in whatever blocks you want to use, go to the code editor, copy the code and paste that into the category.html file.
Now, the key to all of this is that one of the blocks you use when creating the template is the core Query loop block. You’ll then set it to ‘Inherit query from URL’:
That’s it, you’ve got a category page template that displays the posts of whatever category the current url is showing.
The category page template doesn’t work for Custom Post Types
That’s right, I tried using the core Query loop block, but the categories of the custom post type would not display.
Why is that? Because custom post types are excluded from the main query by default. Thank you Pieter Goosen for your very helpful StackOverflow assist.
At any rate, to include the custom post type in the main query, you just need to use the pre_get_posts hook, here’s a code snippet of what that could look like straight from Pieter’s StackOverflow:
function custom_post_type_cat_filter($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_category()) {
$query->set( 'post_type', array( 'post', 'YOUR CPT' ) );
}
}
}
add_action('pre_get_posts','custom_post_type_cat_filter');
How to make money online – earnings with investment https://sites.google.com/view/site-for-investing-in-bitcoin/how-to-make-money-online-earnings-with-investment
How to make money online | earnings with investment https://www.pinterest.com/pin/1071153092593218340/
Delta Airlines Phone Number | Delta airlines customer service phone number https://sites.google.com/view/delta-airlines-phone/
Delta Airlines Phone Number | Delta airlines customer service phone number https://sites.google.com/view/delta-airlines-phone/
Delta Airlines Phone Number | Delta airlines customer service phone number https://telegra.ph/Delta-Airlines-Manage-Booking–18556702491-10-01
Delta Airlines Phone Number | Delta airlines customer service phone number https://telegra.ph/Delta-Airlines-Manage-Booking–18556702491-10-01
Веном 2 – 2019 смотреть онлайн в хорошем качестве https://bit.ly/venom2_2019
Титан 2021 смотреть онлайн в хорошем качестве https://bit.ly/titan2021
control of pest Pennsylvania service http://g7taxi.vn/?s=control+of+pest+%E2%98%8E+1%28844%299484793+Pennsylvania+service+phone+number
control of pest San Jose service https://www.ftmd.itb.ac.id/en/?s=control+of+pest+%E2%98%8E+1%28844%299484793+San Jose+service+phone+number
control of pest Fort Worth service https://sdachurch.com/?s=control+of+pest+%E2%98%8E+1%28844%299484793+Fort Worth+service+phone+number
control of pest SD service https://www.uvaldeleadernews.com/?s=control+of+pest+%E2%98%8E+1%28844%299484793+SD+service+phone+number
control of pest New Hampshire service https://111.wales.nhs.uk/localservices/viewlocalservice.aspx?s=control+of+pest+%E2%98%8E+1%28844%299484793+New Hampshire+service+phone+number
control of pest NC service https://www.andrewchoo.edu.my/?s=control+of+pest+%E2%98%8E+1%28844%299484793+NC+service+phone+number
control of pest ME service https://iqmore.tw/?s=control+of+pest+%E2%98%8E+1%28844%299484793+ME+service+phone+number
control of pest PA service https://trussvilletribune.com/?s=control+of+pest+%E2%98%8E+1%28844%299484793+PA+service+phone+number
control of pest Virginia service https://sacmuseum.org/page/39/?s=control+of+pest+%E2%98%8E+1%28844%299484793+Virginia+service+phone+number
control of pest San Diego service https://www.webdesignerdepot.com/?s=control+of+pest+%E2%98%8E+1%28844%299484793+San Diego+service+phone+number
control of pest Seattle service https://ranczobobrowniki.pl/?s=control+of+pest+%E2%98%8E+1%28844%299484793+Seattle+service+phone+number
orbitz+flight+phone+number MT service https://www.nextbiometrics.com/?s=%E2%98%8E+1%28888%294972988+orbitz+flight+phone+number
latam+book+flight NY service https://proyectoidis.org/page/2/?s=%E2%98%8E+1%28888%294972988+latam+book+flight
delta+airline+phone+number+in+usa Georgia service https://totalmalaysia.my/category/welding-machines/?s=%E2%98%8E+1%28888%294972988+delta+airline+phone+number+in+usa
https://www.google.com/travel/flights?tfs=Delta+airlines%F0%9F%93%9E+1+855-670-2491+book+a+flight
https://www.google.com/travel/flights?tfs=Delta+airlines%F0%9F%93%9E+1+855-670-2491+book+a+flight
https://www.google.com/travel/flights?tfs=Delta+airlines%F0%9F%93%9E+1+855-670-2491+book+a+flight
https://www.google.com/travel/flights?tfs=Delta+airlines%F0%9F%93%9E+1+855-670-2491+book+a+flight
Delta Air lines MA booking flight service https://search.yahoo.com/tablet/s?p=Delta+airlines+1+855-670-2491+book+a+flight&ei=UTF-8&age=1m&fr2=time&btf=m
Delta Air lines MS booking flight service https://search.yahoo.com/tablet/s?p=Delta+airlines+1+855-670-2491+book+a+flight&ei=UTF-8&age=1m&fr2=time&btf=m
Delta Air lines MS booking flight service https://search.yahoo.com/tablet/s?p=Delta+airlines+1+855-670-2491+book+a+flight&ei=UTF-8&age=1m&fr2=time&btf=m
Delta Air lines CT booking flight service https://search.yahoo.com/tablet/s?p=Delta+airlines+1+855-670-2491+book+a+flight&ei=UTF-8&age=1m&fr2=time&btf=m
Delta Air lines WV booking flight service https://search.yahoo.com/tablet/s?p=Delta+airlines+1+855-670-2491+book+a+flight&ei=UTF-8&age=1m&fr2=time&btf=m
Delta Air lines Michigan booking flight service https://search.yahoo.com/tablet/s?p=Delta+airlines+1+855-670-2491+book+a+flight&ei=UTF-8&age=1m&fr2=time&btf=m
Delta Air lines District+of Columbia booking flight service https://search.yahoo.com/tablet/s?p=Delta+airlines+1+855-670-2491+book+a+flight&ei=UTF-8&age=1m&fr2=time&btf=m
Delta Air lines Florida booking flight service https://search.yahoo.com/tablet/s?p=Delta+airlines+1+855-670-2491+book+a+flight&ei=UTF-8&age=1m&fr2=time&btf=m
Delta Air lines California booking flight service https://search.yahoo.com/tablet/s?p=Delta+airlines+1+855-670-2491+book+a+flight&ei=UTF-8&age=1m&fr2=time&btf=m
Веном 2 – смотреть онлайн в хорошем качестве https://bit.ly/venom2-2021
Веном 2 – смотреть онлайн в хорошем качестве https://bit.ly/venom2-2021
Веном 2 – смотреть онлайн в хорошем качестве https://bit.ly/venom2-2021
Веном 2 – смотреть онлайн в хорошем качестве https://bit.ly/venom2-2021
❤️ Beryl want to meet you! Click Here: https://clck.ru/ZCwW5 ❤️
Con el tiempo evolucionaron y hoy invertir en ether o bitcoin día
sirven para varios propósitos.
https://amd1080.com/totosite/
Nice post. I learn something totally new and challenging on blogs I stumbleupon everyday. It will always be interesting to read articles from other writers and use a little something from other sites.
https://main7.net/baca/
Spot on with this write-up, I truly believe that this website needs much more attention. I’ll probably be back again to read through more, thanks for the advice!