how to pass args for archive.php query?

The pre_get_posts hook can be used to modify queries before they’re run. You can use $query->set() to set arguments on the WP_Query object, and $query->is_main_query() in the callback to limit your changes to the main query: add_action( ‘pre_get_posts’, function( $query ) { if ( ! is_admin() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, 12 ); } … Read more

How to Get The Taxonomy Term in Custom Post Type Loop Inside a Wp Query

while ( $loop->have_posts() ) : $loop->the_post(); //Edit Width post type $categories = get_the_terms(get_the_ID(), ‘services’); $separator=”, “; if ( ! empty( $categories ) ) { foreach( $categories as $category ) { echo ‘<a class=”cat_item” href=”‘ . esc_url( get_category_link( $category->term_id ) ) . ‘” alt=”‘ . esc_attr( sprintf( __( ‘%s’, ‘your-themes’ ), $category->name ) ) . ‘”>’ … Read more

Custom query_posts() parameter

If you have your data in separate table adding support for it in query is somewhat messy. Basically you will need to filter posts_where and posts_join to modify raw SQL query so that your custom table is joined and checked against your custom values. As per [faster :)] anu’s suggestion it would make sense to … Read more

Query Posts (post meta)

Ok, this is your original meta conditions that describe that you want all posts where key with name from $hideFromHome equals (meta_compare is = by default) true (actually 1 since you concatenate boolean value with string). ‘&meta_key=’ . $hideFromHome .’&meta_value=” . true What you got in second snippet defines key name as pr_hidehome, value as … Read more

Run second query on page based on author of the first query

You can use the $post->post_author, so before your loop add $agent=””; then inside the loop add $agent = $post->post_author; and then create a second query after you loop ends: $agent_query = NEW WP_Query(array(‘post_type’ => ‘agent’, ‘author’ => $agent)); while ($agent_query->have_posts()){ $agent_query->the_post(); //do your agent loop here } wp_reset_postdata();

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