• Resolved Dmytro Romanenko

    (@avawe)


    Hi guys, there is a need for a filter for the sitemap. In one of my projects, I made a revision to your plugin to select posts by status, please include these changes in the next release.

    File:
    includes/modules/sitemap/providers/class-post-type.php

    Function:
    protected function get_sql_where_clause( $post_types )

    Code:

    $post_statuses = apply_filters('rank_math/sitemap/post_statuses', array('publish'), $post_types);
    
    $status = "{$wpdb->posts}.post_status in ( '" . implode("', '", $post_statuses) . "' )";

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Dmytro Romanenko

    (@avawe)

    Also please add filter for:

    File:
    includes/modules/sitemap/class-sitemap.php

    Function:
    public static function get_last_modified_gmt( $post_types, $return_all = false ){}

    Code:

    $post_statuses = apply_filters('rank_math/sitemap/post_statuses', array('publish','inherit'), $post_types);
    				$sql = "
    				SELECT post_type, MAX(post_modified_gmt) AS date
    				FROM $wpdb->posts
    				WHERE post_status IN ('" . implode( "','", $post_statuses ) . "')
    					AND post_type IN ('" . implode( "','", $post_type_names ) . "')
    				GROUP BY post_type
    				ORDER BY post_modified_gmt DESC";

    Thanks.

    Plugin Author Rank Math

    (@rankmath)

    Hello @avawe

    Thank you for contacting the support.

    Which post status posts are you trying to include in the Sitemap? By default, Rank Math adds both the publish and inherit posts in the Sitemap.

    To include/exclude posts from the Sitemap, you can use the below filters:
    https://rankmath.com/kb/filters-hooks-api-developer/#change-remove-post-url
    &
    https://rankmath.com/kb/filters-hooks-api-developer/#add-extra-urls-in-sitemap

    With that being said, there are existing feature requests, so I’ve added your vote to our internal suggestions lists.

    Thread Starter Dmytro Romanenko

    (@avawe)

    Thanks a lot!

    Plugin Author Rank Math

    (@rankmath)

    Hello,

    Glad that helped.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add new filter’ is closed to new replies.