Yoast SEO and Facebook Open Graph Page Title

It’s a recent news: Facebook does not allo anymore to change the title and description of a shared link. This is a bad news for who is used to change the title directly while sharing.

Probably Facebook is focusing in having only one source of information for a shared page, the page itself, to avoid misleading shares where the title of the page is changed to something totally different. Or just to make it easy for Facebook to rescrap and update the shared information.

With Yoast SEO plugin you can change the meta title for Facebook directly in the post but the only thing I’m interested on is to remove the postfix in the title with the site name. Doing this for each post would be impossible, too much work.

And Yoast SEO has not an option where to set the template for the Facebook meta title as for the general meta title.

Anyway there is a simple solution: filtering automatically the generated og:title metatag and remove the postfix, if present.

Few lines of code are required:

The code add a filter to the WordPress SEO generated meta title for Facebook, search the configured separator from the end of the string and remove the postfix. The coude should be enough safe and can be easily added to the functions.php file of your child theme.

If you need a plugin to incorporate this code in your blog, let me know.

Donations From January 2017 To June 2017

Dear friends, dear supporters, the latest six months were fantastic and we collected 370 € that I have already donated to humanitarian organizations.

  • 150 € to Save the Children
  • 120 € to MSF

A little drop of water in this desert of humanitarians needs to prepare a better World for our children.

Thank you, Stefano.

Include Me Version 1.1.5 Released

Long time since the last release, but there were not issues to correct… 🙂

Anyway, this new release of Include Me adds a nice feature: the ability to include another post content.

It may sound odd, but recently I faced a problem on a blog: an important piece of content needs to be added at the end of a number of selected pages. Since the blog was already using Include Me, we had the idea to put the common content in a page (unpublished) and then include that content in other pages.

There are many the ways to do that, but it was a very simply change on Include Me and that change saved us to install other plugins.

You can read more in the plugin documentation page.

The Question To Ask To WordPress Plugin Developers

If you’re in the way to hire a freelance, ask him that question before to decide to work with him:

We need to add few features to a public plugin ([here the plugin name]). Is it possible and safe to customize a public plugin?

He should respond:

  1. if the plugin provides point of extensions (WordPress actions and filters) I can write a plugin which enhance the public one
  2. if the plugin DOES not provide point of extension I need to change the code of the plugin, playing directly on the plugin files inside the plugin folder BUT you MUST NEVER update the plugin since WordPress delete everything before installing a new version (and my customization will be lost)

Why a post for a so obvious thing?

Because there are people which come to me desperate because they lost a custom theme, paid to someone, after a Newsletter plugin update. The developer created the theme adding or changing files of Newsletter. Of course on update everything is reset.

A developer who works with WordPress MUST know that behavior and work in a different way. WordPress has the concept of action and filter, widely used by plugins to let other to extend thair functionalities. Newsletter, for example, is able to search themes in a different folder which is not touched on updated (and documented in the documentation pages).

Please, ask the above question to a developer before starting to work with him or only a backup can save you.

Stop To Choose Your WordPress Theme in That Way!

When you setup a new blog, the first thing you do is to choose a theme. And you surf between all those wonderful screenshots to find the one which best match your needs.

This is the wrong way.

The screenshots are almost all taken from a desktop version of that theme. And yes, they are fantastic.

But your audience is using a phone to surf your site anf the first thing you should test with a theme is: “how does it performs on mobile?”. If it is less than perfect on mobile, discard it (or take in account to do some work).


This screenshot is from a site where the author asked to put up a new free theme. It is a very nice and free theme that worked ut of the box (as you can see there is still no header logo and the screenshot is missing the nice article grid after the main post).

But we need to test it on mobile. We use the Chrome developer console and we get this, for an iPhone 6 viewport:

Actually it could be ok, but we’re wasting a lot of space saying “hey, we are Insegnare e Imparare”. Is it worth to consume all that area for our name? Probably not. Probably we can remove it at all.

Playing with CSS (so without creating a child theme, but only adding few rules in the custom CSS configuration provided by the theme), I removed the top title. Now we have a really different user experience: a beautiful image, the article title and the top part of the article body.

