Wordpress - How to limit characters to show at Feeds? - wordpress

In wordpress, there is settings for the feed to show Summary or Full. I want to show only content summary at Feeds. But the default summary is still too long for me. And there's another way to add excerpt at each of the post. For that option, I can't use it either because I am running multiple author blog and most of the people don't know how to add excerpt and my posting form is custom form which is not allowed to add excerpt. I tried to search at google and wordpress plugins, but still haven't get any clue yet.
Is there anyway to limit characters at feed display ? Or is there any plugin out there ? Like at feedburner, I can activate summary feeds and limit the characters.
Please kindly help me out again. Thank you.

put the following in the theme's functions.php file:
add_filter('excerpt_length',create_function('$a','return 25;'));
Where 25 is the number of words you'd like to appear in the excerpt.
If you want the normal excerpt length on the regular page but the short one in the feed, use:
if(is_feed()){
add_filter('excerpt_length',create_function('$a','return 25;'));
}
I don't know whether that will work for sure with all feeds, so I'd suggest just using it without the is_feed() check.

Related

How do you get shortcode content and other templates.php file content or ACF content indexed in the normal wordpress search feature using search.php

I've been trying to conduct some research on this issue,
So building a shortcode for example lets say I have this function
function example_shortcode($content, $atts){
$disclaimer = $atts['disclaimer'];
return "<div>$disclaimer</div>";
}
add_shortcode("example_shortcode","example_shortcode");
buy having the
$content //variable passed to the example_shortcode();
This sort of works for shortcodes as long as it is output by the standard
the_content(); //function through the wordpress wysiwyg
But lets say I call the function into a custom-template.php file and add that template to the page editor attributes for WordPress instead of using the WYSIWYG, then the shortcode content wont appear when doing a search on the front end of the site. To me I feel like wordpress should process this this more intelligently in the future especially since using custom templates loaded through wordpress.But for example
i.e. example.com/?s=test
What concept do I need to start understanding next here, I know if the shortcode is processed through the_content(); function it will sort of work as mentioned earlier,
But really the second part of my question, is just dealing with custom-template.php files using Advanced Custom Fields being output into custom_functions(); then being called into custom-templates.php which are then being loaded through the page attributes of the wordpress page editor, my content and everything works just doesnt show up in search results on wordpress frontend site itself?
I've searched the internet for this issue many times, doesn't seem like many people care about this issue, as I can't find much research or the research is tough to find, or I'm searching incorrectly.
Can anyone start pointing me in the right direction, and new tips on research for this topic.
Thank you all for any comments and advice.
Ive conducted countless hours of research, along with the Plugin Author of Relevanssi Better Search for Wordpress.
So I wanted to share the solutions here.
https://wordpress.org/support/topic/search-not-including-php-hard-coded-content/#post-14432554
This Stack Overflow question is also related to this question here

Algolia Wordpress plugin not indexing post content

Just wondering if you guys could help me. I have indexed all my content from WP and when using the instant search only a few posts are showing any sort of excerpt. I have reindexed a few times to see if it resolved it to no luck.
I am looking on algolia's dashboard and when searching for specific items they have only specific attributes filled in. screenshot from algolia dashboard
Any help is appreciated.
By default the plugin will split the post's content into multiple Algolia records.
Then when displaying results, we display the most relevant matched record as the excerpt.
You could customize this behaviour by following this guide: https://community.algolia.com/wordpress/customize-search-page.html
Let us know if there is something you would like to achieve that does not seem supported or easy to implement.
Update:
It seems like some users are more satisfied with putting the post_title as last in the ranking. That way, the displayed excerpt will be relevant.
the only cases where this would not be ideal is if you want the post title to be more important as the content of your post.

Get only one paragraph from post through RSS

I googled and googled try to find something relevant but no luck.
I'm setting up a 'daily tips' campaign for a client and I have to use RSS to do it.
In more detail I use MailChimp and I create a RSS-Driven campaign.
On the other side in the blog of the website there are daily scheduled posts.
I'm trying to find a way to only get the first paragraph of the each post to give it to MailChimp and include it in the email.
So that the structure ends up like this:
Post title
Post's first paragraph
Read more link
Any ideas?
I don't think this is possible within Mailchimp directly, but you you might try FeedsAPI if you have a specific feed, even perfect if it's a not so popular feed since they can create specific extraction patterns for cases like this, it's however a paid service.

wp email publishing with custom content type?

having researched wp forums and only found people asking this question without any answers, I resort to the source of all truth (stack overflow).
I use wordpress custom post types (Custom Post Type UI plugin) and find it very handy.
Now, I want to be able to email-publish some content via WPs built-in email publishing system, but by default that is set up to only publish as regular posts.
I am aware that I can choose categories for the emailed content, but I would very much like to keep all the pages and content of my news (=blogposts) feeds the way they are, being able to put the email-published content into a content type of its own would really help me out.
So I wonder if anyone has done that, and how you would go about it. Thanks for any input.
Not sure if this helps people looking for a solution, but I managed to do it like this...
When a post is submitted for publish by WordPress default email2post, there is an action hook named 'publish_phone' running, so you can get the post there and change its type like this:
add_action('publish_phone','custom_type_by_mail');
function custom_type_by_mail($post_id){
$p = get_post($post_id,'ARRAY_A');
$p['post_type'] = "my-custom-type";
wp_update_post($p);
}
I resorted to converting it into a post category instead of its own content type. I know not whether there be any other solution =)

Post privacy in Wordpress

Can a post be hidden from home page, archive view, category lists etc. and viewable only if you have a direct link to it? The blog doesn't have registered readers and is open to public so that would be a mean of hiding some posts from public view without using the password protection.
I asked this question in Wordpress section and the idea there was to use conditional code so I'm asking the question here as well to get closer to the code.
If I used conditioning, would I have to input each post's ID separately to PHP file for archive, categories, search and such?
EDIT:
After reading a bit more all over, I had an idea of creating a private category and then use some kind of conditioning so that posts from that category are hidden. According to Codex, certain category can be hidden from, for example front page but I don't know if there's a way to hide it altogether except when you have a direct link.
Creating a "Private" category is a good solution. It is quite possible to hide this category altogether except via direct link. You just have to "block all the exits" with conditional code.
The default WordPress theme displays posts via the Post Loop. See http://codex.wordpress.org/The_Loop, especially the section entitled "Exclude Posts from Some Category". Just find all the places in your theme's PHP files (e.g. index.php) where this loop is used, and add the conditional code. You'd also need to filter your category list and blog archives in the side menu. Don't add filtering in single.php, otherwise the private post won't display on its own page.
You'd probably want to add a similar condition to filter search results so that private posts aren't leaked via the blog's search tool. There may be more "exits" I haven't thought of, but I'll be sure to update as I do. I'm glad to look at specific code if you so desire.
Understanding WordPress' post query and loop really opens up a world of possibilities for customization.
I found the simplest way - just use Simply Exclude Wordpress plugin. It has the option to exclude each post (or tag, for that matter) from front page, archive, search or feed. It works flawlessly. You can still view the posts by using direct links.
(Not actually an answer that includes code but a working solution nonetheless.)

Resources