- This topic has 15 replies, 2 voices, and was last updated 5 years, 11 months ago by
Tom.
-
AuthorPosts
-
May 25, 2016 at 5:49 am #196633
Georg
Hi Tom,
i’m going crazy to create a custom post type looking like normal single post.
I’ve created a custom post type, copied your single post template (single.php) and content-single.php. After naming the copy as my post type e.g. single-test.php it is used as wanted.But: After the the title there’s no author and date shown and at the end there are no Tags and Categories.
Do you have an idea?
Thanks in advance!
May 25, 2016 at 11:22 am #196704Tom
Lead DeveloperLead DeveloperCurrently there’s a check inside the actual functions that show those elements looking for the “post” post type.
In the next version (GP 1.3.30), I’ve removed that and added those elements into hookable functions so we can add them to different post types.
If you want to post in this topic once 1.3.30 is released (this week), I can give you the code for it π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 25, 2016 at 9:30 pm #196804Georg
Hi Tom,
thanks for the answer.
If the solution is released this week, i can wait. Otherwise i would appreciate, if you give me the code!
Thank you! πBest
Georg
May 26, 2016 at 12:30 am #196858Tom
Lead DeveloperLead DeveloperIf I don’t get it released tomorrow or Friday I’ll circle back and give you a solution π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 27, 2016 at 4:56 am #197204Georg
Cool! Thank you! π
May 29, 2016 at 1:29 am #197576Georg
Hi Tom,
i’ve installed the newest version of GeneratePress now.
Testing it with custom post types, but it seems nothing changed. πWhat is my fault?
I use the Plugin “Custom Post Type UI” from Webdev Studios to create custom post types, then copy over your single post template unchanged with e.g. single-test.php in my child theme folder, but even the title meta (date and author) or other post meta like tags and categories wont be shown.
Do you have an idea?
Thanks in advance!
Best
Georg
May 29, 2016 at 7:54 am #197642Georg
Hi,
with this code in my child them folder’s function.php now i’ve got the solution for me:
//Gets post cat slug and looks for single-[cat slug].php and applies it add_filter('single_template', create_function( '$the_template', 'foreach( (array) get_the_category() as $cat ) { if ( file_exists(STYLESHEETPATH . "/single-{$cat->slug}.php") ) return STYLESHEETPATH . "/single-{$cat->slug}.php"; } return $the_template;' ) );
Thanks
Georg
-
This reply was modified 5 years, 11 months ago by
Georg.
May 29, 2016 at 10:28 am #197673Tom
Lead DeveloperLead DeveloperWith the new version we’ll need to add some custom code still so it works for your specific custom post type.
Let me know if you’d like that solution or if you’re happy with the one you found π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 29, 2016 at 10:32 am #197677Georg
Hi Tom,
my last posted solution is even not as good as i thought.
Perhaps you give me yours so i can give it a try! πThanks in advance!
Best
Georg
May 29, 2016 at 12:30 pm #197725Tom
Lead DeveloperLead DeveloperYou can do something like this:
if ( ! function_exists( 'generate_post_meta' ) ) : /** * Build the post meta * * @since 1.3.29 */ add_action( 'generate_after_entry_title', 'generate_post_meta' ); function generate_post_meta() { if ( 'post' == get_post_type() || 'your-post-type' == get_post_type() ) : ?> <div class="entry-meta"> <?php generate_posted_on(); ?> </div><!-- .entry-meta --> <?php endif; } endif; if ( ! function_exists( 'generate_footer_meta' ) ) : /** * Build the footer post meta * * @since 1.3.30 */ add_action( 'generate_after_entry_content', 'generate_footer_meta' ); function generate_footer_meta() { if ( 'post' == get_post_type() || 'your-post-type' == get_post_type() ) : ?> <footer class="entry-meta"> <?php generate_entry_meta(); ?> <?php if ( is_single() ) generate_content_nav( 'nav-below' ); ?> </footer><!-- .entry-meta --> <?php endif; } endif;
Just change the “your-post-type” to the name of your post type π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 30, 2016 at 4:23 am #197902Georg
Thank you, Tom!
I’ll try it out and give you a response soon.
Best
Georg
May 30, 2016 at 7:55 am #197964Georg
Ok Tom,
with the custom post type it is functionable now. Great! π
Only problem is now that i can’t edit the title of the category archive for this new post type. There is only “Archive” displayed, no matter what i type in.
I want to edit this in “edit category”.Do you have an idea?
Thanks in advance!
Best
Georg
June 2, 2016 at 7:12 am #198889Georg
Hi Tom,
do you have an idea, what i can do with the category archive title?
I can’t change it. There is only “archive” displayed. πBest regards
Georg
June 2, 2016 at 9:24 am #198916Tom
Lead DeveloperLead DeveloperHi Georg,
You would have to overwrite this function to include logic specific to your custom post type: https://gist.github.com/generatepress/fe5309693719d138dbcf84381eb9a6b3
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJune 3, 2016 at 2:22 am #199107Georg
Hi Tom,
tried out and giving up now. Because it’s too time intensive.
Maybe later i’ll try it again.Sorry, and thank you for helping!
Best
Georg
-
This reply was modified 5 years, 11 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.