Jump to content

Archived

This topic is now archived and is closed to further replies.

dario

Archives for CPTs and where to call them in DMS2?

Recommended Posts

dario

I've got 2 CPTs using the recommended Custom Post Type UI.

They seem to work well. I can post to them and display them individually or as a group.

 

The problem comes when I try to display them using the default WP category archive pages.

E.g., www.mysite.com/category/movies

That results in a Nothing Found in the content loop

 

However, www.mysite.com/movies, does show the archive just fine.

 

Both pages, /category/movies and /movies, are linked to the same template.

 

The plugin author (Michael Beckwith) suggests this:

My biggest and first hunch is that the urls you are ending up on don't have the CPTs in the list of post types that are being queried. You can use the pre_get_post hook to do that, if that's the case.

If that were the answer, I've no idea where to manage this via my DMS child theme.

 

Additionally, the movies category has sub-categories. These sub-categories were created by going to the menu for the Movies CPT and selecting 'Categories'. That takes me to this, add a new category page: /wp-admin/edit-tags.php?taxonomy=category&post_type=movies

Of course they also show up in /wp-admin/edit-tags.php?taxonomy=category

 

But, I'm wondering if the proper way to create sub-categories for CPTs is to create new CPTs for each sub-category instead? And in the 'Advanced Label Options', give the sub-category a parent (e.g., Movies)?

 

Another oddity is that the Categories widget shows correct post counts for all my posts, each in the proper category. Clicking on any of these however, results in a 'Nothing Found' because again the page goes to /category/movies/ instead of /movies.

 

So I'm a bit lost.

Share this post


Link to post
Share on other sites
dario

Solved.

Add the following to the child theme's functions file:

function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {

$post_types = get_post_types();

$query->set( 'post_type', $post_types );
return $query;
}
}
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );

Share this post


Link to post
Share on other sites
Danny

Thanks for informing us the issue has been resolved.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

  • Similar Content

    • Lisa Haran
      By Lisa Haran+
      Hi 
      I have a map here http://www.iloveoffset.com/maps/
      I want to add several pointer locations to the map, but when I do they do not appear.
      On this map there are 2 pointer locations and as you can there is only one visible.
      Earlier today I added 7 and could only see 4 so there is something odd going on.
      My theme is up to date
    • clj182
      By clj182+
      Hello,
      I've been having trouble unlocking the template section for past couple of weeks. When I try clicking nothing happens. 
      I've deleted my custom css and removed plugins. Im down to having only the following plugins:
      Akismet
      Contact Form 7
      DMS Professional Tools
      Pagelines Updater
      WooCommerce
      It was working fine before i have no idea what's going on with it.
    • flourishdesignstudio
      By flourishdesignstudio+
      My DMS 2 site http://www.heart-stone.com/ will not save any new custom css... I can still edit templates and publish those but any custom css that I enter never saves.
      All WP files, themes, and plugins are up to date. 
      Any thought about what might be causing this?
    • flourishdesignstudio
      By flourishdesignstudio+
      Is there a way to edit the custom CSS via FTP? I know I can edit the custom code in the Chrome editor but is there a file path I can use to find and edit the CSS directly from our FTP?
      Thanks in advance for the help!
    • nizami
      By nizami+
      Using navbar section with correctly configured WP menu to display main navigation at https://elenaangel.com. 
      All fine in desktop viewport. Menu displays twice in hamburger mode. How to fix this please? 

×