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.

I created a custom loop using WP_Query for my featured content slider.

<?php
$slider_query = new WP_Query();
$slider_query->query("posts_per_page=5&tag=".(get_option('cgr_slider_tag'))" ");?>
<?php while ($slider_query->have_posts()) : $slider_query->the_post(); ?>

    <article class="slide-item ">

     ....

It works fine in previous 3.1.4 , but after upgraded to 3.2 that code is just didn't work. No error found in WP_Debug mode, and Then i try to directly assign the tag name without using the get_option :

<?php
$slider_query = new WP_Query();
$slider_query->query("posts_per_page=5&tag=tag1");?>
<?php while ($slider_query->have_posts()) : $slider_query->the_post(); ?>

 <article class="slide-item ">


  ....

it works, so i assume the problem is the get_option thing. I've checked the database and other part of the theme that also using get_option and found no problem.

I start thinking that the problem is I didn't code the get_option part correctly, i'm php noob so maybe it's about encapsed string or others.

Any help will be appreciated.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

this line:

$slider_query->query("posts_per_page=5&tag=".(get_option('cgr_slider_tag'))" ");

should be:

$slider_query->query("posts_per_page=5&tag=".(get_option('cgr_slider_tag')));
share|improve this answer
    
Thanks. it works. I should learn more about writing a good php code. –  Faizal Al-Amri Jul 10 '11 at 0:39
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.