Url Rewriting a dynamic wordpress page with parameters
‘^offer/([^/]*)/([^/]*)/?’, Why do you have a question mark here at the end, that doesn’t do anything here. You also need to add_rewrite_tag otherwise it will never work.
‘^offer/([^/]*)/([^/]*)/?’, Why do you have a question mark here at the end, that doesn’t do anything here. You also need to add_rewrite_tag otherwise it will never work.
How to fix the Post Preview Button (CPT & map_meta_cap)
This happens when the image does not have a specific width/height. The image you try to load in your custom-post-type is too small (379x354px). So LinkedIn, Facebook or others will use the layout with the smaller image. Facebook says: Images that are at least 470×246 pixels will display as a rectangle with the title and … Read more
This is quite simple to implement. Get all taxonomies via get_terms() and get the related posts with a custom WP_Query and tax_query. // get all terms $terms = get_terms( ‘docs_category’, array( ‘hide_empty’ => true, ‘parent’ => 0, ) ); if( !empty( $terms ) && !is_wp_error( $terms ) ): foreach ( $terms as $term ): // … Read more
You should check the pre_get_posts() filter hook.
Custom taxonomy permalink without term, redirection to CPT slug
WordPress rewrite rule doesn’t work unless post category is explicitly called in regex
Use the parse_query hook to override the default main query: add_action( ‘parse_query’, function ( WP_Query $wp_query ) { /** * Only apply our custom ordering when: * – We’re not in the admin * – It’s an archive (i.e. not singular) * – It’s the main query (won’t affect custom WP_Query) */ if ( ! … Read more
You could create a generic REST API endpoint that just accepted a post ID. I’ve used the default WP_REST_Posts_Controller to handle some standard checks and format the response: add_action( ‘rest_api_init’, function () { register_rest_route( ‘wpse/406874’, ‘post_data/(?P<id>\d+)’, [ ‘methods’ => WP_REST_Server::READABLE, ‘permission_callback’ => ‘__return_true’, ‘callback’ => function ( WP_REST_Request $request ) { $id = (int) $request[‘id’]; … Read more
How to change CPT single post slug