• Resolved Maximiadis

    (@danielm1984)


    Are the Posts published by the CPTUI and assigned to WordPress core categories and tags able to be queried on a custom built page like now_showing.php?

    The option does come up for me to assign the posts from CPTUI to a WordPress core category. However, when I try to call that category, using query_posts(), I only see the normal posts assigned to that category, not the ones made in by the CPTUI that I also assigned to that same category.

    I did try to do this https://docs.pluginize.com/article/17-post-types-in-category-tag-archives and then call the category, but it’s not working for some reason.

    The only time I see both posts from the CPTUI and the WordPress default posts is when I view them through the normal category.php page.

    • This topic was modified 7 years, 4 months ago by Maximiadis.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Without knowing what code is in your now_showing.php file, I can’t answer anything in regards to it.

    When using query_posts, are you specifying the post types to query against?

    The link referenced would be for the default category/tag archives, as mentioned in it. This would be seen when visiting say mysite.com/category/myterm/

    Assuming you set things up as-is with the sample code provided, did you make sure to use the proper slug value for the post type(s) ?

    The category.php file would be a template file used when viewing a category term archive, like the example one I mentioned above.

    Thread Starter Maximiadis

    (@danielm1984)

    Below is the code from my now_showing.php file.

    <?php
    query_posts('category_name=now-showing');  
    	if (have_posts()) :
    		while (have_posts()) :
    			the_post();
    ?>
    <section>
    	<div class="wrapper">
    		<article>
    			<?php 
    				if (has_post_thumbnail()) 
    					{ 
    					the_post_thumbnail('medium');
    					}
    			?>
    			<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    		</article>
    	</div>
    </section>
    <?php
    		endwhile;
    	endif;
    ?>
    

    In the past I have just queried the CPTUI through all the posts regardless of what category (if any) the posts where assigned to, using query_posts('post_type=>logo_design'); then I just went through the normal loop on a custom php file. The problem is, if I did use the post_type query then the post expiry plugin I’m using wouldn’t be very useful in changing and displaying the posts category from the CPTUI e.g. “Now Showing” to “Past Events” categories. And to add more complexity, each CPT has different custom fields for the client, to simply add their content, knowing it will be displayed in the front-end in a set way.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    To the best of my memory, and though it’s not considered a good practice to use query_posts(), it’s still going to default to only post. So any time you’re needing it to query your post type, you’re going to need to specify that as well in the passed arguments, along with any categories you’re wanting to filter down by.

    Regarding the posts expiration stuff, may be best to talk to that plugin’s support for how to best handle the situation, as we’re not going to have any settings related to that specifically.

    Depending on the overall frontend setup, you could have different template files for each post type, and the “single” template view could handle the custom field data appropriate to its given post type.

    For what it’s worth, CPTUI focuses only on the registration of the post types and taxonomies, we do not do anything automatically on the frontend. That’s all on the site owner to handle, in relation to their site’s needs.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Using CPT in WordPress core categories’ is closed to new replies.