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-the-content-to-calculate-the-number-of-words-in-the-content-analysis.php
Created March 26, 2019 18:38
Filter the content to calculate the number of words in the content analysis
function sp_filter_content_content_analysis($seopress_get_the_content, $seopress_get_the_id) {
return get_post_field('post_content', $seopress_get_the_id);
}
add_filter('seopress_content_analysis_content', 'sp_filter_content_content_analysis', 10, 2);
@wp-seopress
wp-seopress / filter-google-optimize-container-id.php
Created April 17, 2019 16:56
Filter Google Optimize container ID
function sp_gtag_optimize_id() {
return 'GTM-123456';
}
add_filter('seopress_gtag_optimize_id', 'sp_gtag_optimize_id');
@wp-seopress
wp-seopress / filter-automatic-image-attributes.php
Created April 19, 2019 17:50
Filter automatic image attributes
function sp_auto_image_attr($img_attr_array) {
$img_attr_array['post_title'] = "my image title";
$img_attr_array['post_excerpt'] = "my image caption";
$img_attr_array['post_content'] = "my image description";
return $img_attr_array;
}
add_filter('seopress_auto_image_attr', 'sp_auto_image_attr');
@wp-seopress
wp-seopress / remove-seopress-icons-in-header.php
Created May 5, 2019 09:08
Remove SEOPress icons in header
define('SEOPRESS_WL_ICONS_HEADER', false);
@wp-seopress
wp-seopress / filter-article-published-time-meta.php
Last active May 13, 2019 17:37
Filter article published time meta
function sp_titles_article_published_time($html) {
//you can add here all your conditions as if is_page(), is_category() etc..
$html = '<meta property="article:published_time" content="2019-05-06T19:18:27+00:00" />';
return $html;
}
add_filter('seopress_titles_article_published_time', 'sp_titles_article_published_time');
@wp-seopress
wp-seopress / filter-article-modified-time-meta.php
Created May 13, 2019 17:41
Filter article modified time meta
function sp_titles_article_modified_time($html) {
//you can add here all your conditions as if is_page(), is_category() etc..
$html = '<meta property="article:modified_time" content="2019-05-06T19:18:27+00:00" />';
return $html;
}
add_filter('seopress_titles_article_modified_time', 'sp_titles_article_modified_time');
@wp-seopress
wp-seopress / filter-og-updated-time-meta.php
Created May 13, 2019 17:50
Filter OG updated time meta
function sp_titles_og_updated_time($html) {
//you can add here all your conditions as if is_page(), is_category() etc..
$html = '<meta property="og:updated_time" content="2019-05-06T19:18:27+00:00" />';
return $html;
}
add_filter('seopress_titles_og_updated_time', 'sp_titles_og_updated_time');
@wp-seopress
wp-seopress / seopress-deactivation-hook.php
Created February 28, 2019 21:00
SEOPress deactivation hook
function sp_deactivation() {
//do something here
return $something;
}
add_action('seopress_deactivation','sp_deactivation');
@wp-seopress
wp-seopress / seopress-activation-hook.php
Created February 28, 2019 20:59
SEOPress activation hook
function sp_activation() {
//do something here
return $something;
}
add_action('seopress_activation','sp_activation');
@wp-seopress
wp-seopress / filter-latest-post-type-query-in-xml-index-sitemap.php
Last active May 22, 2019 11:05
Filter latest post type query in XML index sitemap
function sp_sitemaps_index_cpt_query($args, $cpt_key) {
//Default Query
//$args = array('post_type' => $cpt_key, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'posts_per_page' => 1, 'meta_query' => array( array( 'key' => '_seopress_robots_index', 'value' => 'yes', 'compare' => 'NOT EXISTS' ) ), 'order' => 'DESC', 'orderby' => 'modified', 'lang' => '');
$args['orderby'] = 'date';
return $args;
}
add_filter('seopress_sitemaps_index_cpt_query', 'sp_sitemaps_index_cpt_query', 10, 2);