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-google-analytics-external-links-tracking.php
Last active October 9, 2019 15:32
Filter Google Analytics external links tracking
@wp-seopress
wp-seopress / filter-google-analytics-ip-anonymization-feature.php
Created February 28, 2019 18:49
Filter Google Analytics IP Anonymization feature
function sp_gtag_anonymize_ip($html) {
return "'anonymize_ip': true,";
}
add_filter('seopress_gtag_anonymize_ip', 'sp_gtag_anonymize_ip');
@wp-seopress
wp-seopress / filter-google-analytics-link-attribution-feature.php
Created February 28, 2019 18:50
Filter Google Analytics Link Attribution feature
@wp-seopress
wp-seopress / filter-google-analytics-remarketing-feature.php
Created February 28, 2019 18:52
Filter Google Analytics Remarketing feature
function sp_gtag_allow_display_features($html) {
return "'allow_display_features': false,'";
}
add_filter('seopress_gtag_allow_display_features', 'sp_gtag_allow_display_features');
@wp-seopress
wp-seopress / filter-google-analytics-tracking.php
Created February 28, 2019 18:53
Filter Google Analytics tracking
function sp_gtag_html($html) {
return "your custom Google Analytics tracking code";
}
add_filter('seopress_gtag_html', 'sp_gtag_html');
@wp-seopress
wp-seopress / filter-google-analytics-tracking-with-a-custom-dimension.php
Created February 28, 2019 18:54
Filter Google Analytics tracking with a custom dimension
function sp_gtag_cd_hook_cf($html) {
return "'dimension6': 'custom_dimension',";
}
add_filter('seopress_gtag_cd_hook_cf', 'sp_gtag_cd_hook_cf');
function sp_gtag_cd_hook_ev($html) {
return "gtag('event', '".__('My custom dimension','wp-seopress')."', {'custom_dimension': 'my_custom_data'});";
}
add_filter('seopress_gtag_cd_hook_ev', 'sp_gtag_cd_hook_ev');
@wp-seopress
wp-seopress / filter-google-news-xml-sitemap-query.php
Last active May 22, 2019 11:06
Filter Google News XML sitemap query
function sp_sitemaps_single_gnews_query($args) {
//Default Query
//$args = array( 'exclude' => '', 'posts_per_page' => 1000, 'order'=> 'DESC', 'orderby' => 'date', 'post_type' => $seopress_xml_sitemap_news_cpt_array, 'post_status' => 'publish', 'meta_query' => array( array( 'key' => '_seopress_robots_index', 'value' => 'yes', 'compare' => 'NOT EXISTS' ) ), 'date_query' => array(array('after' => '2 days ago')), 'post__not_in' => get_option( 'sticky_posts' ), 'lang' => '');
$args['posts_per_page'] = '100';
return $args;
}
add_filter('seopress_sitemaps_single_gnews_query', 'sp_sitemaps_single_gnews_query');
@wp-seopress
wp-seopress / filter-google-snippet-preview-remote-request.php
Last active August 28, 2025 08:54
Filter Google Snippet Preview remote request
function sp_real_preview_remote($args) {
//default: $args = array('blocking' => true,'redirection' => 2,'timeout' => 30,'cookies' => $args['cookies'],'sslverify' => false);
$args['headers'] = array('Authorization' => 'Basic ' . base64_encode( 'admin' . ':' . 'password' ));
return $args;
}
add_filter('seopress_real_preview_remote', 'sp_real_preview_remote');
@wp-seopress
wp-seopress / filter-hierarchical-post-type-query-in-html-sitemap.php
Last active September 3, 2019 09:00
Filter hierarchical post type query in HTML sitemap
function sp_sitemaps_html_pages_query($args2, $cpt_key) {
//default:
//$args2 = array('post_type' => $cpt_key, 'include'=>$postslist, 'sort_order' => $seopress_xml_sitemap_html_order_option, 'sort_column' => $seopress_xml_sitemap_html_orderby_option);
$args2['exclude'] = 10;
//exclude post with ID 10
return $args2;
}
add_filter( 'seopress_sitemaps_html_pages_query', 'sp_sitemaps_html_pages_query', 10, 2 );
@wp-seopress
wp-seopress / filter-html-sitemap-category-query-for-posts.php
Last active May 22, 2019 11:06
Filter HTML Sitemap category query for posts
function sp_sitemaps_html_cat_query($args_cat_query) {
//default
//$args_cat_query = array('orderby'=>'name','order'=>'ASC','meta_query' => array( array( 'key' => '_seopress_robots_index', 'value' => 'yes', 'compare' => 'NOT EXISTS' ) ),'exclude'=>$seopress_xml_sitemap_html_exclude_option,'suppress_filters'=>false);
$args_cat_query['exclude'] = '10,12,20'; //my ids
return $args_cat_query;
}
add_filter( 'seopress_sitemaps_html_cat_query', 'sp_sitemaps_html_cat_query' );