how to display all posts Custom fields dynamically?

<div class=”col-xs-12 col-sm-12 col-md-8 col-lg-8 left_column”> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h1> <?php the_title();?> </h1> <?php $post_meta = get_post_meta(get_the_ID()); foreach($post_meta as $key=>$value) { echo “<strong>”.$key.”</strong>”.” => “; foreach($value as $nameAr=>$valueAr) { echo “<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;”; echo $nameAr.” => “.$valueAr; } echo “<br >”; } the_content(); endwhile; endif; ?> </div>

Query Problem – Show posts within category ‘x’ that have a custom field between ‘y’ and ‘z’

May this code help $args = array( ‘cat’ => ‘Category id’ ‘post_type’ => ‘post type’, ‘meta_key’ => ‘enter your metakey’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘age’, ‘value’ => array(min price, max price), ‘compare’ => ‘IN’, ) ) ); $query = new WP_Query($args); $query will contain an Array of … Read more

Metabox saving values

First, you don’t need the <form> tags; meta boxes are already rendered inside the post edit form. Second, if a checkbox is not checked it is not sent, so isset( $_POST[‘checkbox_name’] ) return false and the custom field that stores the value of the checkbox is not update correctly. I’ve tested this code with standard … Read more

How to use custom field to search for wordpress post type?

Using pre_get_posts may work. Can you try something similar to the following and let me know if it meets your needs: function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set(‘post_type’, array( ‘post’, ‘movie’ ) ); //Should do some sanitation on $GET too if(isset($_GET[‘author’])){ //Change to your field dropdown name $query->set(‘meta_key’, … Read more

Exclude custom post type from search by custom field value?

You need to implement a hook for pre_get_posts filter, in which you can set what you need. Pay attention that you should change only search query, so you have to check if is_search() method returns true. The hook should look like this: add_filter( ‘pre_get_posts’, ‘wpse8170_pre_get_posts’ ); function wpse8170_pre_get_posts( WP_Query $query ) { if ( $query->is_search() … Read more

enabling custom fields in admin?

The visibility of custom fields on the post edit screen is controlled on the post edit page. There’s a button called “Screen Options” towards the top of the screen. Clicking that button will display all of the available boxes and panels for the edit page. If custom fields is not visible here, then either your … Read more

Loop through two different sets of custom fields

Your question literally doesn’t quite sound like “combining” loops, that’s usually different thing in WP terminology. Following it literally you already know the part that outputs artist name you want — the_field(‘artist_name’). What probably confuses it in first context is that it’s not really a normal WP loop. Note how that call doesn’t specify which … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)