Comments (9)
Hi @ovizii,
Thanks for this! I now noticed I made a typo in the CPT sitemap generation :(.
Anyway, in order to remove replies from the sitemap, please use the following snippet, using this filter:
add_filter( 'the_seo_framework_sitemap_exclude_cpt', 'my_sitemap_exlusions' );
function my_sitemap_exclusions( $exclusions = array() ) {
$exclusions[] = 'replies';
//* You can add more exclusions, for example:
$exclusions[] = 'forums';
return $exclusions;
}
You can reset the sitemap's cache by updating a post/page, or by re-saving the SEO Settings.
I hope this helps! Cheers 😄
from the-seo-framework.
thanks for the quick reply and the snippet.
hm, that didn't seem to work. Are you sure I need to exclude "replies" and not "reply"?
I've edited a page and re-saved the settings and invalidated
from the-seo-framework.
Hi ovizii,
I'm not sure if it's reply or replies.
The only way you can be certain is to dump the current post type on the said page, or dump all public post types and make your picks from there: get_post_types( array( 'public' => true ) );
But before that, I'd suggest trying reply
:).
from the-seo-framework.
hm, I dumped all of them:
<?php foreach ( get_post_types( '', 'names' ) as $post_type ) { echo '<p>' . $post_type . '</p>'; } ?>
Result:
post, page, attachment, revision, nav_menu_item, forum, topic, reply, bp-email, postman_sent_mail
so I then inserted reply into your previous snippet and yet no change. Any more ideas? Does your snippet work for you? Here is what is inside my functions.php
/* Added to remove replies from the sitemap */
add_filter( 'the_seo_framework_sitemap_exclude_cpt', 'my_sitemap_exlusions' );
function my_sitemap_exclusions( $exclusions = array() ) {
$exclusions[] = 'reply';
return $exclusions;
}
from the-seo-framework.
Hi @ovizii,
I still have a very hard time using bbPress on my test server... no settings for the forums are shown 😕.
Nevertheless, I figured it out 😄.
It's not working because I made a typo:
my_sitemap_exlusions
my_sitemap_exclusions
You'd have to change the function name or the callback name accordingly so they're equal.
In your case, this snippet should work as expected, don't forget to flush the sitemap's cache by re-saving the SEO settings:
add_filter( 'the_seo_framework_sitemap_exclude_cpt', 'my_sitemap_exclusions' );
function my_sitemap_exclusions( $exclusions = array() ) {
$exclusions[] = 'reply';
return $exclusions;
}
Cheers!
P.S. You'll need to use three backticks with a line-feed/return to write code blocks at GitHub.
P.P.S. Unfortunately, I do not have the time to test all code snippets I post here or on the WordPress.org forums. I used to do that, but I noticed it eats out hours of my day; so I write quick examples based on estimations. I hope you understand, and I'm sorry to have wasted some of your time by doing so :(.
from the-seo-framework.
Hi and thanks for the help so far. Absolutely no need to explain yourself, this is outstanding support you're doing here for free. Thanks for the tip with the "```" :-)
I should have looked closer at the snippet you provided, I could have caught that typo myself.
I can confirm this all works as expected! Thanks a lot, maybe add this to the plugin FAQ as a link?
from the-seo-framework.
Anytime! I'm glad it worked out.
A knowledge base/FAQ is certainly planned, and I have more than enough data to fill it in 😄.
Even more so, an automated plugin function documentation system is planned, as seen on https://developers.wordpress.org/. But that's a project for later.
For now, filters, constants and other things are shown at The SEO Framework API docs. It requires some updates (rather a complete rework 😝), but most information is already present.
Have a wonderful day!
from the-seo-framework.
My sense is that this method no longer works? I can't find the the_seo_framework_sitemap_exclude_cpt
hook in the plugin code. How do I remove a CPT from being listed in the sitemap?
from the-seo-framework.
Hi @cjyabraham
For best performance, I recommend using the_seo_framework_sitemap_supported_post_types
now. It's a sequential array of supported post types.
add_filter( 'the_seo_framework_sitemap_supported_post_types', function( $post_types ) {
return array_diff( $post_types, [ 'exclude_this_post_type', 'exclude_me_too' ] );
} );
Cheers!
from the-seo-framework.
Related Issues (20)
- Rename popular filters HOT 3
- Update Gutenberg's permalink store when selecting a primary term.
- Add listeners for default visibility options in quick-edit.
- 5.0 Beta Test. HOT 1
- Add SEO Bar to User list edit
- Set custom namespaces for compatibility files
- Hashtag/pound is removed from theme-color HOT 1
- Typo: "Note: rhe description " on Settings > Homepage > Meta Description HOT 1
- Toggle Sitemap stylesheet header link HOT 1
- Google Tag Manager connection HOT 1
- Sitemap priority setting HOT 1
- Post archive title shows as "No Title - (website name)"
- Site name is not displayed by Google + Schema.org: 'alternateName' is missing HOT 7
- Make archive exclusions work for adjacent post links. HOT 2
- Polylang: Wrong canonical URL for non-default language's homepage HOT 1
- `wp_sitemaps_post_types` vs `the_seo_framework_sitemap_supported_post_types` hook HOT 3
- Add noindex headers to the Core Sitemap
- Add breadcrumb title and hierarchy options HOT 8
- Option to not notify search engines on post update
- Allow setting of custom alternateName(s)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from the-seo-framework.