- This topic has 5 replies, 3 voices, and was last updated 3 years, 3 months ago by
David.
-
AuthorPosts
-
January 14, 2023 at 8:05 am #2495437
Utopia – Arquitectura e Engenharia Lda
Hi,
I created a custom post type.Now I want co customize the following:
– custom post type archive
– custom post type categories
– custom post type single postI noticed that when in the wordpress backend I select / customize / layout / blog / I can make changes on buttons, but things like columns just don’t work on custom post types.
So, my questions are:
1) Can we make blog settings affect custom post types? ( This would be great for customization.)
2) Do you have a good tutorial for customizing archives and categories pages display properties with elements?
3) Can we customize the sinle custom post type template and insert things like navigating only inside category? Can you point me to a good elements tutorial on this?January 14, 2023 at 12:03 pm #2495632Ying
StaffCustomer Support1) Can we make blog settings affect custom post types? ( This would be great for customization.)
No, as the theme doesn’t know about the CPT. you will need to use some filters to make the blog settings apply to cpt.
2) Do you have a good tutorial for customizing archives and categories pages display properties with elements?
If you have the GenerateBlocks plugin installed, you can create a block element, add a Query loop block in it, set it to
inherit the default loop, and set the location accordingly.In this way, you can control the layout and style of the CPT archives.
3) Can we customize the sinle custom post type template and insert things like navigating only inside category? Can you point me to a good elements tutorial on this?
Yes, you can use the
block element - content templateand assign it to CPT posts.
Yes, you can use theblock element - hookto insert the navigation and assign it to category archives.You can see all documents about block elements:
https://docs.generatepress.com/?s=block+elementJanuary 21, 2023 at 8:40 am #2504104Utopia – Arquitectura e Engenharia Lda
Hi Ying,
Great support, thanks.
I just couldn’t find a way to navigate inside the category. It navigates on all categories… Sorry for beeing so noob.If i add a block element hook, I need code to place there.
a) Can you point me to the code I should insert to restrict the navigation to the most specific category?
Also, I noticed that we could add a block element and a post navigation too. It has templates but I couldn’t manage to restrict it to same category too.
b) What are the advantages of each aproach: The block element vs hook element?January 22, 2023 at 4:33 am #2504627David
StaffCustomer SupportHi there,
a. Post Navigation
Built in Theme Navigation
The theme outputs a post nav for you. And it offers this filter hookgenerate_category_post_navigation.
It it is used to limit next/prev post links to posts within the same term.
You can make it so by adding this PHP Snippet to your functions.php:add_filter('generate_category_post_navigation','__return_true');Hook Element
This would require custom PHP.
to create the next and previous links you can use core functions eg.https://developer.wordpress.org/reference/functions/get_next_post/
https://developer.wordpress.org/reference/functions/get_previous_post/And those functions have params to set various options.
eg.
get_previous_post(true)would return the previous post that is in the same term.Block Element Post Navigation
If you add a Dynamic Link and set its Links Source to Next Post or Previous Post, you can select the Option:In same term. See here for an example using on of the prebuilt layouts:https://www.screencast.com/t/PUOdyPblWCXe
b. Hook Element vs Block Element
The Block element can do more than the hook element.
With it you can create Loop Templates and Content Templates whereas you cannot do this with Hook Element.
Block Element can also use ALL the hooks that are available in Hook Element.Hook Element is best for when wanting to add smaller amounts of code. Some examples:
Scripts such as Google Analytics or Meta tags such asnoindexthat are added to thewp_headorwp_footer
Adding additional content in the theme where there is no block element option to do so.Overall the main decision will come down to if you preper building advanced layouts without ( or with less ) code.
January 22, 2023 at 2:14 pm #2505170Utopia – Arquitectura e Engenharia Lda
Hi David
As always, your help is great!
The explanation was perfect, thank you!
🙂January 23, 2023 at 3:35 am #2505609David
StaffCustomer SupportGlad to be of help!
-
AuthorPosts
- You must be logged in to reply to this topic.