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-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",
@wp-seopress
wp-seopress / filter-the-admin-bar-counter.php
Created April 9, 2025 12:30
Filter the admin bar counter
function sp_adminbar_counter($counter, $total) {
// Default counter
$counter = '<div class="wp-core-ui wp-ui-notification seopress-menu-notification-counter">' . $total . '</div>';
return $counter;
}
add_filter('seopress_adminbar_counter', 'sp_adminbar_counter', 10, 2);
@wp-seopress
wp-seopress / filter-seopress-insights-dashboard-widget-capability.php
Created March 18, 2025 09:21
Filter SEOPress Insights Dashboard widget capability
function sp_dashboard_rankings_widget_cap($cap){
//default: 'edit_dashboard' capability
return 'edit_posts';
}
add_filter('seopress_insights_dashboard_rankings_widget_cap','sp_dashboard_rankings_widget_cap');
@wp-seopress
wp-seopress / filter-rel-nextprev-link-in-head-of-paginated-archive-pages.php
Created February 4, 2025 14:36
Filter rel next/prev link in head of paginated archive pages