Massively edit Divi-related HTML tags in posts on new migrated X Pro website

Good day!

I have a massive magazine website I’ve just migrated from Divi to X Pro. I have this in every post, and there’s a bit more than +10,000 :confounded::

Every post has an h3 tag and an entry-title class inside a p tag, all inside blockquote tag.

All this comes from Divi in the old site, where this would make sense I guess.

In order to prevent editors to go crazy editing post by post, how can I fix this?

Huge thanks in advance.

Warm regards.

Hello Alain,

Thanks for writing in!

Is this block added in the Elementor Editor or by using a custom code to be inserted before or after the post content? To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

Regards.

Thanks for the attentive answer @ruenel.

That code is just part of the posts. Back in the old Divi website, editors wrote posts normally using native WP WYSIWYG editor. It was Divi, for reasons I don’t know, that apply all this… styles? Anyway, everything passed on to this X-Pro-based website once I did the migration.

Here I check every post in WP WYSIWYG and they seems normal, and when I see any article online it has those big chunk of text. And it’s when I check HTML tab in post editor that I see all that garbage code.

How can I get rid of all that? This is driving me crazy, I must say :pensive:

Thanks in advance!

PS: In the secure note I’ve shared with you my staging site URL, and credentials in case you need to enter.

Hey Alain,

The password is incorrect.
Please double-check it.

Thanks.

Check again.

Thanks.

Hello Alain,

I have checked your post and I am seeing this:

The element was added within the post content. There is no way you can batch edit this one within Pro editor. What you can do is to use a Search and Replace plugin.

You will have to do advanced search with REGEX link in this documentation: https://searchregex.com/support/regular-expression/

<blockquote>
<h3>Te sugerimos</h3>
<p class="entry-title"><a href="https://eltoque.com/ser-un-padre-responsable-y-con-derechos/" target="_blank" rel="noopener noreferrer" style="outline: none;"><strong>SER UN PADRE RESPONSABLE Y CON DERECHOS</strong></a></p>
</blockquote>

And then replace it with your custom contents. Be advised that this request is beyond the scope of our support. You may need to contact a 3rd party developer to give you further assistance.

Thank you.

For the sake of anyone who may encounter this problem in the future, I’ll put the solution here:

I defined the matching regular expression (PCRE-compatible):

~<blockquote>\s*(.+?)<p class="entry-title">(.+?)<\/blockquote>~s

You can see it live at RegExr. Click “Explain” to understand the expression.

Then the replacement:

\1<p>\2

Then, here’s a test block with added surrounding content:

<blockquote>
<h3>Te sugerimos</h3>
<p class="entry-title"><a href="https://example.com/post-title/" target="_blank" rel="noopener noreferrer" style="outline: none;"><strong>POST TITLE</strong></a></p>
</blockquote>
<p>Other stuff</p>
<blockquote>Not matched</blockquote>

When the regex above is applied, for example as in preg_replace($pattern, $replace, $content), the above block transforms into:

<h3>Te sugerimos</h3>
<p><a href="https://example.com/post-title/" target="_blank" rel="noopener noreferrer" style="outline: none;"><strong>POST TITLE</strong></a></p>

<p>Other stuff</p>
<blockquote>Not matched</blockquote>

Which I the desired output.

To apply all this to the content there’s three basic options:

  1. Use MySQL’s REGEXP_REPLACE function – whether in terminal, in PHPMyAdmin, or from a PHP script. Check How to do a regular expression replace in MySQL? for usage examples, then match to your database structure.
  2. Handle the cleanup in PHP: Run a select query for all posts with this pattern; then modify content with preg_replace. Finally update the database entries.
  3. Download a database dump, open it up in your favorite text editor (with regex support), or pipe it into your tool of choice, and do the necessary replacements; finally reload into your database.

Whichever way you choose to do this, be sure to backup your data first.

Thanks.

Thanks for sharing the solution, Alain.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.