How to get the URL of a sitemap that contains a certain post?

I achieved it using this simple query <?php $chunks=array_chunk( get_posts([ ‘fields’=>’ids’, ‘posts_per_page’=>-1, ‘post_type’=>[$post->post_type], ‘orderby’=>’ID’, ‘order’=>’ASC’ ]), wp_sitemaps_get_max_urls(‘post’) ); foreach($chunks as $key => $chunk) { if(!in_array($post->ID,$chunk)) continue; var_dump(get_sitemap_url(‘posts’,$post->post_type,$key + 1)); break; }

add role on WordPress in PHP on a second database

I managed to solve after several attempts using the following code: // Insert the role $role = array(‘gold_role’ => 1); $serialized_role = serialize($role); $DB_MEMBERSHIP->insert(‘wpvm_usermeta’, array(‘user_id’ => $user_id, ‘meta_key’ => ‘wpvm_capabilities’, ‘meta_value’ => $serialized_role)); It works very well and doesn’t slow down the shopping experience.

How to change search page url so that it still returns a page when there’s no search query specified?

Isn’t that just because you’ve put ! empty( $_GET[‘s’] ) in your IF statement? Is your search page accessible when you remove that part? EDIT: Or maybe change your function to something like this (untested): function wpb_change_search_url() { if ( is_search() ) { if ( isset( $_GET[‘s’] ) ) { wp_redirect( home_url( “/search/” ) . … Read more