My custom meta box with textarea field not saved

sanitize_textarea_field() will be stripping out the GMaps <iframe> element. Sanitize it with wp_kses( $store_map, $allowed ) instead, where $allowed is an array in the following format: $allowed = array( ‘iframe’ => array( ‘width’ => array(), ‘height’ => array(), ‘style’ => array(), ‘loading’ => array(), ‘allowfullscreen’ => array(), ‘referrerpolicy’ => array(), ‘src’ => array() ) ); … Read more

How to get Custom Post Type (CPT) Archive Page’s Posts Featured Images Preload in header.php

You can access the current query on a custom post type archive page with global $wp_query;. By using the global variable which holds the current query, you don’t need to do an additional query. To keep your header.php file cleaner, you could use actions and callback functions placed in your functions.php file to put the … Read more

CPT with URL rewrite showing as 404

Step 1: Flush Rewrite Rules Manually: Visit Settings > Permalinks and click “Save Changes”. Programmatically (temporarily): function my_custom_flush_rewrite_rules() { flush_rewrite_rules(); } add_action( ‘init’, ‘my_custom_flush_rewrite_rules’ ); Step 2: Add Custom Rewrite Rules function custom_rewrite_rules() { add_rewrite_rule( ‘^products/([^/]+)/([^/]+)/?$’, ‘index.php?post_type=product&product_category=$matches[1]&name=$matches[2]’, ‘top’ ); } add_action( ‘init’, ‘custom_rewrite_rules’ ); Step 3: Modify post_type_link Filter function add_custom_rewrite_rule( $post_link, $post, $leavename ) … Read more