Thread Starter
Mikel
(@ogmic)
So, that means I can create the file anywhere?… Cos I don’t have a child theme
You can place it anywhere really, as long at your php file has permissions set to 755, and you can access the wp-load.php file which is referenced in the script.
Thread Starter
Mikel
(@ogmic)
Thanks so so much. I will update you
Thread Starter
Mikel
(@ogmic)
@corrinarusso Hi, I got this in my mail;
X-Powered-By: PHP/7.4.6
Set-Cookie: PHPSESSID=b1c8eeb08dac888059dec24224ce4d14; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
X-LiteSpeed-Cache-Control: no-cache
Content-type: text/html; charset=UTF-8
Thread Starter
Mikel
(@ogmic)
What does it mean… I set the Cron job to run every 5mins just to be sure, and I got that mail after 5mins, the post were not moved either
That’s not from my script, that’s from LightSpeed :
X-LiteSpeed-Cache-Control: no-cache
You should really turn your cache off while testing.
Thread Starter
Mikel
(@ogmic)
I have deactivated the LiteSpeed Cache plugin, will wait for the next 5mins
Thread Starter
Mikel
(@ogmic)
@corrinarusso Here is what I got;
X-Powered-By: PHP/7.4.6
Set-Cookie: PHPSESSID=bc5f8ed5bbfbe6147eadcc423a737f7e; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-type: text/html; charset=UTF-8
No post was moved too
Can you post the content of the script file back into here pls?
Also – again this is coming from your nocache header :
https://www.php.net/manual/en/function.session-cache-limiter.php
The expiry date is listed as :
Expires: Thu, 19 Nov 1981 08:52:00 GMT
which is a nod to a php developer.
You’ll need to post your code, as well as a screenshot of the cron, as well as that you changed the php file to have 755 permissions.
Thread Starter
Mikel
(@ogmic)
I saw this in the error_log file;
Connection refused.
Thread Starter
Mikel
(@ogmic)
Here is my code
<?php
// change the path to your wp-load.php file
require_once('/home/surepayf/public_html/wp-load.php');
//$output = shell_exec('wp post list --category_name="FREE CONTENT" --format=ids 2>1&');
//echo $output."\n";
global $wpdb;
$oldCatSlug = 'free-content';
$newCatSlug = 248; // you need to insert an integer here that matches your SPECIAL category
$category = get_category_by_slug( $oldCatSlug );
if ( $category ) {
$posts = get_posts( array(
'numberposts' => -1,
'category_name' => 'FREE CONTENT',
)
);
if ( $posts ) {
foreach ( $posts as $post ) {
// update categories the match FREE
// see https://codex.wordpress.org/Function_Reference/wp_set_post_categories
wp_set_post_categories( $post->ID, $newCatSlug, false ); // set this to true if you want this category appended
}
}
}
?>