WordPress tax_input only if logged in

You can use wp_set_object_terms after the post is saved and in case it fails you will get reason for that ex: $new_lead = array( ‘post_title’ => $lead_name, ‘post_content’ => $lead_message, ‘post_type’ => ‘leads’, ‘post_status’ => ‘publish’, ); $lid = wp_insert_post($new_lead); $status = wp_set_object_terms($lid,$term_id,’lead-status’); Now this does the save but $status will hold the reason for … Read more

How to use custom fields to enable sticky posts on custom post types?

You can achieve this with ACF. Create a custom field checkbox (just a simple boolean) for your custom post type. Below an example of overriding the main loop in archive template : function order_cpt_by_stickyness( $query ) { if(!is_admin() && $query->is_main_query() && is_post_type_archive(‘my_custom_postype’)) { $query->set( ‘meta_key’, ‘my_sticky_custom_field’); $query->set( ‘orderby’, [‘meta_value’ => ‘DESC’, ‘date’ => ‘DESC’]); } … Read more

Custom Post Type Alerts

WordPress has a save_post hook, which is an action triggered whenever a post or page is created or updated. Add something like this below to your functions.php: function my_project_updated_send_email( $post_id ) { // If this is just a revision, don’t send the email. if ( wp_is_post_revision( $post_id ) ) return; $post_title = get_the_title( $post_id ); … Read more

Custom Post Type order by modified date and custom meta field issue

If I understand you, I believe that the following will do what you need: function orderby_mod_wpse_140999($orderby) { remove_action(‘posts_orderby’,’orderby_mod_wpse_140999′); global $wpdb; return $orderby.”, {$wpdb->posts}.post_modified DESC”; } add_filter(‘posts_orderby’,’orderby_mod_wpse_140999′); $args = array( ‘meta_key’ => ‘premium’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’ ); $q = new WP_Query($args); var_dump($q->request); The key names may be wrong and it may be (probably … Read more