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 / dynamic-variables-acf-options-page-for-seopress.php
Created April 10, 2024 15:57
Create a dynamic variable from Advanced Custom Fields options page for SEOPress metadata
function sp_titles_template_variables_array($array) {
$array[] = '%%_acf_options_my_field_name%%';
$array[] = '%%_acf_options_my_field_name_2%%';
return $array;
}
add_filter('seopress_titles_template_variables_array', 'sp_titles_template_variables_array');
function sp_titles_template_replace_array($array) {
$array[] = esc_attr(wp_strip_all_tags(get_field('my_field_name', 'option')));
@wp-seopress
wp-seopress / remove-seopress-widgets-from-dashboard.php
Last active March 14, 2024 09:52
Remove SEOPress dashboard widgets
add_action('wp_dashboard_setup', 'sp_remove_dashboard_widgets' );
function sp_remove_dashboard_widgets() {
remove_meta_box( 'seopress_ga_dashboard_widget', 'dashboard', 'normal' );
remove_meta_box( 'seopress_insights_dashboard_rankings_widget', 'dashboard', 'normal' );
remove_meta_box( 'seopress_matomo_dashboard_widget', 'dashboard', 'normal' );
}
@wp-seopress
wp-seopress / filter-export-404-errors-query.php
Created January 30, 2024 16:32
Filter export 404 errors query
add_filter('seopress_export_404_query', 'sp_export_404_query');
function sp_export_404_query($args) {
$args = [
'post_type' => 'seopress_404',
'posts_per_page' => '-1',
'meta_query' => [
[
'key' => '_seopress_redirections_type',
'compare' => 'NOT EXISTS',
],
@wp-seopress
wp-seopress / filter-the-arguments-sent-to-openai-to-generate-alternative-texts.php
Created December 11, 2023 14:37
Filter the arguments sent to OpenAI to generate alternative texts
add_filter('seopress_ai_openai_request_args_alt', 'sp_ai_openai_request_args_alt');
function sp_ai_openai_request_args_alt($args) {
//do your stuff, this is just an example
//var_dump($body)
$args = [
'body' => json_encode($body),
'timeout' => '30',
'redirection' => '5',
@wp-seopress
wp-seopress / filter-breadcrumbs-json.php
Created December 6, 2023 14:50
Filter Breadcrumbs JSON
add_filter( 'seopress_pro_breadcrumbs_json', 'sp_pro_breadcrumbs_json' );
function sp_pro_breadcrumbs_json($array) {
//var_dump($array);
//do your stuff
return $array;
}
@wp-seopress
wp-seopress / filter-the-video-xml-sitemap-regeneration-tool.php
Created November 9, 2023 15:46
Filter the video XML sitemap regeneration tool
function sp_video_regeneration_total_count_posts($sql) {
global $wpdb;
$sql = (int) $wpdb->get_var("SELECT count(*) FROM {$wpdb->posts} WHERE post_status IN ('pending', 'draft', 'publish', 'future') AND post_type IN ( 'your_cpt_name' ) ");
return $sql;
}
add_filter('seopress_video_regeneration_total_count_posts', 'sp_video_regeneration_total_count_posts');
function sp_video_regeneration_increment($increment) {
//default: 1
@wp-seopress
wp-seopress / filter-productpricecurrency-meta-tag.php
Created November 9, 2023 09:34
Filter product:price:currency meta tag
function sp_product_price_currency($currency) {
return $currency;
}
add_filter('seopress_product_price_currency', 'sp_product_price_currency');
@wp-seopress
wp-seopress / filter-productpriceamount-meta-tag.php
Created November 9, 2023 09:29
Filter product:price:amount meta tag
function sp_product_price_amount($price) {
return $price;
}
add_filter('seopress_product_price_amount', 'sp_product_price_amount');
@wp-seopress
wp-seopress / stop-saving-hits-and-last-date-request-for-each-redirection.php
Created November 8, 2023 17:14
Stop saving hits and last date request for each redirection
add_filter('seopress_stop_counter_redirects', '__return_true');
add_filter('seopress_stop_last_date_request_redirects', '__return_true');
@wp-seopress
wp-seopress / filter-post-title-in-html-sitemap.php
Last active November 8, 2023 14:11
Filter post title in HTML sitemap
function sp_sitemaps_html_post_title($post_title) {
//do your sutff
return $post_title;
}
add_filter('seopress_sitemaps_html_post_title', 'sp_sitemaps_html_post_title');