I’m using html5-blank for my theme.

all queries work fine when pulling from standard wordpress post type… it breaks when trying to pull from ‘html5-blank’ post type.

Here’s the query:

<?php $my_query = new WP_Query('category_name=spotlight&showposts=2');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
    <!-- pull thumbnail image -->
    <article class="article_wrap">
        <div class="widget_thumb">
            <a href="<?php echo get_permalink(); ?>">
                <?php echo get_the_post_thumbnail(); ?>
        </div>
        <h1 class="widget_title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
        <p class="widget_spot_description"><?php the_excerpt(); ?></p>
    </article>
        <?php endwhile; ?>

here’s functions.php:

function create_post_type_html5()
{
register_taxonomy_for_object_type('category', 'html5-blank'); // Register Taxonomies for Category
register_taxonomy_for_object_type('post_tag', 'html5-blank');
register_post_type('html5-blank', // Register Custom Post Type
    array(
    'labels' => array(
        'name' => __('HTML5 Blank Custom Post', 'html5blank'), // Rename these to suit
        'singular_name' => __('HTML5 Blank Custom Post', 'html5blank'),
        'add_new' => __('Add New', 'html5blank'),
        'add_new_item' => __('Add New HTML5 Blank Custom Post', 'html5blank'),
        'edit' => __('Edit', 'html5blank'),
        'edit_item' => __('Edit HTML5 Blank Custom Post', 'html5blank'),
        'new_item' => __('New HTML5 Blank Custom Post', 'html5blank'),
        'view' => __('View HTML5 Blank Custom Post', 'html5blank'),
        'view_item' => __('View HTML5 Blank Custom Post', 'html5blank'),
        'search_items' => __('Search HTML5 Blank Custom Post', 'html5blank'),
        'not_found' => __('No HTML5 Blank Custom Posts found', 'html5blank'),
        'not_found_in_trash' => __('No HTML5 Blank Custom Posts found in Trash', 'html5blank')
    ),
    'public' => true,
    'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages
    'has_archive' => true,
    'supports' => array(
        'title',
        'editor',
        'excerpt',
        'thumbnail'
    ), 
    'can_export' => true, // Allows export in Tools > Export
    'taxonomies' => array(
        'post_tag',
        'category'
    ) // Add Category and Post Tags support
));
}

I’m checking the category box in the custom post type but the query does not populate the post. It only shows the posts from the standard post type.

Noooooooo!

Read more here: wp query not working with custom post type > category


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , , ,

Wordpress related questions and answers: