Jetpack Related Posts enhancement ideas
I hope some or all of these ideas can be implemented into the Jetpack Related Posts module. tyvm for it.
- [x] ability to use the shortcode anywhere (not just in the loop, but okay to return false if !is_single() )
- [ ] ability to take arguments like size, post_type, has_terms, date_range, exclude_post_ids, and include_post_ids (e.g. force post ID '1875' to be one of the related posts)
- [x] add site-wide settings at the Reading settings for image size, date range, etc.
- [x] auto-inserting of related posts on 'posts' post type shouldn't happen if the shortcode is detected in the post's content
- [ ] ability to disable showing of related posts via wp-admin post editor (i.e. on a per-post level)
- [x] ability to index posts without comments enabled. I believe it should instead look for if the post type is public or if it's publicly queryable
- [ ] add a Related Posts widget
Ping @xyu
- For the second point, to clarify, you're suggestion that the shortcode support arguments for these? (e.g. for the
jetpack_relatedposts_filter_thumbnail_size,jetpack_relatedposts_filter_post_type,jetpack_relatedposts_filter_date_range.jetpack_relatedposts_filter_has_termsfilters) - I think we're not likely to add too many settings in the settings panel for this. It is pretty flexible via code, while still simple for users (the WordPress "Decisions, Not Options" philosophy)
- Related Posts are already removed from the
the_contentfilter when the shortcode is used very quick example. - Posts with comments disabled should still be indexed. Could you point out where they're excluded? A quick glance, I didn't see it.
@kraftbj I suggested to @cliffordp that post types might be indexed if they support comments. It turns out this is not the case.
@enejb Gotcha. CPTs are generally included if they're public, I believe. @xyu can confirm since this is his wheelhouse.
For the 2nd point, yes, @kraftbj, although I added the idea for include_post_ids (i.e. forcing to be included)... basically allowing shortcode attributes for those filters.
Thanks for considering this list and for the demo link that shows that item works.
@kraftbj @enejb by default we only index the standard post and page post types. However public CPTs can be whitelisted using the rest_api_allowed_post_types filter.
@enejb provided this code to me, which didn't result in indexing my 'real-estate-answers' custom post type:
function jetpack_sync_real_estate_answers($post_types){
$post_types[] = 'real-estate-answers';
return $post_types;
}
add_filter( 'rest_api_allowed_post_types', 'jetpack_sync_real_estate_answers');
Should that code be working?
@cliffordp Could you try to reindex, by going to the Debug menu in Jetpack and clicking on the Reindex button? You can access the debug menu by going to the Jetpack menu in your dashboard, and clicking on the "Debug" link at the bottom of the page.
Yes, I did that after adding the above code. We tried several different ways. Is the code above correct? (i.e. Add code, Reindex, Use API console to check by post ID)
@cliffordp Apologies for the inconvenience but we are currently upgrading our internal search infrastructure in order to provide even faster and better searching and have turned off indexing / loading new content while this is going on.
We are aiming for later today or tomorrow to start indexing again, if you provide @enejb or I your site's URL we can prioritize it so that it's one of the first to be reindexed.
@xyu, @enejb and I have been playing with 'real-estate-answers' cpt for http://endzonerealty.com/ for over a week now so anything yesterday or today wouldn't have affected this. That's why I was asking for verification if the code was the correct way to add my cpt. Thanks.
@cliffordp your code is indeed correct and I do see that the 'real-estate-answers' CPT posts are in our system however they were not indexed into our search infrastructure but they should be indexed at this point.
I didn't intend to turn this into a "it's not working" back-and-forth topic, but it's not working for me. In the console, /sites/43838058/posts/13851/related returns "error Bad Request. message query failed." However, if I understood you correctly, you said it should be indexed at this point. I tried it and got this error then told it to re-index posts again. Once it said it re-indexed, it still gave the error in console.
Hi. Just checking back to see if there's any way to use Related Posts on my 'real-estate-answers' custom post type for endzonerealty.com
tyvm
Hi Cliff, Turns out this is a bit more tricky then we though. We are still working on this and will let you know when it is ready. The changes required have to be done in such away so that it doesn't break backwards compatibility or expose private data.
Check out https://github.com/xyu/jetpack/tree/jsonapi-allow-public-cpts is the branch where the work is taking place.
Excellent. Thanks for the follow up. I'll be eagerly awaiting the functionality, as well as other enhancements (my suggestions in this issue's initial comment). Thank you all so much!
@cliffordp is this working for you yet? I was curious as to this functionality, as well, and a Google search led me here.
Ya know, I've definitely seen it working on some posts and thought "don't know what changed, but great!" But just now checked a few and didn't see it working. Example CPT post where I'd like to see related posts displayed: http://endzonerealty.com/real-estate-answers/need-flood-insurance/
I have [jetpack-related-posts] in the Views content template and in the Views Settings "Third-party shortcode arguments" (http://wp-types.com/documentation/user-guides/shortcodes-within-shortcodes/) and, like I said, I definitely have seen it working and referring to other posts within the same CPT so... short answer is "maybe a little" ;)
@cliffordp Thanks for getting back so quick! That's kind of a bummer. I was hoping to offshore related posts to jetpack, but hopefully it won't be so finicky soon.
@cliffordp @mfgmk In order to get CPTs to work with related posts they must be explicitly whitelisted see here in order for them to be synced to Automattic. (Once it's been whitelisted go into the Jetpack debug page and trigger a bulk resync to force a sync.)
Then to get related posts to also include CPTs in results you can filter jetpack_relatedposts_filter_post_type akin to getting pages to show up in results.
Let me know if that helps.