Remind me: custom template files to clone

Posted in: Newsmag
Post count: 9544

Hi, folks
for one category I need to clone the ‘single template 2’ post template, to use for one specific news category where I need to put a custom element above all the story headlines.

Can you remind me which main template file I need to clone and set as a category ID number to load only for that category?

Thanks 🙂

Post count: 35449

Hi simchris,
If you need to edit the single_template_2.php this is under wp-content/plugins/td-composer/legacy/Newsmag/parts/single/single_template_2.php and it should be set in a child theme under Newsmag-child/parts/single/single_template_2.php and you should also include the file loop-single-2.php
I hope this will help you!
Thank you!

Post count: 9544

Hi, don’t need to edit the main file, need to clone it to assign to a specific category (e.g., say category 99), presuming the classic method of naming a template file by the category number, or adding a hook to do that in functions? E.g., adding a new template option for posts like ‘post-wide.php’ and then function to add that as new template drop down.

Probably I need to make single_template_99.php and loop-single-99.php then register those as a function.

Post count: 9544

okay, in rethinking this;
makes more sense for me to simply modify a template I’m not using, say single_template_7.

So, question:
if I have single_template_2 set as “site wide,” how would I set template 7 to a single post category, for posts not for category indexes?

Thanks. Hope that made sense. I’m a bit rusty on the mods for Newsmag.

Basically trying to have one content category use different template from rest of posts.

Post count: 35449

Hi simchris, so you’ll need to assign the single post template for a specific category, to do this you’ll need to make the above steps + a code in child theme in functions.php that is checking the current category from the post, the code is this one – https://pastebin.com/ze681p93
I hope this will help you!

Post count: 9544

Thanks 🙂 Will give this a try next week.
In oooold days we’d simply put a new single_99.php file in the root of the theme and that would overwrite loading theme for that category. Didn’t think that would work due to dependent file paths in the tagdiv templates.

So, code to repurpose template in correct folder should work. Woo!

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