Best action hook to create custom post and assign taxonomy terms to it on plugin activation?

When I install the plugin, I want to create 10 CPTs of a particular type, which I define in the init action hook, and want to assign 10 terms of a custom taxonomy, which too is defined in an init callback. I tried doing it on register_activation_hook, but the CPT’s terms are not set. Is … Read more

Cron While Editing Post

I have a multi-author blog, on which there are two schedule cron functions. The first function moves all public posts in the pending status after 365 days: if( ! wp_next_scheduled( ‘expire_posts_hook_publish’ ) ) { wp_schedule_event( time(), ‘hourly’, ‘expire_posts_hook_publish’ ); } add_action( ‘expire_posts_hook_publish’, ‘expire_posts_publish’ ); function expire_posts_publish() { global $wpdb; $daystogo = “365”; $sql = “UPDATE … Read more

Intercept request to /wp-content/uploads/random.file

I want to intercept requests to public files in WordPress, more specifically all requests to any file located in /wp-content/uploads. Using request or even init filters didn’t help, e.g. add_action(‘init’, function() { $currentURI = $_SERVER[‘REQUEST_URI’]; if (strpos($currentURI, ‘-sab-v’) !== false) { return; } }); should catch the request to http://localhost:8080/wp-content/uploads/afghanistan-sab-v1-1-586f2f0eb1464db28d20848756de2671.zip, but doesn’t. The same if … Read more

Using get_terms for custom taxonomy in functions.php

I`m trying to retrieve the names of taxonomy items and include them into a theme admin panel. function retrieve_my_terms() { global $terms; $terms = get_terms(‘taxonomy’); foreach ($terms as $term) { $option = $term->name; return $option; } } The function is added after the functions which created the custom post type and taxonomy. From what I’ve … Read more

WordPress Plugin Boilerplate – add_action hook in static “activate” function

I’m hoping someone can point me in the right direction here. I’m using the WordPress Plugin Boilerplate to develop a custom plugin. On install, the plugin will register a new post type (course), a new taxonomy (course-areas) and set up permalink structures for the new post type and taxonomy. I’ve added my code (to create … Read more

wp_redirect() not working on form submission with init hook

I am trying to redirect the user after form submission using wp_redirect() but it it is not working. I am submitting data using init action hook. here is the code. function ab_process_application_form() { if (isset($_POST[‘new_application’]) && isset($_POST[‘ab_application_nonce’])) { if (wp_verify_nonce($_POST[‘ab_application_nonce’], ‘ab_application_form_nonce’)) { // all $_POST and validation code … // add record to database $insert_id … Read more

When we register a custom taxonomy or post type, does the WP database modified at all?

When you use the register post type and register taxonomy functions in your functions.php, where do all that setting info get stored in regards to the CT’s and CPT’s you are registering? I’m talking about the settings such as whether the CPT is public or not, which custom post types work with which registered taxonomies, … Read more