Header-Templates for CPT and Custom taxonomies?

Posted in: Newspaper
Post count: 209

Hello,
is it somehow possible to add a header-template to a custom post type and custom taxonomies? Or to enable the full post settings for a CPT to give them another layout?

Post count: 35449

Hi,

Unfortunately since Newspaper v9.7 this is a bit tricky to achieve, if you have a prev version of the theme you can follow our guide for Custom Post Type Support -> https://forum.tagdiv.com/custom-post-type-support/

Thank you!

Post count: 8

Hello,
Has there been any progress on this question? Saying it is “a bit tricky to achieve” is not very helpful. I’ve searched the documentation and forums but have not found an answer.
I have the latest version of Newspaper installed with a child theme, use a CPT and need to be able to set custom archive and single template options with specific headers and footers. I have copied single-<CPT-Name>.php file into the child theme and gutted parts to display the CPT content. However, I’d like to be able to use standard TagDiv headers and footers rather than manually rewrite versions of all the header.php and footer.php files.
I don’t mind coding.
If there isn’t a GUI way to call specific headers and footers for a CPT, is there a code reference say, that in the child theme functions.php file if post_type = X then use header Y & footer Z?

Thank you for your help.
Best,
Don

Post count: 35449

Hi,

Unfortunately this is possible only pages and cloud template, for these you can use a cloud header and footer that can be edited using tagDiv Composer.

Indeed it can be possible to set in functions.php some code that can set the header per specify post_type.

Thank you!

Post count: 8

Hi Calin,

Thank you for the response.
Can you point me to any documentation of the code calls required in functions.php to call a specific tagdiv header and/or footer?

Or some sample code would be good. 🙂

Thanks,
Don

Post count: 35449

Hi,

Unfortunately I do not know any documentation for this type of code, usually this is custom made by developers.
-> https://developer.wordpress.org/reference/functions/is_page/

Thank you for your understanding!

Post count: 8

Hi Calin,
Thank you for responding. I am a developer and know about is_page. WordPress has quite good documentation.

I am asking about the function reference for TagDiv. What calls do your developers use to include Newspaper theme specific elements in a page? What calls do we use to specify which header to use? Is there a parameter to set before calling get_header or get_footer.

I have had a brief look at you code and it is difficult to follow since there are three or four areas with very similar templating. I suspect this was exacerbated by you moving templating functionality out of the theme to fit with Envato standards. There must be documentation, or at least someone in your team that knows where everything is. If you don’t have internal documentation, then it is going to be impossible to maintain your code.
If you won’t/can’t help, then so be it. But I’ve dealt with numerous premium plugin authors and all have at least made some effort.

Thank you for your understanding.
Don

Post count: 8

Hi Calin,
Could you please escalate this to the next level.

One of your developers will know the correct “TagDiv way” to set which header / footer is used.

Thank you,
Don

Post count: 8

###########################################################
This is posted in case anyone else has the same need to set specific headers for a CPT single page template.

In TagDiv the headers and footers displayed for a post are controlled by entries in the {db-prefix}-postmeta table. In particular, the meta data values for ‘tdc_header_template_id’ and ‘tdc_header_template_id’.

If you create or edit a cloud template take note of the post_id.

In this use case the post is being created programmatically.
The insert is:

$post_id = wp_insert_post(
array(
‘comment_status’ => ‘closed’,
‘ping_status’ => ‘closed’,
‘post_author’ => $author_id,
‘post_name’ => $slug,
‘post_title’ => $title,
‘post_content’ => $content,
‘post_excerpt’ => $excerpt,
‘post_status’ => ‘draft’,
‘post_type’ => ‘my_custom_post_type’,
‘meta_input’ => array(
‘tdc_header_template_id’ => 621, /* use your header template id */
‘tdc_footer_template_id’ => 622, /* use your footer template id */
)
)
);

You could use add_action( ‘wp_insert_post’, ‘my_new_cpt_post_function’) to run ‘update_post_meta’ and update the values.

Hope this helps someone.
Best,
Don

Post count: 35449

Hi ethos,

Yes, our theme has more headers and footers to fit with Envato standards -> https://tagdiv.com/updating-the-core-of-tagdiv-themes/
For example when tagDiv Composer is not activate the theme will use the files from this path -> wp-content/themes/Newspaper/header.php when the plugin is enable and you also use tagDiv Standard pack with a standard header it will be use this path -> wp-content/plugins/td-standard-pack/Newspaper/header.php and if you are using a cloud header it will be use the file from this path wp-content/plugins/td-composer/legacy/Newspaper/header.php
Indeed this is quite confuse, but this is the way that these files are used after after the update per envato requirements.
Also I’m not a developer, only a support member and a have limited code knowledge about the functions for the theme and how these are call and work, but if you want I can ask a developer for more information and I will get back to you.

Thank you for your understanding!

Post count: 209

Hello Don,
thank you very much for coming back to this issue. I’d like to add your solution to finally style my CPT. Where do I have to add your code? In functions.php? The code seems to modify the setting of a post. When exactly does this happen? It seems to modify the data when creating the draft. Am I right? Thanks for any further information.

Post count: 104

Have a similar desire, looking to programmatically change the post-setting template on the fly, but really posted so I can get notified when someone updates this post. I have woocommerce members plugin and it doesn’t display properly with the cloud templates, but the Single Template it does, so trying to setup a way to programmatically change it for non-members.

Post count: 8

Sorry guys,
I haven’t needed to look at this forum since the last post. 😉

In belated response:

If you want to set the meta values after a post is created in the normal manner you could use something like this in your theme functions.php file:

add_action( 'save_post', 'ethos_tdc_templates_callback', 20, 1 );

function ethos_tdc_templates_callback($post_id) {

$my_post_type = 'pacnews'; // SET THE POST TYPE YOU WANT TO PROCESS

$post_type = get_post_type($post_id);

if ($my_post_type == $post_type ) {

$tdc_header_template_id = 621; // USE YOUR TEMPLATE ID
$tdc_footer_template_id = 684; // USE YOUR TEMPLATE ID
update_post_meta( $post_id, 'tdc_header_template_id', $tdc_header_template_id );
update_post_meta( $post_id, 'tdc_footer_template_id', $tdc_footer_template_id );
}
}

Hope this helps someone.

Post count: 27744

Hello, @ethos

Thank you for your suggestion.

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