Even Google, which asks to have the relevant content “above the fold” will be more happy!

Ok, it’s better, but we still want our name there. We can reintroduce it but with a smaller font, always plaing with CSS:

Now there is room for our narcissism and content for the reader. Even the main article title could be reduced, and always just playing with CSS.


Always test your theme for mobile. Don’t worry about the desktop version, you’ll find a combination of layout and options to make it good. But the mobile version is harder to adjust.

There is still the habit to build theme starting from the desktop version, because this is the first version people see. But the real value of a theme is the mobile version, if it is quick to load and render, optimized to deliver the content to the reader.

How To Draw Effectively In a Whiteboard

I’m a fan of physical meetings, when possible, looking my collaborators into their eyes and sketch and discuss with them ideas, features, issues.

Drawing on a piece of paper or on a whiteboard is of incredibly help to explain others what’s in my mind and it makes the picture clearer to everyone. A draw is worth thousands of words, and taking two minutes to make a sketch can save several minutes of discussion and repetitions.

But I’m disaster when is time to use a pen and outline a figure on paper. I discovered today there are many techniques that helps even people like me to draw something enough clearly to be understandable to everyone. Those techniques uses a small number of shapes which is easily to learn to draw.

Here a fantastic video to start with the 7 elements that facilitate your whiteboard drawing sessions.

Thumbnails 1.0.7 With a Couple of New Options

Thumbnails is a light plugin which helps your theme to generate thumbnails. Most of the thumbnails can be generated on the fly and stored in a cache folder, instead to full fill your upload folder. More, you change theme and the thumbs sizes changes you can be in trouble with old images.

With Thumbnails there is no more problems.

The new feature are the persistent autowired featured image which really improve the performances of the older versions and the ability to process images for the core sizes (limited to the thumbnail size of WordPress).

Header and Footer With AMP Support

Was time for a review of Header and Footer, the plugin many of you use to inject codes in the head, footer and middle of the posts and pages. The most common injections are:

  • Google Analytics, specially with customizations
  • Facebook Pixel
  • AdSense
  • Verification metatags

The new version removes the Open Graph minimal support since that protocol is now complex and needs a dedicated plugin. The bbPress support will be removed in the near future, so the plugin is lighter for who does not use bbPress and for who uses bbPress I released a more interesting and complete Ads for bbPress plugin.

AdSense for bbPress

Injecting ads on bbPress pages is now really easy with Ads for bbPress.

This new free plugin can inject, like Header and Footer whatever code you need before and after the bbPress pages not not only. It can inject between topic and replies and before the new topic and new reply form.

A must have for everyone running bbPress.

And it’s ultra light: the best practices have been used to load the blog as less as possible.

Find it on WordPress here.

Use get_option() Only Once, As Late As Possible and Store It

I see many plugins to get their options (one or more) with the super useful get_option() of WordPress not only once but every time they needed it and sometime more than once inside the same function.

This is definitively not good for performances. Let me explain why.

Admitting your options are “autoloaded”, your get_option() does not trigger a query to the database but every time you call it:

  • the option name is trimmed
  • the filter “pre_option_nnn” is called
  • the list of missing option is taken from the cache and checked
  • the list of autoloaded options is checked (probably creating a big array copy)
  • the option name is checked against ‘siteurl’, ‘home’, ‘category_base’, ‘tag_base’ special names
  • the maybe_unserialized is called over your option value
  • the filter “option_nnn” is applied

Reference: the options.php file of WordPress.

Every step is taken every time you call get_option(). It’s time to optimize that!

How to optimize the get_option() call?

First, use it as late as possible. Why? Suppose you created a plugin which just runs a shortcode. If that shortcode depends on a set of options but it is rarely used, why to run code which is not required?

To optimize the options load you can code it in this why (my example uses functions to be easy, but you should always wrap the code in a class). I assume you save all the options in an array (WordPress takes care to serialize and unserialize it).

As you can not the options are not returned by “my_init_options()” to avoid an array copy and because they anyway are global. Using a class and an internal property for your options makes the code less “dirty” and less “old style”. Optimized code most of the times is not elegant.

Let start the discussion, now!