WP_query returns error when used for custom widget

UPDATE: Okay, Looking at the Error, it should be easy. Just remove any Whitespaces or Clear Lines at the end of your Plugin file after the last “?>”. http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc Did you copy&paste the code here? Because it seems like you have some whitespaces that should not be there in the line <?php if ($the_query->have_posts()) : … Read more

one get_posts to return a number of custom posts for each meta value

Short answer: no. But if you want to use one loop for all your needed posts, you can do something like this: $args = array( ‘post_type’ => ‘product’, ‘meta_query’ => array( array( ‘key’ => ‘cf_type’, ‘value’ => ‘fog’, // need to have 10 with value ‘fog’ and 10 with value ‘gof’ ) ), ‘numberposts’ => … Read more

Filter and display a specific custom field value [closed]

Now with the new information I would go with this: ?> <form method=”post” action=”where_ever_you_want_to_point_the_user_afterwards.php”> /* The loop: */ if (the_field(‘departures’) == ‘user_departure_location’) { <input type=”radio” name=”destination” value=”<?php echo the_field(‘destination’); ?>”> <a href=”https://wordpress.stackexchange.com/questions/154925/<?php the_permalink(); ?>”> Destination: <?php the_field(‘destination’); ?> Departing from:<?php the_field(‘departures’); ?> Price:<?php the_field(‘price’); ?> </a> } /* The loop end */ ?></form> And then … Read more

Get custom fields when hover link of post

I would just put the custom fields in the <li> after the <a> and then show/hide them with your preferred tooltip method, whether it be CSS, JS or a combination of the two: <?php if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <li> <a href=”https://wordpress.stackexchange.com/questions/155135/<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>” … Read more

$args Orderby The number

You could use the get_terms_orderby filter: add_filter( ‘get_terms_orderby’, ‘wpse156153_get_terms_orderby’, 10, 3 ); $categories=get_categories($cat_args); remove_filter( ‘get_terms_orderby’, ‘wpse156153_get_terms_orderby’, 10, 3 ); with function wpse156153_get_terms_orderby($orderby, $args, $taxonomies ) { return ‘FIELD(t.term_id, ‘ . $args[‘include’] . ‘)’; }

How to exclude post from being queried based on custom meta value

According to the codex for WP_Query, you should be able to tack on some meta related arguments to your args array (this is untested): $review_args = array( ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ‘posts_per_page’ => ‘1’, ‘cat’ => 22, ‘meta_query’ => array( ‘key’=>’reviewed_by’, ‘value’=> $reviewed_by_array, ‘compare’=> ‘NOT IN’ ) ); $review_query = new WP_Query($review_args);

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