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-arguments-sent-to-ai-provider-to-generate-social-metadata.php
Last active March 10, 2026 15:05
Filter the arguments sent to AI provider to generate social metadata
<?php
add_filter( 'seopress_ai_openai_social_request_args', 'sp_ai_openai_social_request_args' );
function sp_ai_openai_social_request_args( $args ) {
// Example: increase the timeout if your answers are long.
$args['timeout'] = 45;
// Example: adding/overriding a custom header.
if ( ! isset( $args['headers'] ) || ! is_array( $args['headers'] ) ) {
$args['headers'] = [];
}
$args['headers']['X-My-Project'] = 'my-seopress-ai-integration';
@wp-seopress
wp-seopress / filter-ai-generated-social-metadata.php
Last active March 10, 2026 14:49
Filter AI generated social metadata
<?php
// Filter the X description generated by OpenAI
add_filter( 'seopress_ai_openai_social_twitter_description', 'sp_ai_openai_social_twitter_description', 10, 2 );
function sp_ai_openai_social_twitter_description( $prompt, $post_id ) {
// Example: prepend post type label
$post_type_obj = get_post_type_object( get_post_type( $post_id ) );
if ( $post_type_obj && ! empty( $post_type_obj->labels->singular_name ) ) {
$prompt = $post_type_obj->labels->singular_name . ': ' . $prompt;
}
@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;
}