Skip to content

Instantly share code, notes, and snippets.

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-local-business-types-list-for-schema.php
Created Jun 23, 2021
Filter Local Business types list for schema
View filter-local-business-types-list-for-schema.php
add_filter('seopress_schemas_lb_types', 'sp_schemas_lb_types');
function sp_schemas_lb_types($types)
{
//List here: https://schema.org/LocalBusiness
$types[] = 'MyMissingSubType';
return $types;
}
View rename-seo-page-name-from-admin-menu.php
add_filter('seopress_seo_admin_menu_title', 'sp_seo_admin_menu_title');
function sp_seo_admin_menu_title($name) {
$name = __('my custom page name', 'your-text-domain');
return $name;
}
View filter-local-business-widget-html.php
function sp_lb_widget_html($html) {
var_dump($html);
return $html;
}
add_filter('seopress_lb_widget_html', 'sp_lb_widget_html');
@wp-seopress
wp-seopress / meta-robots-noindex-hidden-woocommerce-products.php
Last active May 27, 2021
Set hidden WooCommerce products meta robots to noindex
View meta-robots-noindex-hidden-woocommerce-products.php
add_filter('seopress_titles_robots_attrs', 'sp_titles_robots_attrs');
function sp_titles_robots_attrs($attrs)
{
if (function_exists('wc_get_product')) {
$product = wc_get_product(get_the_ID());
if (isset($product)) {
$product_visibility = $product->get_catalog_visibility();
//Check product visibility
@wp-seopress
wp-seopress / filter-predefined-dynamic-variables-for-automatic-schemas.php
Last active May 19, 2021
Filter the list of predefined dynamic variables for automatic schemas
View filter-predefined-dynamic-variables-for-automatic-schemas.php
add_filter('seopress_schemas_mapping_select', 'sp_schemas_mapping_select');
function sp_schemas_mapping_select($select) {
//Add the new group option + option to the list
$select['Custom variables'] = [
'my_custom_var_key' => __('My super custom var', 'wp-seopress-pro'),
];
return $select;
}
add_filter('seopress_schemas_dyn_variables', 'sp_schemas_dyn_variables');
@wp-seopress
wp-seopress / disable-content-analysis.php
Created Apr 20, 2021
Remove Content analysis metabox
View disable-content-analysis.php
add_filter('seopress_metaboxe_content_analysis', '__return_false');
@wp-seopress
wp-seopress / filter-woocommerce-order-status-sent-to-google-analytics-enhanced-ecommerce.php
Created Mar 16, 2021
Filter WooCommerce order status sent to Google Analytics Enhanced Ecommerce
View filter-woocommerce-order-status-sent-to-google-analytics-enhanced-ecommerce.php
function sp_gtag_ec_status($status) {
//default status
//$status = ['completed', 'processing'];
return $status;
}
add_filter('seopress_gtag_ec_status', 'sp_gtag_ec_status');
@wp-seopress
wp-seopress / filter-export-redirections-query.php
Last active Mar 16, 2021
Filter export redirections query
View filter-export-redirections-query.php
function sp_export_redirections_query($args) {
//default arguments
$args = [
'post_type' => 'seopress_404',
'posts_per_page' => '-1',
'meta_query' => [
[
'key' => '_seopress_redirections_type',
'value' => ['301', '302', '307', '410', '451'],
'compare' => 'IN',
@wp-seopress
wp-seopress / remove-archive-links-per-post-type-in-html-sitemap.php
Created Mar 11, 2021
Remove archive links per post type in HTML sitemap
View remove-archive-links-per-post-type-in-html-sitemap.php
add_filter('seopress_sitemaps_html_remove_archive', 'sp_sitemaps_html_remove_archive', 10, 2);
function sp_sitemaps_html_remove_archive($display, $cpt_key) {
if ($cpt_key === 'product') {//remove "product" archive page
return true;
}
//do nothing for other CPT
return false;
}
@wp-seopress
wp-seopress / force-the-display-of-the-custom-post-type-archive-page-even-if-it-does-not-exist-in-breadcrumbs.php
Last active May 3, 2021
Force the display of the custom post type archive page even if it does not exist in breadcrumbs
View force-the-display-of-the-custom-post-type-archive-page-even-if-it-does-not-exist-in-breadcrumbs.php
add_filter('seopress_breadcrumbs_force_archive_name', '__return_true');
//has_archive must be set to TRUE in the register post type function