• Home  / 
    • Mom
    •  /  How to remove strange Mediavine Artifacts from your posts

    How to remove strange Mediavine Artifacts from your posts

    By Lisa / October 11, 2018
    Slow site speed due ad codes

    How to remove strange Mediavine ad artifacts in posts


    ​After successfully starting and growing your Mommy Blog, you might start monetizing it with ad services such as Mediavine. If you're a member of the Mediavine family, you know how wonderful it is to be part of this network. There are numerous posts and reviews on the internet detailing how much Mediavine has changed lives and made blogging a profitable endeavor. Being with Mediavine is great when things run well on your site but what about when you run into some hiccups? Well, I'd like to add my 2 cents on this topic.

    Over the past week, we noticed that our site started showing some strange Mediavine artifacts e.g. extra Mediavine icons, extra blank spaces which normally host Mediavine ads, extra "Report this ad" notices.

    The Problem​

    sample of extra mediavine logos and blank spaces

    Something was not quite right. After a bit of investigation, and a quick email to Mediavine, it turns out that an undocumented incompatibility exist with Thrive theme's Thrive Content Builder Editor.

    I am aware that Mediavine is not compatible with Thrive Architect, and as a result I never updated my WordPress Thrive Theme to Thrive Architect. ​However little did I know, Thrive Content Builder also has incompatibilities with Mediavine.

    thrive content builder with ads showing in editor

    Thrive Content Builder showing ads in editor.

    It turns out that every time I edited a post with Thrive Content Builder, Mediavine would run ads in the T​CB Editor resulting in some hidden scripts and codes being added to your post when you hit save!

    show code button on thrive content builder

    Click the show code button on Thrive Content Builder to see rogue mediavine ad codes

    Clicking on the show code button will reveal all the rogue codes in a light box.

    light box showing html code to your post

    Thrive Content Builder show code Light Box

    The highlighted "waypoint" code is the code snippet that the Mediavine plugin inserts into your post while displaying ads. When you hit "Save", this code gets stored as part of your post. And each time that you make a change to your post while ads are shown in the Thrive Content Builder Editor, another copy of the code snippet gets saved in your post. You can see where this is going right?

    Mediavine Custom Plugin​

    ​After an email to a Mediavine Engineer, they came back saying that they have a custom plugin to stop ads from being displayed while using the Thrive Content Builder Editor. From our conversation, it seems that this custom plugin will also solve the incompatibility problem with Thrive Architect.

    mediavine custom plugins for solving ads displaying while editing post

    Mediavine custom plugins to stop ads displaying in editors

    ​After installing the custom plugins, you can happily return to editing and writing your posts as before. However, now comes the hard part. The cleanup!

    If you've added or edited a lot of posts after joining the Mediavine Family - and there's a good chance you did in trying to "Go Teal", ​you have a lot of work ahead of you. 

    I've tried to go back to my posts one by one, wracking my brain to try to remember which posts I edited, but it just seemed too hard.

    So after a bit of trial and error, research on the internet, and a tip from a Mediavine Engineer, I finally arrived at what I deemed to be the best way to clean up these "rogue snippets".

    Phpmyadmin to the rescue

    First things first, before you do anything to your database using phpMyAdmin, BACKUP YOUR DATABASE! You can probably ask your host to perform a database backup for you, or you can do so under phpMyAdmin yourself by exporting the database.

    phpMyAdmin database backup

    Next we need to find out which posts contained the "rogue snippets". After scouring a few posts line by line, it turns out that every "rogue snippet" contains a <div> tag with a label called "...waypoint". This will make our search much easier.

    using SQL query in phpMyAdmin

    How to run an SQL query in phpMyAdmin

    A quick search on the internet on the uses of SQL produced the following code to track down every post with the "rogue snippet".

    This SQL query will list all the posts that have the "rogue snippets" and organize them by "post_id". Looking at the "number of records", will tell you how many posts contain these "rogue snippets".

    SELECT * FROM `wp_postmeta` WHERE `meta_value` LIKE '%waypoint%' GROUP BY post_id

    Please note that because of the "GROUP BY" criteria in the SQL query, the results in the table does not show how many revisions of each contain the "rogue snippets"​. If you recall, we mentioned that each time you hit save, the "rogue snippets" are saved into your post. But WordPress does not just save changes to your post, it stores your post with all the changes as a new database record. So depending on the number of revisions you limit WordPress to and how many times you hit "save" with ads displayed, you may have several database records with these "rogue snippets".

    SELECT * FROM `wp_postmeta` WHERE `meta_value` LIKE '%waypoint%'

    ​Running the SQL query without the GROUP BY post_id will produce a table showing you number of posts and revisions containing the "rogue code snippets".

    To do a thorough cleanse, it is recommended to go through every database record containing "rogue snippets"​ and cleaning it up.

    SQL query showing posts containing rogue code snippet

    Clicking "Edit" on the row will open a window where you can edit the postmeta column directly. This column contains all the underlying html code to your post.

    Using your browser's find function, by hitting "Cmd-F" or "Ctrl-F", find the keyword "waypoint".

    Editing row's meta_value with find function

    On the top of right of the above screenshot you can see the result of the browser find function. In this particular post, it shows 7 places where 'waypoint' label inside <div> tag is found.

    Now from the "waypoint" highlight, work backwards a little, ​and look for the beginning of the <div> tag, and start highlighting from there.

    Looking for the beginning of the rogue code snippet

    Note: sometimes you have to delete a tag that says:

    <div class="remove_padding">

    Remove padding tag also needs to be deleted

    Highlight everything until you come to something that looks like "<div class="thrv_wrapper thrv ..." This is where the "rogue snippet" ends and the Thrive tags begin.

    ​You'll notice that sometimes you have to scroll through a lot of code, and other times, it's just a couple of <div> tags that you have to highlight.

    Sample of small rogue code snippet

    After finding a few rogue code snippets, you'll start recognizing what's good and what's rogue. Hint: While you're highlighting, if you happen to see some legible text with sentences that you may recognize from your post, you've gone too far! Back it up and look for the end of the rogue code snippet further up the post.

    ​Repeat until the find function shows 0 found

    Rinse, and Repeat for the next "waypoint" until the browser find bar says "0 results found". When you've reached this point, you know you've cleaned up the "rogue snippets" from this database entry.

    Now repeat this with all other database entries. Please note, you may have to edit a database entry with the same "Post_id" several times. This is because revisions to a post are stored under the same "Post_id". If you want to see more progress, feel free to leave out the "GROUP BY post_id" in your SQL query. This will then display all records containing the "rogue snippets" and you can work through them one by one, until the table shows no more.

    Browser find function showing "not found". You're all done!

    I hope this guide helps to save you hours of searching and troubleshooting to get your posts cleaned up. The "rogue snippets" cause not only unsightly artifacts but also slow your page down, which can affect your SERP position! 

    Happy "rogue snippet" Hunting!​


    Enter your text here...

    Leave a comment:


    Read more:
    SecondTrimester
    Your Second Trimester of Pregnancy

    Top 5 Best Ice Cube Tray for Baby Food
    Top 5 Best Ice Cube Tray for Baby Food | 2019 Reviews

    Close