How can I filter a query by post id?

So you want the values 108,78,90 corresponding to the meta key ‘areas’ for the post with ID 94? First retrieve those IDs: $the_post_id = 94; $area_ids = get_post_meta( $the_post_id, ‘areas’, false ); //Make sure they’re all positive integers $area_ids = array_map( ‘absint’, $area_ids ); if( $area_ids ){ //We have IDs, retrieve posts $areas = get_posts( … Read more

how to show only catergory titles on a page in wordpress

You will need to combine get_categories() and wp_query First you should get all categories and loop through each one of them. Inside the loop you need a wp_query to get the title and the image of the latest post per category. At last you should reset the post data. Place the code below inside your … Read more

How to write short code with if else to get page_id?

I use this maybe helpfull <?php $title = get_the_title($post); $parent_title = get_the_title($post->post_parent); echo $title; echo $parent_title; ?> <?php global $post; //wordpress post global object if($post->post_type == ‘page’){ $content .= ‘<br /> This item is a page and the ID is: ‘.$post->ID; } elseif($post->post_type == ‘post’) { $content .= ‘<br /> This item is a post … Read more

How to query posts from single post format on Genesis framework

The taxonomy should be post_format and term should be post-format-link. Also simple taxonomy queries are deprecated since 3.1 in favor of tax_query: $args = array( ‘posts_per_page’ => 5, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => ‘post-format-link’ ) ) ); $recent = new WP_Query( $args );

WP_Query – meta fields numeric

Maybe I’m wrong but you are missing query relation… <?php $args = array( ‘post_type’ => ‘mls’, ‘meta_query’ => array( relation => ‘AND’, array( ‘key’ => ‘_city’, ‘value’ => ‘Clarkson’, ‘compare’ => ‘=’ ), array( ‘key’ => ‘_price’, ‘value’ => ‘200000’, ‘type’ => ‘numeric’, ‘compare’ => ‘>=’ ) //array( // ‘key’ => ‘_price’, // ‘value’ => … Read more

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