Forums

SQL query to change post category (3 posts)

  1. jbjweb
    Member
    Posted 3 years ago #

    Hi guys,

    I'm looking for the SQL query to execute in order to move a post from a category to another.

    Exemple: Post is in category "Fresh". After 5 days, the post is moved in category "Archive".

    Any help will be very appreciated. Thanks in advance!

  2. jbjweb
    Member
    Posted 3 years ago #

    bump!

  3. Spamboy
    Member
    Posted 3 years ago #

    I didn't know the SQL, but I created a simple plugin that dumps a SQL trace to the screen whenever you edit a post. You could use this dump to pull the SQL statements you need:

    <?php
    /*
    Plugin Name: Spamboy SQL Trace
    Plugin URI: http://www.spamboy.com/
    Version: 0.1
    Author:	<a href="http://www.spamboy.com/">Spamboy</a>
    Description: Description goes here
    */
    
    // Functions
    function sb_sql_trace($post_ID) {
    	global $wpdb;
    
    	$sb_filename= '../SQL_trace_' . date("Ymd_His") . '.txt';
    	$sb_file = fopen($sb_filename, 'w') or die("can't open file");
    
    	if(SAVEQUERIES) {
    		foreach($wpdb->queries as $sb_query){
    			$stringData = $sb_query[0] . "\n\n";
    			fwrite($sb_file, $stringData);
    		}
    	}
    
    	fclose($sb_file);
    
    }
    
    // Actions
    add_action('edit_post', 'sb_sql_trace');
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.