WordPress.org

Ready to get started?Download WordPress

Forums

Displaying Custom Post Types (3 posts)

  1. criticalxnature
    Member
    Posted 1 year ago #

    Further to this post

    I think I'm missing something simple here but being new to WP, I seem to be getting lost easily...

    I have installed a plugin for creating custom post types, and on the admin end its working wonderfully. However, the issues appear at the front end.

    Say I have a new Post Type called 'Movies' with a post that I have put in the parent category 'Film' and subcat 'Drama'. It is all displaying correctly in admin.

    Issue 1: The movies are displaying at /wp/movies but are not found via category view at /wp/category/film.
    Issue 2: The post format is being displayed as default via content.php while content-movies.php is being completely ignored.

    I'm using a child theme of Twenty Twelve.

    Is it just that I need to add something to the theme/(child) functions.php? If so please be specific as to what and where.

  2. criticalxnature
    Member
    Posted 1 year ago #

    Issue 1 fixed!

    Placed the following in functions.php (works with menus) - from here:

    add_filter('pre_get_posts', 'query_post_type');
    function query_post_type($query) {
      if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
        $post_type = get_query_var('post_type');
    	if($post_type)
    	    $post_type = $post_type;
    	else
    	    $post_type = array('post','fanvideo','nav_menu_item');
        $query->set('post_type',$post_type);
    	return $query;
        }
    }

    Still puzzled over the display issue though...

  3. criticalxnature
    Member
    Posted 1 year ago #

    Basically is there any way to say (in category view/category.php):

    If post type = 'custom' then display template_path ('content', 'custom') else display default

    where template_path ('content', 'custom') would be content-custom.php

Topic Closed

This topic has been closed to new replies.

About this Topic