• 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)
  • Thread Starter Corneliatt

    (@corneliatt)

    Ok, so I managed to solve this. If someone has the same problem, I solved it by using get_the_title() instead of the_title().

    ??

    Thread Starter Corneliatt

    (@corneliatt)

    Oh, I thought I had solve this, but now it doesn’t work. When I use “>” or something like that in the title it won’t find anything (of course, because the slug doesn’t contain >). Can I somehow strip the the_title() from >??

    Thank you in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get the_title(); in a WP_Query’ is closed to new replies.