SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard masm50's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    2,508
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    preg_replace for MySQL?

    I've built a Wordpress site up with thousands of posts where I've inserted images using the traditional method into the post content itself.


    I'm now moved to a different theme, and have made the first image for each post the featured image (which I want to keep), but I now would like to remove the first image from the_content.


    I have found that I can remove the first image (with or without captions) on the fly by instead of using the_content(), doing this:


    PHP Code:
    echo preg_replace("/\[caption .+?\[\/caption\]|\< *[img][^\>]*[.]*\>/i","",get_the_content(),1); 


    Is there some way I can run this command on the database to actually remove those images?


    Thanks for any pointers

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    there's nothing like that in mysql, you'll have to do it with php
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard masm50's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    2,508
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I thought as much - thanks for the reply!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •