change value of fields created with advanced custom fields in the front

If you want to include your own inputs on the acf_form() you should use some of its parameters to allow the form submit them. Otherwise your inputs will be out of the form. As an example you could use this code: <?php acf_form( array( ‘html_after_fields’ => ‘<input type=”text” id=”id_whatsapp” name=”acf[n_whatsapp]” value=”acf[n_whatsapp]”>’, ) ); ?> You … Read more

ACF: How to make get_field() ignore the main wp query?

I resolved this by adding wp_query->is_main_query() to my clauses before I set the query update. Ie… // The filter code that shows only the current authors posts add_action(‘pre_get_posts’, ‘query_set_only_author’); function query_set_only_author( $wp_query ) { if( is_admin() && get_current_user_role()==”required_role” && $wp_query->is_main_query() ) { if ( basename($_SERVER[‘PHP_SELF’])==”edit.php”){ $wp_query->set( ‘author’, $current_user->ID ); } }

Remove the first 5 characters of the_title and orderby that

WordPress WP_Query’s orderby parameter has a lot of options but nothing as specific as what you are after. I think you’d have to do this after retrieving posts through the WP_Query, then sort them using usort(). Your code should be something like this. $args = array( ‘post_type’ => ‘z_day’, ‘posts_per_page’ => -1, ‘meta_query’ => array( … Read more

Assign category from custom field on post creation and update

After getting year, you may check if category exists using category_exists($cat_name); if not found then create category using wp_create_category( $cat_name, $parent ); after that you may create post using $my_post = array( ‘post_title’ => wp_strip_all_tags( $_POST[‘post_title’] ), ‘post_content’ => $_POST[‘post_content’], ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_category’ => array( 8,39 ) ); // Insert the … Read more