Quantcast
Viewing all articles
Browse latest Browse all 3201

jerome281 on "[Plugin: WP Job Manager] Expired Job to be listed into the WordPress SEO XML sitemap"

I thought something like this would work, unfortunately he didn't :(

function add_sitemap_custom_items(){
  $postsForSitemap = get_posts(array(
    'numberposts' => -1,
    'orderby' => 'modified',
    'post_type'  => array('job_listing'),
    'post_status'  => array('expired'),
    'order'    => 'DESC'
  ));

  $sitemap_custom_items = '<sitemap>';

  foreach($postsForSitemap as $post) {
    $sitemap_custom_items .= '
      <url><loc>'. get_permalink($post->ID) .'</loc>
      <lastmod>'. $postdate[0] .'</lastmod></url>
      ';
  }

  $sitemap_custom_items .= '</sitemap>';
    return $sitemap_custom_items;

 }
add_filter( 'wpseo_sitemap_index', 'add_sitemap_custom_items' );

Viewing all articles
Browse latest Browse all 3201

Trending Articles