Customized post template
-
Hi,
I’ve created a new custom post type using Custom Post Type UI and I want to create a new post template for displaying this post type correctly.
Can I do it using OceanWP? If yes; May you please guide me to the starting point?
-
I created a child theme and I copied
partials/single/*for creating my own post format but it seems a wrong approach.PS. I read this page from the documentation Template Hierarchy it seems I can customize
single.phpbut I’m unable to see it in OceanWP.I’m lost π
-
This reply was modified 7 years, 3 months ago by
mbnoimi.
BTW, I’m unable to see OceanWP Settings in all the posts created by Custom Post Type UI
Hello,
Try to Add the below code the functions.php file of the child theme using FTP or cPanel. It will add OceanWP Settings metabox in your custom post types. Edit the post types in the code.
/** * Add the OceanWP Settings metabox in your CPT */ function oceanwp_metabox( $types ) { // Your custom post type $types[] = 'your-post-type'; // Return return $types; } add_filter( 'ocean_main_metaboxes_post_types', 'oceanwp_metabox', 20 );If you want to edit the file, then you need to write your own function to fetch a template using for that custom post type. For example, ‘Review’ is a custom post type.
Step 1 – Copy
partials/singlefolder under child theme and rename the ‘single’ folder to ‘review’.
Step 2. Now copy the singular.php file into your child theme and add the below code after line 52.elseif ( is_singular( 'review' ) { get_template_part( 'partials/review/layout' ); }Step 3. Now modified the file under review folder as per your need.
Hope it will help you.
Thanks a lot.
It works!
Happy to hear that!
Oops,
When I applied step 2 I get a white page!
// Library post types elseif ( is_singular( 'oceanwp_library' ) || is_singular( 'elementor_library' ) ) { get_template_part( 'partials/library/layout' ); } elseif ( is_singular( 'software' ) { get_template_part( 'partials/software/layout' ); } // All other post types. else { get_template_part( 'partials/single/layout', get_post_type() ); }If you want to edit the theme file and code for the custom post type, then use Step 2, otherwise no need to do it. OceanWP settings metabox will work for custom post type after adding the code I gave you earlier.
@apprimit I tried a lot but I failed to make it works fine.
May you please take a look into my child theme on Github
https://github.com/mbnoimi/blackocean-
This reply was modified 7 years, 3 months ago by
mbnoimi.
Hello,
I just tested it and it is working for me. Try to install the Health Check plugin and enable Troubleshooting mode. Reload your site, save the permalinks again to update the .htaccess file. Disable troubleshooting mode and check it works or not.
Also, try to add the code (step 2) after line 44 instead of 52.I did exactly as you said above but unfortunately it didn’t work π
Do you’ve some time to take a look into my website? If; yes I sent to you username & password to your blog’s email connect at wpyard.com.
I’m really sorry for disturbance.
Hello,
Please don’t share login details here or anywhere. It is against the forum guidelines and I don’t want to violate it. You should also follow the forum guidelines – Read guidelines here
I didn’t, I sent mine to your personal email hoping you’ll help me to figure out what’s going on.
BTW, This issue doesn’t occur in case I use “Twenty Nineteen” theme.
Sharing login or contact information is violate the terms of forum guidelines. We are restricted and must follow the guidelines. You can consult with a developer to look into your issue. I can only guide you and can’t do coding support for your website. Hope you understand.
Thanks
-
This reply was modified 7 years, 3 months ago by
The topic ‘Customized post template’ is closed to new replies.
