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 / 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
@wp-seopress
wp-seopress / filter-the-sitemap-alert-arguments.php
Created January 20, 2025 14:40
Filter the XML sitemap alert arguments
add_filter('seopress_seo_alerts_sitemap_args', 'sp_seo_alerts_sitemap_args');
function sp_seo_alerts_sitemap_args($args) {
// default args
$args = [
'blocking' => true,
'timeout' => 10,
'redirection' => 1,
];
return $args;
}
@wp-seopress
wp-seopress / filter-the-robots-alert-arguments.php
Created January 20, 2025 14:31
Filter the robots.txt alert arguments
add_filter('seopress_seo_alerts_robots_args', 'sp_seo_alerts_robots_args');
function sp_seo_alerts_robots_args($args) {
// default args
$args = [
'blocking' => true,
'timeout' => 10,
'redirection' => 1,
];
return $args;
}
@wp-seopress
wp-seopress / filter-the-homepage-alert-arguments.php
Created January 20, 2025 14:12
Filter the homepage alert arguments
add_filter('seopress_seo_alerts_homepage_args', 'sp_seo_alerts_homepage_args');
function sp_seo_alerts_homepage_args($args) {
// default args
$args = [
'blocking' => true,
'timeout' => 10,
'redirection' => 1,
];
return $args;
}
@wp-seopress
wp-seopress / automatic-product-schema-seopress-pro.php
Last active February 18, 2025 10:04
Add "MerchantReturnPolicy" and "deliveryTime" to each product offer for the automatic product schema with SEOPress PRO
<?php
//Add "MerchantReturnPolicy" and "deliveryTime" to each product offer (simple and variable) for the automatic product schema with SEOPress PRO
add_filter('seopress_schemas_auto_product_json', 'sp_schemas_auto_product_json');
function sp_schemas_auto_product_json($json) {
// Returns schema as an array with 'property' => 'value'
// Check if 'offers' exists in the JSON
if (!isset($json['offers'])) {
return $json;
}
@wp-seopress
wp-seopress / kk-star-ratings-seopress-pro-schemas.php
Last active December 20, 2024 08:37
Integrate KK Star Ratings with SEOPress PRO schemas
// This snippet will retrieve the votes from the current post handled by KK Star Ratings plugin
add_filter('seopress_schemas_auto_recipe_json', 'sp_schemas_auto_recipe_json');
function sp_schemas_auto_recipe_json($json) {
$post_id = get_the_ID();
$rating_data = get_post_meta($post_id, '_kksr_avg_default', true);
$count = get_post_meta($post_id, '_kksr_count_default', true);
if (!empty($rating_data) && !empty($count)) {
$json['aggregateRating'] = [