Rewrite custom post type url’s adding meta box values

It sounds like you’re very close here and your only remaining issue is that your permalinks for genres and movies collide. ‘movies’ CPT permalink /genres/%custom field meta box value%/%movie%/ ‘genres’ CPT permalink /genres/%genre%/ The issue here is using the add_permastruct. When it creates the rules for movies, they look something like this: genres/([^/]+)/([^/]+)(/[0-9]+)?/?$ => index.php?genre=$matches[1]&movies=$matches[2]&page=$matches[3] … Read more

how to create my own edit.php admin page code or template for my custom post type

When you register the CPT set show_ui to false. For example: $args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’ => true, ‘show_ui’ => false, // <– here ‘show_in_menu’ => true, ‘query_var’ => true, ‘rewrite’ => array( ‘slug’ => ‘book’ ), ‘capability_type’ => ‘post’, ‘has_archive’ => true, ‘hierarchical’ => false, ‘menu_position’ => null, ‘supports’ … Read more

Custom Post Type / Taxonomy Slug / Post Title with post type archive

Replace your code with the following. I have made some changes to the post_type_link filter’s callback function. function my_custom_post_work() { $labels = array( ‘name’ => _x( ‘Work’, ‘post type general name’ ), ‘singular_name’ => _x( ‘Work’, ‘post type singular name’ ), ‘add_new’ => _x( ‘Add New’, ‘book’ ), ‘add_new_item’ => __( ‘Add New Work’ ), … Read more

Create Post tabs in single-{content-type}.php with Custom Field values

You can use rewrite endpoints to achieve this. First, register your endpoints: function wpa_movie_endpoints() { add_rewrite_endpoint( ‘synopsis’, EP_PERMALINK ); add_rewrite_endpoint( ‘screens’, EP_PERMALINK ); add_rewrite_endpoint( ‘trailer’, EP_PERMALINK ); } add_action( ‘init’, ‘wpa_movie_endpoints’ ); So now in addition to http://domain.com/post-name/ (or whatever your particular permalink structure is), you’ll have: http://domain.com/post-name/synopsis/ http://domain.com/post-name/screens/ http://domain.com/post-name/trailer/ You can then check for … Read more

Permalinks in Custom Post types

Take a look at my answer to the following question. You can modify my parse_request() to get what you need: “Remove taxonomy slug from a custom hierarchical taxonomy permalink”. And you can read the following to see why what you want can cause issues in WordPress and requires a complex solution: “Category in Permalinks Considered … Read more

How to force Authentication on REST API for Password protected page using custom table and fetch() without Plugin

After studying carefully 🤓 the WordPress REST API Handbook concerning Home / REST API Handbook / Extending the REST API / Routes and Endpoints Home / REST API Handbook / Extending the REST API / Adding Custom Endpoints I realized I made a couple of mistakes. Therefore, I wanted to share with you my findings. … Read more

Custom Permalinks for Custom Post Types and Taxonomies

Here’s the method I use to get what you’re trying to achieve. First, register your location taxonomy: register_taxonomy( ‘location’, array( ‘business’ ), array( ‘rewrite’ => array( ‘slug’ => ‘business-location’ ) ) ); Next, register the business post type. The important bit to note here is the inclusion of the %location% rewrite tag in the slug. … Read more