• jbjweb

    (@jbjweb)


    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jbjweb

    (@jbjweb)

    bump!

    Spamboy

    (@spamboy)

    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: https://www.spamboy.com/
    Version: 0.1
    Author:	<a href="https://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');
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘SQL query to change post category’ is closed to new replies.