• Hi,

    I have setup Custom Post Types and almost everything work fine, but there is one issue.

    Post is related to existing WP Category, when I click on the Category on the Post’s page then 404 error showed up.

    Why this Custom Post is not in the Category Archive Page?

    Settings of “Types” Plugin are checked for the option “has archive”.

    http://wordpress.org/extend/plugins/types/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Dear User45,

    It is a WordPress behavior. Please add following code in your functions.php of theme to add custom post types to tag & category archives.

    <br />
    if ( ! function_exists( 'include_custom_post_types' ) ) {<br />
    function include_custom_post_types( $query ) {<br />
    if ( ! is_preview() && ! is_admin() && ! is_singular() ) {<br />
    $args = array(<br />
    'public' => true ,<br />
    '_builtin' => false<br />
    );<br />
    $output = 'names';<br />
    $operator = 'and';<br />
    $post_types = get_post_types( $args, $output, $operator );<br />
    $post_types = array_merge( $post_types, array( 'post' ) );<br />
    if ($query->is_feed) {<br />
    } else {<br />
    $my_post_type = get_query_var( 'post_type' );<br />
    if ( empty( $my_post_type ) )<br />
    $query->set( 'post_type', $post_types );<br />
    }<br />
    }<br />
    } }<br />
    add_action( 'pre_get_posts', 'include_custom_post_types' );<br />

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    I am having the same problem! Does it matter where in my functions.php file I put the above code?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘No link to Category’ is closed to new replies.