Articles of custom post types

How do I redirect all 404 errors of a specific post type to another URL?

I have a custom post type containing job listings, that is highly volatile. Jobs are frequently added and removed. Our analytics show that a lot of crawling errors are for detail pages of jobs that have been unlisted. The solution I came up with is to redirect all visits for non-existant URLs within the CPT’s […]

Archive page with multiple taxonomies rewrite

Ok, I’ve read over pretty much every answer to this question, but my situation must be unique somehow. What I’m attempting to do is straightforward in theory. CPT: resource Tax1: resource_type Tax2: industry When I register the CPT I have set the following: ‘rewrite’ => array( ‘slug’ => ‘resources/%resource_type%’, ‘with_front’ => false ), ‘with_front’ => […]

Versioned Custom Post Type (Not the same as revisions)

I want to create a special custom post type with a url format as follows site_root/post_slug[/post_name[/version_number]] site_root/post_slug: points to a list of posts i.e. post_name site_root/post_slug/post_name: points to the latest version (not permalink) site_root/post_slug/post_name/version_number: points to the specific version number In the admin Menu it would have post_name1 – Version 1 – Version 2 – […]

Rewrite custom post type url – Multiple post types

I know this question as been asked several times, but this question is not exactly the same. I have two functions to change the url of single custom post type, but couldn’t figure out how make this work for multiple CPTs. What I have tried: Simply copy the functions and rename them – won’t work, […]

Custom query at top of archive search page, arguments are overridden

I am using a customised archive template for a custom post type. At the top of the page, I’d like to show a specific post, found using a new wp_query() call. $args = [ ‘posts_per_page’ => 1, ‘post_type’ => ‘document’, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ]; $query = new WP_Query( $args ); if ( […]

WP_Query custom post type query not showing the exact post type

I am new in WordPress. I have registered wp_query function through ‘custom post type UI’ and ‘Advanced custom fields’ plugin. And this is the code in the portfolio page. <div id=”tf-content”> <div class=”container”><!– Container –> <div class=”row”><!– Row –> <?php $args = array( ‘post-type’ => ‘portfolio’ ); $query = new WP_Query( $args ); ?> <?php […]

Order Custom Post Type by Custom Field Value

I’m having trouble getting my custom ordering to work. I’m trying to order a custom post type by a custom field called feature_order which is a numeric field (created with Advanced Custom Fields plugin). Here is the code: $args = array( ‘post_type’ => ‘attorneys’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘feature_order’, ‘orderby’ => ‘meta_value_num’, ‘order’ => […]

Custom Permalinks with CPT and Hierarchical Taxonomies

CPT: product Taxonomy: prod_cat Current URLs Child Term domain.com/product-category/pulp/ Hierarchical Child Term domain.com/product-category/pulp-iqf/pulp/apple/ Single CPT Post domain.com/product/apple-juice-concentrate/ Desired URLs Child Term domain.com/pulp/ Hierarchical Child Term domain.com/pulp-iqf/pulp/apple/ Single CPT Post domain.com/pulp-iqf/pulp/apple/apple-juice-concentrate/ I’ve gone through the depths of answers on WPSE and believe me I’ve tried various combinations but I’m unable to set it this way. The […]

Custom taxonomy rewrite with query var returns %2F in URL

I’m facing a (hopefully) small issue right now I can’t seem to solve. First of all my page is set up in a way that all my projects (custom post type) are displayed on one big page with a query var filter containing my custom taxonomies. So the URL with all the projects is example.com/projects/ […]

Category with post type pagination returns 404

I have a category template with a custom post type that looks like: <?php $category = get_query_var(‘cat’); $paged = (get_query_var(“page”)) ? get_query_var(“paged”) : 1; $args = array( ‘cat’ => $category, ‘paged’ => $paged, ‘post_mime_type’ => ‘image’, ‘posts_per_page’ => 9, ‘post_status’ => ‘inherit’, ‘post_type’ => ‘attachment’ ); query_posts($args); $count = $wp_query->found_posts; ?> <?php if ( have_posts() […]