Many of us started using new SEO plugin for our WordPress websites. Looks like we have alternative plugin to Yoast finally. Don’t get me wrong, I really enjoyed Yoast but I was sick and tired of their adverts to buy premium… Why premium? Nice options not always must come as paid features. With help comes Rank Math. In short time over 30k+ installations and 5 stars rate.

I’m using Rank Math on all my websites since over a month and I totally love it! It’s super easy to setup (Rank Math can copy your Yoast settings), brilliant backend and what’s more important super easy to use. On top of that all works, Google is happy with the work that Rank Math is doing on my websites.

Rank Math WPBakery Sitemap Fix 2

Sounds like a lovely story. During my tests I actually discovered one nasty thing. Google is not indexing my images. After some checking Armands from A-Fotografy and I have found that none of them were in the sitemap. Blog posts were fine, but 0 images on pages. Pages were done via WPBakery Page Builder. That was the issue – something doesn’t work between WPBakery and Rank Math.

Solution

Thanks to Rank Math awesome support we have a solution! And it’s super simple to apply to everyone who is using WPBakery and Rank Math.

add_filter( 'rank_math/sitemap/urlimages', function( $images, $id ){
    if ( empty( $images ) ) {
        $post = get_post( $id );
        if ( $post && strpos( $post->post_content, '[vc_row' ) !== false ) {
            preg_match_all( '/(?:image|images|ids|include)\=\"([^\"]+)\"/', $post->post_content, $matches );
            foreach ( $matches[1] as $m ) {
                $ids = explode( ',', $m );
                foreach ( $ids as $id ) {
                    if ( (int) $id ) {
                        $images[] = array(
                            'src' => wp_get_attachment_url( $id ),
                            'title' => get_the_title( $id ),
                        );
                    }
                }
            }
        }
    }

    return $images;
}, 10, 2 );

Copy above code as it is and paste it at the end of your functions.php (ideally in child theme so the code remains after update). Thanks to that few lines of code your images on pages done by WPBakery will appear again in sitemap and Google Image Search.

Simple working solution! Enjoy!

Rank Math WPBakery Sitemap Fix 3
5 Shares:
You May Also Like
5 Minute Guide to GDPR for Wedding Photographers 4
Read More

5 Minute Guide to GDPR for Wedding Photographers

It’s almost like it’s 1999 again and the Y2K bug – expect this time you have Facebook and everyone and ramming GDPR compliance at you. In short, the regulations tighten up how businesses are using people’s personal data within the business and introduce greater transparency to how people can see what a company is doing with their personal data.
Complete solution to increase the WordPress Memory Limit 5
Read More

Complete solution to increase the WordPress Memory Limit

We have all seen it at some point. A common error in WordPress is a PHP memory limit error. This happens when WordPress doesn’t have enough memory to achieve what you want. It can be caused by poorly written plugins that will continue to run a procedure until the installation runs out of memory and of course WordPress memory consumption increases with the amount of modifications. Simply the more plugins you install and keep activated , the more memory power your website needs.
SEO for dummies photographers 6
Read More

SEO for dummies photographers

Those blogging on WordPress should be somewhat familiar with WordPress SEO. If you are blogging on WordPress for fun only or you know the basics, then you may want to move on and not read further. However, if you are blogging for money-making purposes, you may want to continue reading here about WordPress SEO.