Title: Need help with a code
Last modified: June 11, 2020

---

# Need help with a code

 *  [Mikel](https://wordpress.org/support/users/ogmic/)
 * (@ogmic)
 * [6 years ago](https://wordpress.org/support/topic/need-help-with-a-code/)
 * Can anyone help with a custom hook/code to auto change the post in a category
   to another category every day at exactly 12:00AM.
 * I have three categories ( general, special, free )… I have contents with this
   categories; general & free. So I want any post in the FREE category to change
   automatically to SPECIAL 12:00AM Daily. So I will have the post in General + 
   SPECIAL category.
    -  This topic was modified 6 years ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
      Reason: Moved to Fixing WordPress, this is not an Everything else WordPress
      topic

Viewing 14 replies - 31 through 44 (of 44 total)

[←](https://wordpress.org/support/topic/need-help-with-a-code/page/2/?output_format=md)
[1](https://wordpress.org/support/topic/need-help-with-a-code/?output_format=md)
[2](https://wordpress.org/support/topic/need-help-with-a-code/page/2/?output_format=md)
3

 *  Thread Starter [Mikel](https://wordpress.org/support/users/ogmic/)
 * (@ogmic)
 * [6 years ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-12979466)
 * Screenshot of the file set to 755
 * [https://ibb.co/VMC9QFM](https://ibb.co/VMC9QFM)
    [https://ibb.co/5WPg4zK](https://ibb.co/5WPg4zK)
 *  Thread Starter [Mikel](https://wordpress.org/support/users/ogmic/)
 * (@ogmic)
 * [6 years ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-12979468)
 * Screenshot of Cron job
 * [https://ibb.co/88w6tKH](https://ibb.co/88w6tKH)
 *  [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * (@corrinarusso)
 * [6 years ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-12979469)
 * If you are getting Connection Refused, are you are sure that this file path is
   correct :
    /home/surepayf/public_html/wp-load.php you may have to explicitly 
   call the php file. You may have to ask your host what path to use to reference
   the php binary file. Howerver, it is foten : /usr/bin/php in that case you would
   need to change php in your command line in the cron to : /usr/bin/php
 *  Thread Starter [Mikel](https://wordpress.org/support/users/ogmic/)
 * (@ogmic)
 * [6 years ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-12979473)
 * > Also – again this is coming from your nocache header :
   >  [https://www.php.net/manual/en/function.session-cache-limiter.php](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.
 * [@corrinarusso](https://wordpress.org/support/users/corrinarusso/) Is there any
   way to fix this, what is the advantage/disadvantage?
 *  [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * (@corrinarusso)
 * [6 years ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-12979478)
 * There’s nothing really to fix. But also this is getting very technical.
 * Here, see attached re: your cron :
 * > [View post on imgur.com](https://imgur.com/a/O9kTDOh)
 *  Thread Starter [Mikel](https://wordpress.org/support/users/ogmic/)
 * (@ogmic)
 * [6 years ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-12979480)
 * > Howerver, it is foten :
   >  /usr/bin/php in that case you would need to change
   > php in your command line in the cron to : /usr/bin/php
 * I have included this to my Cron job
 *  Thread Starter [Mikel](https://wordpress.org/support/users/ogmic/)
 * (@ogmic)
 * [6 years ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-12979483)
 * > There’s nothing really to fix. But also this is getting very technical.
   > Here, see attached re: your cron :
   >  [https://imgur.com/a/O9kTDOh](https://imgur.com/a/O9kTDOh)
 * Okay, will do that now
 *  Thread Starter [Mikel](https://wordpress.org/support/users/ogmic/)
 * (@ogmic)
 * [6 years ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-12979497)
 * [@corrinarusso](https://wordpress.org/support/users/corrinarusso/) I didn’t receive
   any mail again, and the posts are not moved
 *  [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * (@corrinarusso)
 * [6 years ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-12980455)
 * I dunno [@ogmic](https://wordpress.org/support/users/ogmic/)
    Like I said, the
   script is very easy and straightforward. It works as expected on my own server.
   I suggest you reach out to your host or ask a developer. There’s only so much
   I can do remotely, and without proper access.
 *  Thread Starter [Mikel](https://wordpress.org/support/users/ogmic/)
 * (@ogmic)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-13038846)
 * [@corrinarusso](https://wordpress.org/support/users/corrinarusso/) please I need
   your help with something please.
 *  Thread Starter [Mikel](https://wordpress.org/support/users/ogmic/)
 * (@ogmic)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-13038847)
 * I will be very very happy if you can help me out. Can I reach you on WhatsApp?
   [@corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 *  [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * (@corrinarusso)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-13040341)
 * Hi [@ogmic](https://wordpress.org/support/users/ogmic/)
    I’ve never heard of 
   WhatsApp – but I’m also not allowed to solicit work or contact info on the forums.
   It should be very straight forward, so I think you must be overlooking something
   simple. Can you show me what you have so far ?
 * The code I provided early works for sure – as I have it running successful on
   my own server :
 *     ```
       <?php
       // change the path to your wp-load.php file 
       require_once('/home/full-path-to-your-root-wordpress/public_html/your-website.com/wp-load.php'); 
       //$output = shell_exec('wp post list --category_name="FREE" --format=ids 2>1&');
       //echo $output."\n";
       global $wpdb;
       $oldCatSlug = 'FREE';
       $newCatSlug = 86; // 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',
               )
           );
           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 th
       is category appended
               }
           }
       }
       ?>
       ```
   
 *  Thread Starter [Mikel](https://wordpress.org/support/users/ogmic/)
 * (@ogmic)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-13041070)
 * [@corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * Please I need help on this please…
 * I have a mobile recharge website created with woocoomerce. Presently, I process
   orders manually because I don’t know how to make it work automatically.
 * Just of recent, I got an API from two vendors so that I can integrate with my
   website.
 * The challenge/problem is that I don’t know how to do it – I have zero idea about
   how to make it work.
 * ABOUT MY WEBSITE WORKS;
 * I have 5 products(One of each representing different mobile networks, with several
   attributes serving as data plans options, and an add-on(woocoomerce product add-
   on) used to receive users phone number). I also have a wallet system, so that
   users can pay easily from their wallet – without having to use the card everytime
   on every order.
 * WHERE I NEED YOUR HELP;
 * • How do I make it possible so that once an order has been paid for on my website,
   it will automatically be submitted to the API for processing(automatically)
 * • And if possible also get a response… To update the order status on my website.
    -  This reply was modified 5 years, 11 months ago by [Yui](https://wordpress.org/support/users/fierevere/).
      Reason: redundant link(s) deleted
 *  [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * (@corrinarusso)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-13042864)
 * Hi [@ogmic](https://wordpress.org/support/users/ogmic/)
 * People need to know the entire picture, and providing accurate answers to these
   questions is in no way straight forward. There are far too many different variables
   with your website, and especially with a vendor API(s) to be able to give you
   strong advice.
 * There are tonnes of articles that describe how to automate your processes in 
   WooCommerce :
    [https://woocommerce.com/posts/automation-for-ecommerce-stores/](https://woocommerce.com/posts/automation-for-ecommerce-stores/)
 * When I am connecting my websites to a third party API, I use Zapier most often:
   
   [https://zapier.com/](https://zapier.com/)
 * If you don’t know how to do this, you’ll need to either learn or hire a developer.
   Your ask is too complicated for simple forum discussions.

Viewing 14 replies - 31 through 44 (of 44 total)

[←](https://wordpress.org/support/topic/need-help-with-a-code/page/2/?output_format=md)
[1](https://wordpress.org/support/topic/need-help-with-a-code/?output_format=md)
[2](https://wordpress.org/support/topic/need-help-with-a-code/page/2/?output_format=md)
3

The topic ‘Need help with a code’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 44 replies
 * 2 participants
 * Last reply from: [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/need-help-with-a-code/page/3/#post-13042864)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
