Support » Fixing WordPress » Custom Post Types Permalink Settings, Landing Page

  • So, I’m new to custom post types, so pardon if this comes across as confusing…

    I’m currently trying to set up a ‘landing page’ for a custom post type

    My friend wants to make a small site that lists all the albums he has recorded on….

    So the custom post type = Albums with a few fields such as title, year etc.
    I have the Permalinks Set as ‘/%category%/%postname%’
    so pages look something like this http://www.site.com/albums/album_name
    this works perfectly.

    the problem I am facing is if I go directly to the category (www.site.com/albums) WordPress returns NOT FOUND

    I’m not sure what to do here…

    Is this something I have to define with the custom post type?

    here is my code…

    [Code moderated as per the Forum Rules. Please use the pastebin]

Viewing 2 replies - 1 through 2 (of 2 total)
  • I think you need to add the custom post type to the post types for the query. Here is a function (slightly modified) from an article by Justin Tadlock that should work:

    <?php
    add_filter( 'pre_get_posts', 'my_get_posts' );
    
    function my_get_posts( $query ) {
       $my_custom_type = 'albums';
       if ( is_category() && false == $query->query_vars['suppress_filters'] )
          $query->set( 'post_type', array( 'post', 'page', 'album', 'movie', 'quote', 'attachment', $my_custom_type ) );
    
       return $query;
    }
    ?>

    Hi,

    As far as I know, you’ll need to create an “album” page, so http://www.site.com/albums works, and create a page template for it, where your posts under that custom type are shown.

    See http://wordpress.org/support/topic/custom-post-type-landing-page for some sample code.

    Hope it helps!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Types Permalink Settings, Landing Page’ is closed to new replies.