Is there a is_ function for sitemaps?

There is no is_sitemap() core function in WP < 6.8, but there is a ticket for it here. The rewrite rules for the sitemap (src) use e.g. the sitemap query variable: add_rewrite_rule( ‘^wp-sitemap\.xml$’, ‘index.php?sitemap=index’, ‘top’ ); add_rewrite_rule( ‘^wp-sitemap-([a-z]+?)-([a-z\d_-]+?)-(\d+?)\.xml$’, ‘index.php?sitemap=$matches[1]&sitemap-subtype=$matches[2]&paged=$matches[3]’, ‘top’ ); add_rewrite_rule( ‘^wp-sitemap-([a-z]+?)-(\d+?)\.xml$’, ‘index.php?sitemap=$matches[1]&paged=$matches[2]’, ‘top’ ); The get_query_var( ‘sitemap’ ) is checked within the template_redirect … Read more

add_rewrite_rule – how to match exact whole word only?

Here’s the updated code with the explanation and last two lines added: Updated Code with Last Two Lines add_action(‘query_vars’, ‘add_query_vars’); function add_query_vars($vars) { $vars[] = ‘verify’; // Add ‘verify’ as a query variable return $vars; } add_action(‘init’, ‘verify_add_rewrite_rule’); function verify_add_rewrite_rule() { // Use ^verify/?$ to strictly match “verify” and ensure it ends there add_rewrite_rule(‘^verify/?$’, ‘index.php?verify=1&post_type=page’, … Read more

WP Query to display events and custom post type in a set order

I have implemented the following code to my them to achieve the custom ordering for featured events (first), regular events (second), and notices (third). New additions to the code include: Merged the posts using array_merge like this: $merged_posts = array_merge( $featured_events->posts, $future_events->posts, $notices->posts ); Ran a foreach to set a custom post order for featured … Read more

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