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-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-terms-headings-in-html-sitemap.php
Last active June 17, 2025 09:23
Filter terms in HTML sitemap titles
add_filter('seopress_sitemaps_html_display_terms_only', 'sp_sitemaps_html_display_terms_only', 10, 2);
function sp_sitemaps_html_display_terms_only($display_terms_only, $cpt_key) {
// Display terms only for products
if ($cpt_key == 'product') {
return true;
}
return $display_terms_only;
}
@wp-seopress
wp-seopress / run-action-after-a-404-error-is-inserted.php
Created May 14, 2025 12:03
Run action after a 404 error is inserted
add_action('seopress_after_create_404', 'sp_after_create_404');
function sp_after_create_404($id) {
//do your stuff here
return $something;
}
@wp-seopress
wp-seopress / composer.json
Last active April 10, 2025 12:57
Composer & SEOPress PRO
{
"repositories": [
{
"type": "package",
"package": {
"name": "wp-seopress-pro/wp-seopress-pro",
"version": "8.6.1",
"type": "wordpress-plugin",
"dist": {
"url": "https://www.seopress.org/?edd_composer_download=1&license_key=xxxxxxxxxxxx&version=8.6.1&lang=en&url=https://example.com",