add pagination to custom category posts

You can try below code for display page with pagination. I set 6 to posts_per_page which restrict to display 6 post per page at a time. <?php //build $args for fetch records… $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $args = array( ‘posts_per_page’ => 6,//display post per page ‘paged’ … Read more

Using Image Sizes for Custom Post Types outside the Loop

You are doing wrong on this part the_post_thumbnail($page->ID, “my-non-working-size”); For the_post_thumbnail() you don’t need to pass post ID, you just have to pass size and attr. More Info – the_post_thumbnail() So try like this the_post_thumbnail(“my-non-working-size”); without passing post ID. Your markup messed up so I’m not sure your actual markup structure. Here is working example … Read more

Showing all posts and custom post types by using one category

It’s showing blank because there are no posts in it. The default category taxonomy is only connected with the default post type. To enable it to use it with a custom post type, add the following line to the register_post_type configuration ‘taxonomies’ => array( ‘category’ ), For more info : https://codex.wordpress.org/Function_Reference/register_post_type#taxonomies

Better approach for a WordPress Inventory

In general, categories are tied to posts only (not custom types). This is built-in taxonomy. Though there is another experience. My approach is to create custom post types and custom taxonomies. That’s up to you how to organize the catalog. CPT for company and taxonomy for product family, or otherwise: /makita/drills/product_1 /makita/drills/product_2 /bosch/drills/product_1 /bosch/drills/product_1 or … Read more

WordPress custom permalink and archive link for custom post type

You need to either go into Settings -> Permalinks and click Save Or if you’re doing this programmatically you need to use flush_rewrite_rules(), but make sure this is only used when you activate/deactivate the plugin, DON’T set this in code that runs (like in init, or on every page load): https://developer.wordpress.org/reference/functions/flush_rewrite_rules/ register_deactivation_hook( __FILE__, ‘flush_rewrite_rules’ ); … Read more

Missing Post from Custom Post Type

What you’re observing is normal behavior. Registering a post type does not add any data to the database, but adding a new post once the post type has been registered does add data to the DB. Removing the post type registration code will not remove data. Head over to Settings > Permalinks and click Save … Read more

Shortcode to return single custom post based on post taxonomy

From your supplied info, it’s not all very clear to me. But as far as I’ve understood your problem, here’s my approach. Assuming we have the following shortcode that the user has put inside a normal post’s content and that this shortcode will pull information from your custom post type case_studies: [casestudy study_type=”mountain”] So firstly, … Read more