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; }

html sitemap via recursive function

The “memory exhausted” error in question happened because of this part in your function: ‘parent’ => $next_page -> post_parent, which should actually be ‘parent’ => $next_page -> ID (or I’d omit the unnecessary spaces, i.e. I’d use ‘parent’ => $next_page->ID). And the error can be illustrated like so: $cur_page = get_post( 123 ); // assume … Read more

WordPress sitemap with Custom Post Types

Here is a quick crack at it, which should work in two level depth: <h2 id=”posts”>My Post Type</h2> <ul> <?php $not_in = array(); //to avoid naming the same post over and over //get top level terms $Parent_terms = get_terms( ‘my_taxonomy’, array(‘orderby’ => ‘name’,’parent’ => 0)); foreach ($Parent_terms as $term) { echo “<li><h3>”.$term->name.”</h3>”; echo “<ul>”; //get … Read more

Unlimited Page Sitemap Link

You are most probably exceeding the maximum execution time when trying to retrieve 7000 posts/products, or specifically more than 2000 posts/products. To be quite honest with you, 7000 posts/products (or even just a list of posts/products) all packed in one single page is not only going to drive you crazy, but anyone visiting your site. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)