0

I keep getting the "Oops, post not found!" error message when I try and view all posts from a specific category. I think the issue is stemming from the fact that I'm actually using Custom Pages with Categories added to them.

I've searched around, but I can't find anyone in my situation with this specific problem. I've looked inside the archive.php and I can't see anything where I could tell WP to look for specific Custom Pages. I don't know what else to try.

My Custom Pages are defined like this (note the Categories):

// let's create the function for the wigwam post type
function wigwam_post_example() { 
    // creating (registering) the wigwam type 
    register_post_type( 'wigwam', /* (http://codex.wordpress.org/Function_Reference/register_post_type) */
        // let's now add all the options for this post type
        array( 'labels' => array(
            'name' => __( 'The Wigwam', 'bonestheme' ), /* This is the Title of the Group */
            'singular_name' => __( 'Wigwam', 'bonestheme' ), /* This is the individual type */
            'all_items' => __( 'All Wigwams', 'bonestheme' ), /* the all items menu item */
            'add_new' => __( 'Add New', 'bonestheme' ), /* The add new menu item */
            'add_new_item' => __( 'Add New Wigwam', 'bonestheme' ), /* Add New Display Title */
            'edit' => __( 'Edit', 'bonestheme' ), /* Edit Dialog */
            'edit_item' => __( 'Edit Wigwams', 'bonestheme' ), /* Edit Display Title */
            'new_item' => __( 'New Wigwam', 'bonestheme' ), /* New Display Title */
            'view_item' => __( 'View Wigwam', 'bonestheme' ), /* View Display Title */
            'search_items' => __( 'Search Wigwams', 'bonestheme' ), /* Search wigwam Type Title */ 
            'not_found' =>  __( 'Nothing found in the Database.', 'bonestheme' ), /* This displays if there are no entries yet */ 
            'not_found_in_trash' => __( 'Nothing found in Trash', 'bonestheme' ), /* This displays if there is nothing in the trash */
            'parent_item_colon' => ''
            ), /* end of arrays */
            'description' => __( '', 'bonestheme' ), /* wigwam Type Description */
            'public' => true,
            'publicly_queryable' => true,
            'exclude_from_search' => false,
            'show_ui' => true,
            'query_var' => true,
            'menu_position' => 8, /* this is what order you want it to appear in on the left hand side menu */ 
            'menu_icon' => get_stylesheet_directory_uri() . '/library/images/work-post-icon.png', /* the icon for the wigwam post type menu */
            'rewrite'   => array( 'slug' => 'wigwam', 'with_front' => false ), /* you can specify its url slug */
            'has_archive' => 'wigwam', /* you can rename the slug here */
            'capability_type' => 'page',
            'taxonomies' => array('category'),
            'hierarchical' => true,
            /* the next one is important, it tells what's enabled in the post editor */
            'supports' => array( 'title', 'editor','excerpt', 'thumbnail','page-attributes', 'categories')
        ) /* end of options */
    ); /* end of register post type */
   } 

The URLs that are broken look like:

example.com/category/news/

There is one reference to query_posts in nav-menu.php -- but I don't know if that file is even used in this project (it's outside the theme in the main WP):

 elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches)) {
    if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) {
        query_posts(array(
            'posts_per_page' => 10,
            'post_type' => $matches[2],
            's' => $query,
        ));

UPDATE: Sorry my search was being slow. There's quite a few references to query_posts after all, not just the one above. None to do with the archive.php page, though?

How can I tell WordPress to look in my Custom Pages when searching in categories?

  • 3
    Can you explain to us more what your custom pages with categories is? Throw in examples of URLs for categories and URLs for the archives you're having issues with. Also are there any calls to query_posts in your code? Even if they seem irrelevant – Tom J Nowell Oct 28 '14 at 17:51
  • @TomJNowell I've attempted to update my post with the information you've asked for. – Django Reinhardt Oct 28 '14 at 18:04
  • 1
    It sounds like this is your problem. – Milo Oct 28 '14 at 18:19
  • You shouldn't be using query_posts, use WP_Query to grab posts, and if you need to modify the main query, use the pre_get_posts filter instead – Tom J Nowell Oct 28 '14 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.