AutoBlog - Limit post title

Is it possible to limit the post title when using auto blog with a zapier RSS page stream feed

  • Adam Czajczyk

    Hello Olivier,

    I hope you're well today and thank you for your question!

    Do you by "limit the post title" mean limiting its length? The Autoblog plugin doesn't include such feature "out of the box" but it seems that it may be doable with some additional code hooked to it.

    Please confirm whether I understood you right and I'd then ask the plugin developer for consultation.

    Best regards,
    Adam

  • Adam Czajczyk

    Hello Olivier,

    Thank you for confirming this.

    In WordPress this could be achieved with a custom filter added to the "the_title" function but that would affect all the titles on the site, unless posts coming from feeds are assigned to specific categories only - we could then apply that filter to posts from that category (or categories) only as well.

    I think though that you would want to get a solution strictly for Autoblog so let me please ask Autoblog's developer. Please keep an eye on this thread and I'll let you know once I only get the response.

    Best regards,
    Adam

  • Oliver

    Thanks Adam, You are right, if the imported stream posts are all in a 'facebook' category then the process is easy enough to filter on.

    Is there an easier/better way of autoposting Facebook posts to WordPress without the use of Zapier? E.g. access the FB API directly? Do other website owners even do this as part of their marketing mix?

    I know there are various widget plugins but I'm after something that can actually create posts on the website from a facebook stream - otherwise there is no point in having a blog section on the site

    The client is more used to posting updates to facebook than wordpress (actually, they didn't have the ability to add blog posts/updates to their website before I re-did it)

  • Adam Czajczyk

    Hello Olivier!

    Personally, I never came across sites fetching posts from FB to WP blog, usually it's the other way around. On the other hand, I haven't seen all the pages around the web yet :smiley:

    I see though that apparently there is a couple of plugins available that seem to be doing similar job. Take a look please:

    https://wordpress.org/plugins/recent-facebook-posts/

    https://wordpress.org/plugins/wp-fb-feeds/

    These plugins don't create posts and just display FB statuses in a widget or via a shortcode but this one claims to "import posts from FB to WP blog":

    https://wordpress.org/plugins/egany-facebook-to-wp/

    I didn't test any of above plugins though so you may want to check them by yourself. As for our own Autoblog, I'll let you know once I only get a replay from the developer. Please note however that this may take a bit longer than it takes me to respond here on support forum as developers are quite busy with various complex issues.

    Best regards,
    Adam

  • Dimitris

    Hey there Oliver,

    I trust you're doing good today and don't mind chiming in! :slight_smile:

    Perhaps I need to educate them a little on using WordPress and how as a tool it can be at the center of their social marketing?

    That's the spirit here! :slight_smile:

    Feel free to use our tutorial videos for that https://premium.wpmudev.org/projects/category/videos/

    These can also be used inside your WP installation with the Integrated Video Tutorials plugin https://premium.wpmudev.org/project/unbranded-video-tutorials/

    Warm regards,
    Dimitris

  • Adam Czajczyk

    Hello Olivier!

    Getting back to initial issue, I got a working solution for you for shortening post titles created by Autoblog. Here's the code:

    <?php
    function wpmu_autoblog_shorten_titles( array $data, array $details, SimplePie_Item $item ) {
    	$data['post_title'] = trim( $item->get_title() );
    	$data['post_title'] = substr($data['post_title'],0,5);
    	return $data;
    }	
    
    add_filter( 'autoblog_pre_post_insert', 'wpmu_autoblog_shorten_titles', 11, 3);
    add_filter( 'autoblog_pre_post_update', 'wpmu_autoblog_shorten_titles', 11, 3);

    To apply it to your site:

    - create an empty file with a .php extension (e.g. "autoblog-short-titles.php");
    - paste the code above into this file
    - upload the file to your server to the "/wp-content/mu-plugins" folder; if there's no "/mu-plugins" folder inside "/wp-content" just create it.

    As for the code. You will want to tweak it a little bit so here's how:

    1. To set the length of the title edit this line:

    $data['post_title'] = substr($data['post_title'],0,5);

    Replace "5" value with your preferred maximum length of title; it's currently set to five characters only so it's definitely to short but I set it this way for testing purpose. The "0" value should stay intact.

    2. To add additional string to the title, e.g. three dots/full stops (...) edit the same line like this:

    $data['post_title'] = substr($data['post_title'],0,5) . '...';

    3. The code should affect both newly added posts and posts that were updated by autoblog (if you are using that feature); by removing the last line of the code you can make it affect only newly inserted posts.

    I hope that helps!

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.