- This topic has 13 replies, 4 voices, and was last updated 4 years, 1 month ago by Tom.
August 24, 2015 at 3:32 am #131643Pete
I’m using a plugin that allows me to assign a post to a template the same as I can assign a page to a template… (i wish this was in core).
Which file/s would I need to make a copy of (then edit) to make a new single post template, just like i would a page template?August 24, 2015 at 5:36 am #131656Jean
Hello Pete, you can copy the
single.phpand create a new single post template. You just need to rename the file to
Maybe this could help you: https://codex.wordpress.org/Post_Type_TemplatesAugust 24, 2015 at 8:42 am #131688TomLead DeveloperLead Developer
If the plugin makes it so you can set a page template, you should actually be able to name it whatever you like.
However, if it’s anything like the page template system, you’ll need to put this at the top:
/** * Template Name: My template name * */August 24, 2015 at 9:03 am #131703Pete
Hi guys, yep I know how to make a page template, I just need to know which file I need to copy. If I copy single.php then isn’t there other files linked/included in the single.php as well that need to be customized?August 24, 2015 at 9:05 am #131704TomLead DeveloperLead Developer
content-single.php is used within single.php.
If I were you, I would copy the content-single.php code and just put it into your custom single.php file in place of the get_template_part() code.August 24, 2015 at 9:08 am #131706Pete
Thanks that’s exactly what I was after. Cheers.August 24, 2015 at 9:19 am #131711TomLead DeveloperLead DeveloperJanuary 15, 2017 at 10:33 am #264315Jay
I’m trying like heck to understand the content-single.php because I would like my posts to be displayed in a certain fashion. I see that within content.php AND content-single.php there’s an action called (generate-before-content and generate-after-contact). I believe it is the before action I wish to find so I can alter what is generated. I can’t seem to find the source of that.
Please advise. Thank you.January 15, 2017 at 9:25 pm #264434TomLead DeveloperLead Developer
content.php displays your default loop – so the blog index, archives etc..
content-single.php displays the loop on your single post pages.
Those hooks appear in both files as they’re available in both loops.
You can use GP Hooks to add content into either of them.
Let me know if you need more info 🙂January 15, 2017 at 9:46 pm #264440Jay
In looking at GP Hooks, I don’t see the ‘generate-after-content’ hook which seems to be specific specific to the content-single file.
JayJanuary 15, 2017 at 11:51 pm #264446TomLead DeveloperLead Developer
It’s the “Generate After Content” hook in GP Hooks.
You would use PHP to make your code only apper on single posts:
<?php if ( is_single() ) : ?> Single post code here <?php endif; ?>
Be sure to check the “Execute PHP” checkbox.January 16, 2017 at 4:44 am #264505Jay
Thanks for that, Tom.January 16, 2017 at 5:28 am #264518Jay
One more follow up. Where can I permanently alter the featured image size?January 16, 2017 at 10:11 am #264617TomLead DeveloperLead Developer
For the index pages? In Customize > Blog > Post Images: https://docs.generatepress.com/article/adjusting-the-featured-images/
- You must be logged in to reply to this topic.