Skip to content

Instantly share code, notes, and snippets.

View wp-seopress's full-sized avatar
😊
Coding SEOPress, best WordPress SEO plugin

Benjamin Denis wp-seopress

😊
Coding SEOPress, best WordPress SEO plugin
View GitHub Profile
@wp-seopress
wp-seopress / filter-the-shipping-properties-in-product-schema.php
Created January 26, 2026 09:45
Filter the shipping properties in product schema
add_filter('seopress_pro_wc_schema_shipping_details', 'sp_wc_schema_shipping_details', 10, 2);
function sp_wc_schema_shipping_details($shipping_offers, $wc_product) {
// Example: add/override a shipping destination + delivery times.
$shipping_offers['shippingDestination'] = [
'@type' => 'DefinedRegion',
'addressCountry' => 'US',
];
$shipping_offers['deliveryTime'] = [
@wp-seopress
wp-seopress / filter-to-disable-woocommerce-shippingdetails-schema-generation.php
Created January 26, 2026 09:30
Filter to disable WooCommerce shippingDetails schema generation
// Enable shipping details
add_filter( 'seopress_pro_wc_schema_shipping_details_enabled', '__return_true' );
// Disable shipping details
add_filter( 'seopress_pro_wc_schema_shipping_details_enabled', '__return_false' );
@wp-seopress
wp-seopress / filter-image-sized-used-in-open-graph-x-cards-tags.php
Last active December 15, 2025 14:23
Filter image size used in Open Graph and X Card tags
add_filter( 'seopress_social_image_size', 'sp_social_image_size' );
function sp_social_image_size( $size ) {
// Return the size you want to use for the image, default is 'full'
return 'large';
}
@wp-seopress
wp-seopress / filter-xml-sitemaps-cache-duration.php
Created October 29, 2025 07:40
Filter XML sitemaps cache duration
add_filter( 'seopress_sitemaps_cache_duration', 'sp_sitemaps_cache_duration', 10, 1 );
function sp_sitemaps_cache_duration( $duration ) {
// default duration is 1 hour (3600 seconds)
return HOUR_IN_SECONDS;
}
@wp-seopress
wp-seopress / filter-local-business-opening-hours-separator.php
Last active September 24, 2025 08:30
Filter Local Business opening hours separator
LB Widget:
add_filter('seopress_lb_widget_opening_hours_separator', 'sp_lb_widget_opening_hours_separator');
function sp_lb_widget_opening_hours_separator($separator) {
// apply your custom logic here
return $separator;
};
LB Block:
add_filter('seopress_lb_block_opening_hours_separator', 'sp_lb_block_opening_hours_separator');
function sp_lb_block_opening_hours_separator($separator) {
@wp-seopress
wp-seopress / limit-index-xml-sitemap-query.php
Last active September 9, 2025 09:20
Limit the number of posts for the XML index sitemaps
add_filter('seopress_sitemaps_index_post_types_query','sp_sitemaps_index_post_types_query', 10, 2);
function sp_sitemaps_index_post_types_query($args, $cpt_key){
$args = [
'posts_per_page' => 10000,
];
return $args;
}
@wp-seopress
wp-seopress / filter-google-snippet-preview-remote-request.php
Last active August 28, 2025 08:54
Filter Google Snippet Preview remote request
function sp_real_preview_remote($args) {
//default: $args = array('blocking' => true,'redirection' => 2,'timeout' => 30,'cookies' => $args['cookies'],'sslverify' => false);
$args['headers'] = array('Authorization' => 'Basic ' . base64_encode( 'admin' . ':' . 'password' ));
return $args;
}
add_filter('seopress_real_preview_remote', 'sp_real_preview_remote');
@wp-seopress
wp-seopress / filter-taxonomies-to-watch-for-automatic-redirections.php
Created August 18, 2025 14:03
Filter taxonomies to watch for automatic redirections
add_filter('seopress_watch_taxonomy_for_redirects', 'sp_watch_taxonomy_for_redirects', 10, 3);
function sp_watch_taxonomy_for_redirects($should_watch, $taxonomy_name, $taxonomy_object) {
// Only watch 'category' and 'post_tag' taxonomies
$allowed_taxonomies = ['category', 'post_tag'];
return in_array($taxonomy_name, $allowed_taxonomies);
}
@wp-seopress
wp-seopress / filter-content-used-to-find-new-video-for-xml-video-sitemap.php
Last active August 13, 2025 13:26
Filter content used to find new video for xml video sitemap
add_filter('seopress_pro_video_sitemap_content', 'sp_pro_video_sitemap_content', 10, 2);
function sp_pro_video_sitemap_content($content, $post_id) {
//eg. to add a custom field, replace 'my_custom_field_name' by your own
$content .= get_post_meta($post_id, 'my_custom_field_name', true);
return $content;
}
@wp-seopress
wp-seopress / enable-disable-execution-of-shortcodes-in-xml-image-sitemaps.php
Last active July 14, 2025 13:46
Enable / disable execution of shortcodes in XML image sitemaps
// Disable shortcode execution for XML image sitemaps
add_filter('seopress_sitemaps_single_shortcodes', '__return_false');
// Enable shortcode execution for XML image sitemaps
add_filter('seopress_sitemaps_single_shortcodes', '__return_true');