Quantcast
Channel: WordPress.org Forums » [Sermon Manager] Support
Viewing all articles
Browse latest Browse all 1331

Migration of blog posts to Sermon Manager

$
0
0

Replies: 1

My church currently just use normal WordPress blog posts to manage their blog posts. This is fine to a point except that it doesn’t really allow a lot of flexibility in parsing out preachers, audio files, notes, resources etc. So I installed sermon manager.

The problem I found with sermon manager is that it doesn’t seem to be able to import sermons from normal wordpress blog posts. I’m not sure why this might be, however – I wrote a few SQL queries to address this and figured it might help some of you on here too. This only works by the way if you keep your sermons in a single category away from normal blog posts. If not, then you might want to go and do that before running this SQL.

Obviously before you run arbitrary SQL on your live production server you should test it on a staging or dev server somewhere else first.


# Update posts to sermons

UPDATE wp_posts AS p
        LEFT JOIN
    wp_term_relationships AS r ON p.ID = r.object_id 
SET 
    p.post_type = 'wpfc_sermon'
WHERE
    r.term_taxonomy_id = 4;

# Insert sermon text    
INSERT INTO wp_postmeta (<code>post_id</code>, <code>meta_key</code>, <code>meta_value</code>)
SELECT <code>p</code>.<code>ID</code>, 'sermon_description', <code>p</code>.<code>post_content</code> FROM wp_posts p
LEFT JOIN wp_term_relationships AS r ON p.ID = r.object_id
WHERE r.term_taxonomy_id = 4;

# Insert sermon date
INSERT INTO wp_postmeta (<code>post_id</code>, <code>meta_key</code>, <code>meta_value</code>)
SELECT <code>p</code>.<code>ID</code>, 'sermon_date', unix_timestamp(<code>p</code>.<code>post_date</code>) FROM wp_posts p
LEFT JOIN wp_term_relationships AS r ON p.ID = r.object_id
WHERE r.term_taxonomy_id = 4;

SET SQL_SAFE_UPDATES = 0;

# Update the post tags to be sermon tags
UPDATE wp_terms t
        LEFT JOIN
    wp_term_taxonomy tt ON t.term_id = tt.term_id
        LEFT JOIN
    wp_term_relationships tr ON tt.term_taxonomy_id = tr.term_taxonomy_id
        LEFT JOIN
    wp_posts p ON tr.object_id = p.ID 
SET 
    tt.taxonomy = 'wpfc_sermon_topics'
WHERE
    p.post_type = 'wpfc_sermon';
SET SQL_SAFE_UPDATES = 1;
  • This topic was modified 12 hours, 28 minutes ago by lenswipe.
  • This topic was modified 12 hours, 28 minutes ago by lenswipe.
  • This topic was modified 12 hours, 26 minutes ago by lenswipe.
  • This topic was modified 12 hours, 22 minutes ago by lenswipe.

Viewing all articles
Browse latest Browse all 1331

Trending Articles