• I’m using Postie post articles via email from my Google Reader. Still in the testing stages, but it works just as I want, except Google Reader sends off some stuff I don’t want in my posts… and Postie, to the best I can tell, doesn’t let me remove parts of the post (that I can tell).

    I’d like to setup a query to run as a cron after importing articles that goes through wp_posts, looks for the following and replaces it with nothing. I’m pretty low on the knowing what the heck I’m doing totem pole, so any help/advice/suggestions would be apprecaited.

    <br /><br /> <div style="margin: 0px 2px; padding-top: 1px;    background-color: #c3d9ff; font-size: 1px !important;    line-height: 0px !important;">&nbsp;</div> <div style="margin: 0px 1px; padding-top: 1px;    background-color: #c3d9ff; font-size: 1px !important;    line-height: 0px !important;">&nbsp;</div> <div style="padding: 4px; background-color: #c3d9ff;"><h3 style="margin:0px 3px;font-family:sans-serif">Sent to you by Savage702 via Google Reader:</h3></div> <div style="margin: 0px 1px; padding-top: 1px;    background-color: #c3d9ff; font-size: 1px !important;    line-height: 0px !important;">&nbsp;</div> <div style="margin: 0px 2px; padding-top: 1px;    background-color: #c3d9ff; font-size: 1px !important;    line-height: 0px !important;">&nbsp;</div>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Do you want to use wp_cron, or can you set up a traditional cron job on your server? Do you know how to do that part?

    Is the text you’re replacing always this exact text?

    Thread Starter Savage702

    (@savage702)

    It doesn’t really matter. I’ve never actually used wp-cron, but If it gives any advantage, I’m all for it.

    As for being the same, there are two parts I’d be removing, the part I posted is static, the other would be the same all the way through except for a different link each time, which I think I know how to wildcard that out.

    Well, you could take a couple of different routes – I suppose the easiest would be to run a normal cron job calling a php script, open a connection to the database and read in all the posts (or if you wanted to get clever, read only posts from that day, or however often you want to run the cron), and then use the php replace() or preg_replace() (if you need to use a wildcard to get htat link out) function to get rid of the text you’re after, then update the rows with the new post content.

    The other way you could do it is just to do the entire find/replace within your mysql call, so you only have 1 query per post that you’re updating (you can see the syntax for that here).

    If you need more help with the specific code, I could whip something up.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom SQL Query’ is closed to new replies.