Forums

[resolved] Database Hackery (2 posts)

  1. gregorsmith
    Member
    Posted 1 year ago #

    OK, how best to phrase this, I'm needing a way to select posts from a certain category then quickly mass replace the post excerpt using the post content.

    I figured this would be relatively easy in MySQL and I was able to fill in blank excerpts using a quick:

    UPDATE wp_posts
    SET post_excerpt = post_content
    WHERE post_excerpt IS NULL OR post_excerpt = ''

    But since the old post_category column in wp_posts isn't being used finding a way to pull the post id, post_content and post_excerpt information from wp_posts, the object_id and term_taxonomy_id info from the wp_term_relationships tables and replacing the post_excerpt with the post_content if a term_taxonomy_id is 3 is proving to be more difficult than I first imagined.

    Can anyone think of a SQL query that might pull this off?

  2. gregorsmith
    Member
    Posted 1 year ago #

    Resolved, I used this query in case anyone else has this specific issue

    update wp_posts p
    set p.post_excerpt = p.post_content
    where p.ID in (select tr.object_id
    from wp_term_relationships tr
    where tr.object_id = p.ID
    and tr.term_taxonomy_id = 3)
    ;

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.