Get the_title(); in a WP_Query
-
1. I have got a query that looks like this:
$new_query = new WP_Query(array('faq' => 'question', 'post_type' => 'question_faq', 'orderby' => 'rand', 'showposts' => '1'));
This works perfectly. But it doesn’t work if I change ‘question’ to the variable $title like this:
$title = the_title(); echo $title; $new_query = new WP_Query(array('faq' => $title, 'post_type' => 'question_faq', 'orderby' => 'rand', 'showposts' => '1'));
In the echo just before the query the $title is displays just perfectly, but as soon as it gets into the query it somehow looses its value.
2. My other question is if the custom taxonomy (here called ‘faq’) is comparing the name of the category, or the slug name? If it’s the slug, is there any possibility to get it to search the names instead?
Thank you so much in advance!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get the_title(); in a WP_Query’ is closed to new replies.