Permalink problems with custom post type and custom taxonomy

There was a problem with archive page and pagination in the original answer. Therefore, instead of changing the “rewrite” => [‘slug’ => ‘our-training/%training-category%’] in register_post_type() as I suggested earlier, add the following rewrite rules and change the links created for CPT. The rules will handle such addresses: display single training post with pagination support /our-training/training-category-1/training-name/ … Read more

Combine multiple CPT names to create valid permalinks

Sally CJ commented an important detail that helped me reach what I needed. Apart from that I struggled with what seemed to be regex error – one of my rules was overriding another because there was no $ character in regex to end the string. Working solution for custom rewrites: function dd_custom_rewrite_rules() { add_rewrite_tag(‘%company%’, ‘([a-z0-9-]+)’, … Read more

WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”

SOLUTION: With some playing around I realized I am definitely an idiot and WAY over-thought things. While I had previously read and tried some of the things in this similar post, I ended up substituting their code for mine and found it actually worked for my use case. In trying to understand why that was, … Read more

Having Issue on Ordering CPT by Custom Field In Custom WP Query

Your query args are not quite correct. When you want to order by a custom field, you need to specify a meta_key argument, and set your orderby to the kind of ordering you need. For example: $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘topic’, ‘field’ => ‘slug’, ‘terms’ => ‘movie’, ), ), ‘post_type’ … Read more

Custom shortcode works in Elementor editor but not on frontend

The problem is with the require_once, you are passing a relative path and that path doesn’t exist. Assuming the test.php file you want to require is in this path wp-content/themes/your-theme/views/test.php You can use the following require_once locate_template(‘views/test.php’); Consider using include instead of require_one, if this shortcode is not 100% necessary for your site to function, … Read more

set_query_params using custom params defined in functions file?

it just seems to be ignoring only the custom parameters I have defined in my functions file There are two issues in your code: WP_REST_Request::set_query_params() actually accepts just one parameter, which is an array of arguments, so your code should look like so: $request->set_query_params([ // pass a single array containing one or more arguments ‘per_page’ … Read more

How to integrate single and archive templates for custom post type in any WordPress theme

Is there a way to use for example single.php base structure overriding only the inner content? The main content of pages and posts is output using the the_content() function. This can be filtered and changed by plugins using the the_content filter. However this only outputs the content entered into body of the editor. It does … Read more