Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.
7 votes
Accepted

Posts to expire (deleted) after a date

I did something similar a while ago. I'm not sure deleting a post is a good solution, maybe you can change only the post status to a custom one called Expired for example. But for an example, the code ...
user avatar
  • 3,158
6 votes
Accepted

Programatically Creating Initial Wordpress Site

I'd highly recommend WP-CLI for such tasks. It is a tool that allows installation and configuration of WordPress on the command line. What you are trying could easily be done: wp core download wp ...
user avatar
  • 5,431
6 votes

Fastest way (least amount of steps) to locally import a remote database using WP-CLI

Since WP-CLI 0.24.0 you can now use aliases which enable you to import a remote database quite easily. By using aliases, you can run WP-CLI commands against another WP-CLI install. That install could ...
user avatar
  • 638
5 votes
Accepted

Delete expired posts after a number of days after they expired

WP Cron jobs are not reliable as it needs someone to visit the site at the time the event should fire. If you need precise timing, you should use server cron jobs. Anyways, lets look at your code ...
user avatar
3 votes

How to Submit Post Via cURL & PHP

Have a look at wp-cli and wp-api they could help you automate your process without you needing to know too much about wordpress.
user avatar
  • 111
3 votes

XMLRPC and Underscored custom fields

Playing with XML-RPC and underscored custom fields: Let's say we want to set the featured image to a given post with $remote_post_id. We want it to be the attachment with ID equal to 300, so we want ...
user avatar
  • 63.9k
3 votes

Delete expired posts after a number of days after they expired

The native trash bin It sounds like you're implementing your own version of the WordPress trash system. If you trash a post, the native way, it will get the trash post status and will be ...
user avatar
  • 63.9k
3 votes

How to add multiple existing users to a multisite site?

I'd try this with two steps. First, install the Multisite User Plugin or grab the useful bits from its code. Short version: It hooks into user_register and loops through each blog in a multisite, ...
user avatar
  • 1,275
3 votes
Accepted

Automatically set page order on create page

You could use ajax and the admin_footer-post-new.php hook. The sql would vary depending on whether you want the highest or most recently published order number. The following returns the highest ...
user avatar
  • 4,308
3 votes

Programatically Creating Initial Wordpress Site

I worked out an easy and elegant way to solve this problem - After doing the installation I can simply use CURL to submit the values for the initial user through a web page with a command line like ...
user avatar
  • 165
2 votes

Disable automatic content hyperlinking

It's the Editor TinyMCE's embed plugin to disable it you will also need to disable all other embeds (twitter, images, youtube, etc) If you still want to proceed, then enter this code in your theme's ...
user avatar
  • 141
2 votes

Automatically set page order on create page

You could hook into the publish_page transitional status action and use a simple SQL query (via $wpdb) to determine the highest current value of menu_order in the {prefix}_posts table and set the ...
user avatar
2 votes

New Gmail email to a WordPress new post?

WordPress has built-in support for posting via email. Go to Settings > Writing in your admin and enter your credentials under "Post via e-mail". Note it won't handle Gmail labels (it only works via ...
user avatar
  • 34.9k
2 votes
Accepted

Automate dir and DB stack creation with WP-CLI

WP-CLI has a bunch of helpful commands, including some to perform basic database operations. However, it's not its job to create new users in MySQL and grant them permissions on a newly created ...
user avatar
  • 3,634
2 votes

How to incorporate Documentation into wordpress?

WordPress allows you to add help tabs which appear in your Dashboard and on each admin page. $screen = get_current_screen(); $screen->add_help_tab( array( 'id' => $id, //unique ...
user avatar
  • 9,439
2 votes

How can I post exact same post but with a few things changed? (with some sort of Automation)

I would do this using advanced custom fields to setup a field set with X and Y, then build a custom post template where the non-dynamic text is hard coded and us the_field(field_id) function to run a ...
user avatar
2 votes

Send a review notification email to admin when a post is 12 months old

You ask a good question, where I would put it or how I would call it? I don't think you want to loop over all the posts everytime somebody visiting your site checking if any of them are more than one ...
user avatar
2 votes

Setting a default text for excerpts of a particular category

Insert the following code, in functions.php of your child theme. function wpse_excerpt_for_specific_category( $excerpt ) { global $post; $category = 'Test'; // could be name, slug, or id $...
user avatar
1 vote

Generate WP-CLI @alias for each site on multisite

LOCAL For local aliases, it works best to define your path ahead of time in the config.yml. Then keep the variables pretty clean by only specifying the url to target the site. Sorting the output ...
user avatar
  • 9,439
1 vote

Shortest possible shell script to install WordPress on Nginx server?

Having the "shortest" script is a fairly pointless goal here I think, besides for entertainment purposes. But if you are looking for something that is very minimal and easy to understand, ...
user avatar
1 vote
Accepted

Automating WP application directory creation (domain name passed as a variable argument)

Ok, I just checked the WP CLI documentation. There are 3 important steps: Download WordPress: (I would use it with the options --path and --locale, but those are optional) wp core download Create ...
user avatar
  • 5,900
1 vote

Automatically Add Page Links to Nav Menu

Turns out is_plugin_active is defined in wp-admin/includes/plugin.php so it's only available within the admin unless I call it. I needed to add include_once( ABSPATH . 'wp-admin/includes/plugin.php' )...
user avatar
  • 11
1 vote
Accepted

Automatically generator a Wordpress installation on my subdomain

You'll want to setup a Multis-site network - https://codex.wordpress.org/Create_A_Network If you know your way around code what you'll need to do is use the wpmu_create_blog() function - https://...
user avatar
1 vote

Automate configuration after new/hosted installation

This sounds like a perfect use case for WP CLI, all you need is SSH access, which many major hosts now provide. Many of the features you are asking for are already provided out of the box. For others ...
user avatar
  • 5,900
1 vote
Accepted

Automating Page Creation

Where is the content coming from? You can easily write PHP code that will create pages, but the content has to come from somewhere. If the content already exists, say in a database that you own, then ...
user avatar
1 vote
Accepted

On install, automatically create page and set it as front page

First of all you should use register_activation_hook, this hook runs when a wordpress plugin is installed. I would also replace the call to the $wpdb for inserting post with wp_insert_post. ...
user avatar
  • 2,811
1 vote
Accepted

Automate specific steps on WordPress install

I'd suggest creating a Yeoman generator. I've written one for my starter theme which you might find helpful if you write your own: https://github.com/powerbuoy/SleekWPGenerator
user avatar
  • 802
1 vote

When a user registers, create a page from an existing template with their username as the page name

First off, it sounds like you might be able to solve your underlying question using BuddyPress. If you simply want to make an actual WordPress page if a user registers you can do that using the ...
user avatar
1 vote
Accepted

No result update a custom field using wp_schedule_event

It think that your problem is the you are passing the post ID as url parameter to facebook API: $url = get_the_ID(); Also, as get_posts return an array of post objects, you could use this code: $...
user avatar
  • 19.7k
1 vote

XMLRPC and Underscored custom fields

_Underscored meta data is defined to be data which is internal to the software and not directly changed by a user. This is probably why you can't change it via XMLRPC. If you need this kind of ...
user avatar
  • 22.6k

Only top scored, non community-wiki answers of a minimum length are eligible