Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
function add_listing( $atts)
 { extract( shortcode_atts( array (
'sslug' => '',
'jslug' => ''
  ), $atts ) );

global $wpdb;
$qstr = '   
SELECT * 
FROM $wpdb->posts   
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)    
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
WHERE $wpdb->posts.post_type = "states" 
AND $wpdb->posts.post_status = "publish"
AND $wpdb->term_taxonomy.taxonomy = "usstates"
AND $wpdb->term_taxonomy.taxonomy = "job-desc" 
AND $wpdb->terms.slug =  $sslug;   <-----
OR $wpdb->terms.slug =   $jslug;    <--------
ORDER BY $wpdb->posts.post_date DESC
';
  add_shortcode("list", "add_listing");

i want to subtitute the value like for example:

here's my sample shortcode

[list sslug="alabama" jslug="electrician"]

i want to subtitute the value to the arrow above

but cant get it to work :(

please help guys

share|improve this question
add comment

1 Answer

If you put variables inside a string, you have to use " double quotes.

So:

// This:
$qstr = '
SELECT *
...
ORDER BY $wpdb->posts.post_date DESC
';

// becomes...
$qstr = "
SELECT *
...
ORDER BY $wpdb->posts.post_date DESC
";
share|improve this answer
1  
He should be using the prepare method for those two items, but you're correct about the double quotes as well. He also has a taxonomy problem since he's got $wpdb->term_taxonomy.taxonomy = "usstates" AND $wpdb->term_taxonomy.taxonomy = "job-desc", which will always be false. –  Otto Aug 30 '11 at 17:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.