Sunday, 15 January 2012

Wordpress mysql query not showing results? -



Wordpress mysql query not showing results? -

the query should homecoming thumbnail, title, name, cost etc (all fields)

<?php query_posts('meta_key=cp_job&meta_value=sell'); if ( have_posts() ) { while ( have_posts() ) { the_post(); // the_content(); // } // end while } // end if ?>

it should homecoming results meta_key=cp_job , meta_value=sell.. i've tried sorts of queries , has taken several hours, i've yet find solution.

i'm working theme , time i've gotten result query

$metakey = 'cp_job'; $job = $wpdb->get_col($wpdb->prepare("select meta_value $wpdb->postmeta meta_key = %s order meta_value asc", $metakey) ); foreach ($job $value) { echo $value"; }

this query doesn't want accomplish.

i want "select * table cp_job='sell'"; wordpress makes complicated. don't know table hold results!...

any help please..

you may seek this:

$args = array( 'post_type' => 'post', // or custom post type if it's cpt 'meta_key' => 'cp_job', 'meta_query' => array( array( 'key' => 'cp_job', 'value' => 'sell' ) ) );

then run query , loop $query same way:

$query = new wp_query( $args );

mysql wordpress

No comments:

Post a Comment