How to insert php into cloud composer header?

Posted in: Newspaper
Post count: 161

Hi,

My ad network requires me to insert scripts to the header, but the header scripts are different for each post template. We can’t load both scripts from the theme panel, because that will conflict with their ad servers. We use 2 tagdiv composer post templates and I noticed they both have some kind of template id in the body class, for example: tdb_template_17454. Is it possible to get the template id with the function get_page_template()? If this would work, the next question would be to what header.php file I should add the function? As mentioned we use the tagdiv composer so the header.php file in the theme folder doens’t work.

Thanks in advance!

Post count: 35449

Hi,
TagDiv Cloud library is a custom post type and the cloud templates made with tagDiv Composer are saved in database. Now normal you should be able to check if is a specific template. For example the files for cloud header are on this path -> wp-content/plugins/td-cloud-library/shortcodes/header and the header.php file is wp-content/plugins/td-composer/legacy/Newspaper/header.php (if you are not using the tagDiv Standard Pack).
Hope this will help you!
Thank you!

Post count: 161

Hi Calin,

Thanks! What kind of function could I use to determine what Cloud template is used for a certain post?

For example: We use 2 single post templates created with the Tagdiv Cloud Composer. Lets call them Template_cars and Template_all_other_posts. We have an ad network that has special ads for content about Cars and we want to show them only on the Cars posts. The ad network requires us to insert their header tags only on the Car posts in the <head>. On all other posts we need to insert other header tags in the <head>.

My idea was to add some php code to the header.php which achieves the following:

If post uses Template_cars –> insert these header tags, if post uses Template_all_other_posts –> insert other header tags.

Thanks!

Post count: 35449

Hi r1kay,
Yes, you can do that, or you can use cloud templates, those cloud templates can be set individual per each post, or per category -> https://i.imgur.com/cGJ6iyS.png in this way you can make with tagdiv Composer, the cloud template for posts and assign an individual header, in this way the ads that you set on it will apply only on that template.
To use a php is more hard. Here are some example -> http://justintadlock.com/archives/2011/07/20/conditional-checks-for-custom-post-types
Thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.