Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For a one-time fix, you might consider an SQL solution. Some assumptions with the following SQL:</p> <ul> <li>There is only ONE iframe per post to be replaced (the SQL can be run multiple times if there are posts with more than one iframe).</li> <li>The iframes to be replaced ALL are in the form:</li> </ul> <p><code>&lt;iframe src="https://w.soundcloud.com/player/?url="..." other-stuff&lt;/iframe&gt;</code></p> <ul> <li>All you care about is what's between the quotes for the url parameter</li> <li>The end result is [soundcloud url="..."]</li> </ul> <p>If all of this is true, then the following SQL should do the trick. It can be tweaked if you want a different shortcode, etc.</p> <p>Be sure to backup your wp_posts table before performing ANY mass update.</p> <pre><code>CREATE TABLE wp_posts_backup SELECT * FROM wp_posts ; </code></pre> <p>Once the backup is complete, the following SQL should fix all of your posts in a single shot:</p> <pre><code>UPDATE wp_posts p SET p.post_content = CONCAT( SUBSTRING_INDEX( p.post_content, '&lt;iframe src="https://w.soundcloud.com/player/?url=', 1 ) ,'[soundcloud url="' , REPLACE( REPLACE( SUBSTRING_INDEX( SUBSTR( p.post_content , LOCATE( '&lt;iframe src="https://w.soundcloud.com/player/?url=', p.post_content ) + 50 ) , '&amp;amp;', 1 ) , '%3A', ':' ), '%2F', '/' ) ,'?' ,SUBSTRING_INDEX( SUBSTR( p.post_content , LOCATE( '&lt;iframe src="https://w.soundcloud.com/player/?url=', p.post_content ) + 50 + LOCATE( '&amp;amp;', SUBSTR( p.post_content , LOCATE( '&lt;iframe src="https://w.soundcloud.com/player/?url=', p.post_content ) + 50 ) ) + 4 ) , ' ', 1 ) ,']' ,SUBSTR( p.post_content, LOCATE( '&lt;/iframe&gt;', p.post_content ) + 9 ) ) WHERE p.post_content LIKE '%&lt;iframe src="https://w.soundcloud.com/player/?url=%&lt;/iframe&gt;%' ; </code></pre> <p>I would suggest you TEST a few posts before running this against all of them. An easy way to test would be to add the following to the WHERE clause above (immediately before ';') changing '?' to the Post ID(s) to be tested.</p> <pre><code>AND p.ID IN (?,?,?) </code></pre> <p>If for any reason you need to restore your posts, you can do something like:</p> <pre><code>UPDATE wp_posts p JOIN wp_posts_backup b ON b.ID = p.ID SET p.post_content = b.post_content ; </code></pre> <p>One other thing to consider. I wasn't sure if you wanted to pass on the parameters that are currently a part of the url, so I included them. You can easily remove them by changing:</p> <pre><code> ,'?' ,SUBSTRING_INDEX( SUBSTR( p.post_content , LOCATE( '&lt;iframe src="https://w.soundcloud.com/player/?url=', p.post_content ) + 50 + LOCATE( '&amp;amp;', SUBSTR( p.post_content , LOCATE( '&lt;iframe src="https://w.soundcloud.com/player/?url=', p.post_content ) + 50 ) ) + 4 ) , ' ', 1 ) ,']' </code></pre> <p>to:</p> <pre><code> ,'"]' </code></pre> <p>resulting in:</p> <pre><code>UPDATE wp_posts p SET p.post_content = CONCAT( SUBSTRING_INDEX( p.post_content, '&lt;iframe src="https://w.soundcloud.com/player/?url=', 1 ) ,'[soundcloud url="' , REPLACE( REPLACE( SUBSTRING_INDEX( SUBSTR( p.post_content , LOCATE( '&lt;iframe src="https://w.soundcloud.com/player/?url=', p.post_content ) + 50 ) , '&amp;amp;', 1 ) , '%3A', ':' ), '%2F', '/' ) ,'"]' ,SUBSTR( p.post_content, LOCATE( '&lt;/iframe&gt;', p.post_content ) + 9 ) ) WHERE p.post_content LIKE '%&lt;iframe src="https://w.soundcloud.com/player/?url=%&lt;/iframe&gt;%' ; </code></pre> <p><strong>Updated to allow for no parameters in the url</strong></p> <pre><code>UPDATE wp_posts p SET p.post_content = CONCAT( SUBSTRING_INDEX( p.post_content, '&lt;iframe src="https://w.soundcloud.com/player/?url=', 1 ) ,'[soundcloud url="' , REPLACE( REPLACE( SUBSTRING_INDEX( SUBSTRING_INDEX( SUBSTR( p.post_content , LOCATE( '&lt;iframe src="https://w.soundcloud.com/player/?url=', p.post_content ) + 50 ) , '&amp;amp;', 1 ) , '"', 1 ) , '%3A', ':' ), '%2F', '/' ) ,'"]' ,SUBSTR( p.post_content, LOCATE( '&lt;/iframe&gt;', p.post_content ) + 9 ) ) WHERE p.post_content LIKE '%&lt;iframe src="https://w.soundcloud.com/player/?url=%&lt;/iframe&gt;%' ; </code></pre> <p>Good luck.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload