Adding custom post type to theme
-
Hello!
First I want to thank you for the great, responsive, free theme. Been using it for a few months and love it!
I have encountered an issue recently though. I have started to use the plugin IssueM (a magazine format plugin) and these create a custom post type called “article” (from the looks of things, and from looking here https://ww.wp.xz.cn/support/topic/related-posts-not-showing-up-3)
Since these are not normal “posts”, they do not show up on the homepage, in the slider, in any list of recent posts… well they don’t show anywhere but the special made IssueM pages.
There is an option in IssueM to use Categories and Tags that posts use, but this does not have them show up.
There is also a spot on their page that says to add this to the theme’s function.php:
function add_articles_to_homepage( $query ) { if ( !is_admin() && is_home() && $query->is_main_query() ) { $query->set( 'post_type', array( 'post', 'article') ); } return $query; } add_action( 'pre_get_posts', 'add_articles_to_homepage' );But when I add this to the end of the functions.php, it just breaks the page.
I want to add the “article” post type to the loops that pull for content on the site and basically:
1) Have the “article” post type show up on the homepage slider and the catagory lists
2) Also have them show up in other areas that display recent posts
Thank you very much for any help with this! I’ve been poking around for a week, and everything that I have tried so far either didn’t work or broke the page lol
The topic ‘Adding custom post type to theme’ is closed to new replies.
