Multiple custom post type templates

Posted in: Newspaper
Post count: 63

I need to be able to display multiple post templates for custom post types. I haven’t found a solution for this. The documentation only specifies one singe post template for a custom post type:

Custom Post Type Support

I need all the templates from the “standard” post template display to show. How do I show every option and template for a custom post type? I need all the standard post settings options (templates, review option etc.) for a custom post type.

Post count: 22421

Hi,
Unfortunately there is no option for this. The post templates were only created for posts, not custom post types. The CPT support is still limited with our theme so post templates cannot be used with custom post types at the moment. Sorry.
Thank you!

Post count: 63

Well they can actually. Which your own docs state. They are just limited to a single template without code modifications. I’ve already modified the wp_booster framework to include custom post types (which you should do by default if you ask me).

I was hoping that there was an easy solution, but I’ll get to work on modifying the rest of the framework myself.

Another thing. You might want to rewrite the error handling of your td_api.api. I.e. line 322:

td_util::error(__FILE__, "td_api_base::mark_used_on_page : a component with the ID: $id is not set.");

Will display errors on page and not only to error log.

Post count: 22421

Hi,
Yes, sorry about that, the custom post template can be changed to another one besides the default by following the CPT guide and changing the style manually.
As for the error I will pass this information on to the dev team.
Thank you!

Post count: 63

Hi Bogdan.

You’re still not really understanding what I am trying to achieve. I want every template available to a custom post type. Not just one. Thats kinda useless not being able to switch templates.

Post count: 6535

Hi

You can modify the post panel generator to have all post templates available for custom post type by editing td_templates_settings.php like in this example: http://screencast.com/t/8aUB77jrHOQ8 Hoover this is not a grantee the they will also work. Our post templates were designed to work only with post post type and to have them working on custom post types you’ll need a different approach for them.
Note that this is a very complex task which require many customizations in theme’s files and also good coding skills are involved in order to complete it. We can’t offer customization services at the moment so if you still need guidance on this or you’re not aware of the steps you need to take in this regard please consider hiring a developer or a freelancer to do this for you.

Thanks for the message!

Post count: 63

Hi Andrei.

I’m almost there with the modifications. So far the block code is working 100 % with several custom post types. But I still cannot show custom post types on the category pages. Top posts are working as the are based on the block settings, but the article display is not showing. I’ve been trying to find there in the code the ‘post_type’=> ‘post’ is set for that but can’t seem to find it.

So far i’ve changed this:

td_data_source.php

$wp_query_args = array(
'ignore_sticky_posts' => 1,
'post_type' => array('post','custom1','custom2','custom3'),
'post_status' => 'publish'
);

This will enable mega menus to fetch data from custom post types.

Out commented the post tytd_wp_booster_functions.php

// if ($post->post_type != 'post') {
// return $wordpress_template_path;
// }

This will enable custom post types to use the default post templates.

td_templates_settings.php line 89:

'template' => get_template_directory() . '/includes/wp_booster/wp-admin/content-metaboxes/td_set_post_settings.php',
));

Forcing the templates to show for custom cpt in edit post in backend.

I’ve also added custom cpt to search etc.

But where do I set the post types for the article display on category pages etc?

Post count: 63

It’s probably the loop functions that needs to be modified. Just can’t seem to find where it fetches the data source.

Post count: 6535

Hi

Basically a custom post type it’s assigned to a custom taxonomy. That is a point of a custom post type, to have an additional way to sort thing in wordpress. The categories are default wp-taxonomies which are designed to display only wp’s default posts types. To change that you’ll need to modify the query for category pages and send your custom post types as a parameter. The query for category pages it’s made by loop.php file so you have to make some changes in that file in order to achieve your goal.
In td_data_source.php are made all queries for theme’s blocks. That file dos not generate content for pages like category page, archive page etc. It generate the query for each theme’s block.

Thanks!

Post count: 63

Hi Andrei.

I can’t seem to locate a single query in the loop.php file?

Are the content display generated using pagebuilder or?

  • This reply was modified 10 years by Phonetic.
Post count: 63

Ahh yeah have_posts()..

I’ll modify the query.

Post count: 63

Got it working. Almost..

Pagination is showing, but following pages are not working. Clicking them will generate a 404 error. Someting I’m missing?


$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$args = array( 
    'post_type'   => 'custom1',
    'post_status' => 'published',
    'posts_per_page' => '10',
    'paged' => $paged
);

$wp_query = new WP_Query( $args );
  • This reply was modified 10 years by Phonetic.
  • This reply was modified 10 years by Phonetic.
Post count: 51

@Phonetic

I just got my hands into CPT, but not sure where to begin. Can I have a link to your website, and maybe a post where CPT is enabled?

Thank you

Post count: 63

Hi Dhananjay.

The website I’m building / redesigning will launch May 1st. It’s under wraps until then 🙂

I realised that Newspaper theme really is not geared for CPT. In the end there is too many customisations needed and would probably break all sorts for theme updates in the future.

I had to options to accomplish my goal:

1. Use CPT to get the data-sorting i wanted.
2. Modify and add the needed sorting logic to the data backend.

I chose the latter. Today I rewrote the ajax functions and implemented the function (only get posts from main box / menu filter AND sub-filters (from drop-downs).

I’ve documented the changes here: Adding Ajax Logic

You might wanna take a look.

  • This reply was modified 10 years by Phonetic.
Post count: 51

That was generous of you to reply back. I would definitely have a look 🙂
BTW, good luck with your website.

Post count: 63

NP.

We’re all here to help out 🙂

Post count: 29

Hi Phonetic!

I’m with a similar issue. I couldn’t load the pagination. Only page 1 is showing, other pages returns 404 error. Did you manage to make it work?

Thanks!

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