• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Jetpack a2z

Jetpack a2z

Jetpack a2z

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Jetpack_Sitemap_Builder::news_sitemap_xml() – Build and return the news sitemap xml. Note that the result of this function is cached in the transient ‘jetpack_news_sitemap_xml’.

You appear to be a bot. Output may be restricted

Description

Build and return the news sitemap xml. Note that the result of this function is cached in the transient 'jetpack_news_sitemap_xml'.

Usage

$string = Jetpack_Sitemap_Builder::news_sitemap_xml();

Parameters

Returns

string The news sitemap xml.

Source

File name: jetpack/modules/sitemaps/sitemap-builder.php
Lines:

1 to 53 of 53
  public function news_sitemap_xml() {
    $the_stored_news_sitemap = get_transient( 'jetpack_news_sitemap_xml' );

    if ( false === $the_stored_news_sitemap ) {

      if ( $this->logger ) {
        $this->logger->report( 'Beginning news sitemap generation.' );
      }

      
/**
 * Filter limit of entries to include in news sitemap.
 *
 * @module sitemaps
 *
 * @since 3.9.0
 *
 * @param int $count Number of entries to include in news sitemap.
 */
      $item_limit = apply_filters(
        'jetpack_sitemap_news_sitemap_count',
        JP_NEWS_SITEMAP_MAX_ITEMS
      );

      $buffer = new Jetpack_Sitemap_Buffer_News(
        min( $item_limit, JP_NEWS_SITEMAP_MAX_ITEMS ),
        JP_SITEMAP_MAX_BYTES
      );

      $posts = $this->librarian->query_most_recent_posts( JP_NEWS_SITEMAP_MAX_ITEMS );

      foreach ( $posts as $post ) {
        $current_item = $this->post_to_news_sitemap_item( $post );

        if ( false === $buffer->append( $current_item['xml'] ) ) {
          break;
        }
      }

      if ( $this->logger ) {
        $this->logger->time( 'End news sitemap generation.' );
      }

      $the_stored_news_sitemap = $buffer->contents();

      set_transient(
        'jetpack_news_sitemap_xml',
        $the_stored_news_sitemap,
        JP_NEWS_SITEMAP_INTERVAL
      );
    } // End if.

    return $the_stored_news_sitemap;
  }
 

 View on GitHub View on Trac

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Related

Published: 27 November 2019 | Last updated: 27 November 2019

Primary Sidebar

Information

Function name: Jetpack_Sitemap_Builder::news_sitemap_xml
Class ref: Jetpack_Sitemap_Builder
Plugin ref: Jetpack
Version: 9.2
Sourcefile: modules/sitemaps/sitemap-builder.php
File ref: modules/sitemaps/sitemap-builder.php
Deprecated?: No
API Letters: B,J,N,S

Footer

Jetpack a2z
Jetpack a2z
Jetpack a2z
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  jetpack.wp-a2z.org
© Copyright Jetpack a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites