Update custom field on the fly
Update custom field on the fly
Update custom field on the fly
So you got a lot of stuff right, and some things wrong, so I’ll go through it line by line First: wp_reset_query(); This function cleans up after a query_posts call, you should never use either of them. Sadly, a lot of tutorial writers use this instead of what they intended to use, wp_reset_postdata, as it … Read more
…Removed my prior ‘solutions’… So, the real problem here is that this function is hooked to publish_post action, at which point the post might not be saved yet, if it is a new post. Only if it is a post already saved but with some other status, we can access the ACF values using get_field(). … Read more
It turns out the latest Advanced Custom Fields update (from version 5.6.0 on) removes the core custom fields metaboxes by default. The way to restore it was to add a filter in functions.php: add_filter(‘acf/settings/remove_wp_meta_box’, ‘__return_false’);
submitting form to admin-panel.php returns 500 error
It’s not supposed to. If you want to use multiple values in an IN meta query you need to pass an Array. That would look like this: $Style_Cabinet_Style = array( ‘Demo’, ‘Demo Two’ ); If you only have a String with commas separating the values, eg. ‘Demo, Demo Two’. Then you can use explode() to … Read more
More explain your question. if you want to fetch all post in database you this code $query = array( ‘post_type’ => ‘my-post-type’, ‘post_author’ => $current_user->ID, ‘post_status’ => array(‘publish’, ‘pending’, ‘draft’, ‘auto-draft’, ‘future’, ‘private’, ‘inherit’, ‘trash’) ); $loop = new WP_Query($query); while ( $loop->have_posts() ) : $loop->the_post();
I managed to work out the issue, so wanted to share in case others run into the same problem. The issue was coming from get_the_author_meta() which only works if an author has posts assigned to them… The solution was to change the code to: $author = get_user_by( ‘slug’, get_query_var( ‘author_name’ ) ); Then grab the … Read more
You can use get_the_content to a variable instead, so you can check it is not empty first: <?php $content = get_the_content(); ?> <?php if (!empty($content)) : ?> <h3><?php the_title(); ?></h3> <p><?php echo $content; ?></p> <?php endif; ?>
You don’t have the $post object, but trying to use it in the code ($post->ID). Use get_the_ID() function instead: <?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); // $gread = get_post_meta( $post->ID, ‘read_time’, true ); // Wrong $gread = get_post_meta( get_the_ID(), ‘read_time’, true ); // Right endwhile; } From now forth always enable debugging when you … Read more