• Resolved xdesi

    (@xdesi)


    OK Currently I have the code which search for all posts with the tag football.

    query_posts(array(
    'cat'=>'5',
    'tag_slug__and'=>array('football'),

    How do i change this so it searches for all posts with the tag dependant upon the title. So i need to insert the_title() instead of football but can’t figure how to do it i keep getting an error?

Viewing 2 replies - 1 through 2 (of 2 total)
  • blazes816

    (@blazes816)

    Does:

    query_posts(array(
    'cat'=>'5',
    'tag_slug__and'=>array(the_title()),

    Not work?

    Thread Starter xdesi

    (@xdesi)

    It works but not how it should.

    OK let me try and describe this the best i can. Here is the code in it’s shortest form.

    <?php rewind_posts();
    query_posts(array(
    'cat'=>'5',
    'tag_slug__and'=>array(the_title()),
    ) );
    while (have_posts()) : the_post();
    the_content();
    php endwhile; ?>

    OK what this should do is search for all posts from cat 5 with a tag the same as the title of this post (lets say the title of the post is “football”) and then display the content from those posts.
    However this does not work instead it just displays the title of the posts found in non-formatted text.

    I can confirm that the code correctly works if i simply enter the title of the post in plain text such as (‘football’). So why does it not work with (the_title()), if the title of the post is football. i should be getting the same results. I need it to be dynamic.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Simple PHP Problem’ is closed to new replies.