Long URL's on Autoblog

Working on optimizing SEO and I have a lot of long URL links from my autoblog. I need to have an automatic way to shorten slugs. Is it possible?

This is a good example:


  • Adam Czajczyk
    • Support Gorilla

    Hi richard

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

    URLs (or rather “slugs” ) for Autoblog-imported content are not created directly by Autoblog. Autoblog simply creates a regular post out of the fetched feed items and uses core WP routines to post it. Therefore the URL structure depends directly on the permalinks setting of your site – in this case they are created out of post title, which – in case of Autoblog – is a title of a feed item.

    What could be done here would be to actually adjust these slugs: plugin fetches the feed and processes it -> an item is processed -> item is saved as post -> now update the slug(shorten it).

    This could be done with an additional code snippet:


    function autoblog_trim_post_slug( $post_id ) {

    $slug = get_post_field( 'post_name', $post_id );

    // trim/shorten $slug here,
    //for example let's cut it to max of 30 characters if it's longer

    if ( strlen( $slug ) > 30 ) {
    $slug = substr( $slug, 0, 30);

    $updated_post = array (
    'ID' => $post_id,
    'post_name' => $slug

    wp_update_post( $updated_post );


    add_action( 'autoblog_post_post_insert', 'autoblog_trim_post_slug', 2, 1 );

    This code is fired right after the Autoblog adds a post and immediately does this:

    – checks the post slug length

    – if it’s longer than 30 characters it trims it to exactly 30 characters and updates.

    Of course, you can make them even shorter by simply replacing the 30 value in lines 10 and 11 (they should be the same). You can also expand this code to adjust/alter URLs in other ways, if you wish.

    To apply the code to your site:

    – create an empty file with a .php extension (e.g. “autoblog-trim-post-slugs.php”:wink:

    – copy the code from above and paste it into that file

    – optionally, make any necessary adjustments to the code

    – save the file and upload it to the “/wp-content/mu-plugins” folder of your site install; if there’s no “mu-plugins” folder right inside the “wp-content” folder, just create an empty one.

    Please note: this will only affect feed items imported after the code was added. Those that were already created would have to be adjusted manually by editing the posts in WP back-end and changing their slugs there.

    Best regards,


  • richard
    • WPMU DEV Initiate

    It would be great to include this as a new ‘SEO’ module within Autoblog. Items that could be added could include:

    1) trim the slug (see above)

    2) trim the page title

    3) add a meta description to the post

    4) add a focus keyword to the post (you could you the primary tag that Autoblog imports

    Together these would solve many of the SEO issues generated with the use of Autoblog.

    Best wishes,


  • Adam Czajczyk
    • Support Gorilla

    Hi richard

    I’ve tested it on my own setup with Autoblog before sharing to make sure that it works. However, it’s been created (and tested) using pretty much “bare” WordPress install with just Autoblog plugin and Twenty Seventeen theme.

    Often it’s that the theme or some other plugin is also filtering/manipulating things like posts titles, slugs or content so that might need some additional tweaking. Another option is that for some reason the code is not properly executed on your site. I’ll need to check it but let’s start with the very basic:

    – can you confirm that the code “as is” was added as mu-plugin? It’s important to put it into a file with .php extension and put that file into the “/wp-content/mu-plugins” folder of the WordPress install (it shouldn’t be “/wp-content/plugins” or “/wp-content/plugins/mu-plugins”!)

    – did you make any change whatsoever to the code that I shared? If yes, what change that was (could you share modified code if so)?

    If you didn’t make any changes to the code and the code was indeed added as mu-plugin, I’d need to take a closer look so please confirm that and in such case please enable support access to the site so I could check it. To enable support access: go to the “Network Admin -> WPMU DEV -> Support” page, click on “Grant support access” button there and let me know here once it’s done.

    Best regards,


  • Adam Czajczyk
    • Support Gorilla

    Hi richard

    Thank you for enabling access.

    I checked the site (I didn’t make any changes there whatsoever) and I see it’s very complex.

    The setup seems to be very precisely configured with lot of plugins and some custom code snippets and while I don’t see anything that would be “obvious” possible reason that could cause my code not to work there, I’m still thinking that this is most likely related to the site’s specifics.

    Since it’s a complex live site, I believe that you’d rather avoid a full conflict test so I’d like to ask you for one other small test instead. Since it’s a multisite, could you please:

    – create (just for testing) and additional sub-site on your setup; making sure that there’s only some core theme enabled such as Twenty Seventeen and as little plugins as only possible – apart from Autoblog

    – then add some feed to that site and see how it processes these URLs?

    The point here is to see if the same happens on a “clean” site on this specific installation or not. Would you please give it a try and let me know about results? I’m pretty sure we’ll find the way to make it work but we first need to find out why it’s not working in the first place :wink:

    Best regards,


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.