• I’ve been using a plugin called “search everything” to be able to search tags. But I would like to cut down on my heavy plugin usage. Is there any core hack or functions.php hack to include tags in the search results?

    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter benjamin_sp

    (@benjamin_sp)

    Any ideas guys, would really like to know if this can be done without a plugin.

    Pretty much anything that can be done in a plugin can be done without one.

    Short answer, yes i believe you can.

    Thread Starter benjamin_sp

    (@benjamin_sp)

    t31os_, do you know of any places that gives the exact method? In a desperate attempt, I opened up the search everything’s plugin page and tried to locate the bits of code that were responsible for the search tags feature which I then pasted into the functions file but it didn’t exactly work.

    Do you mean show tags for the search results (if it’s a post), or search posts where tag=search_text …

    Thread Starter benjamin_sp

    (@benjamin_sp)

    I mean a user should be able to find posts by searching tags. If a user enters a word in the search bar that happens to be a tag, it should return all the posts that are ascribed to that tag. Like searching “technology” would return the posts “Mac vs PC” and “Microsoft in talks to buy Yahoo” since I tagged those two posts with the word “technology”.

    It’s already supported ….

    If you try a search now, look at the url.. you’ll have something like..

    yoursite.com/?s=searchterm

    Add this onto the end..

    &tag=tagname

    ..hit enter..

    The query should then filter the posts by matching tag….

    If you want to search by TAG alone you’ll need to modify the main query (query_posts) just as you would with other template files.

    If you want to print out the query_vars (so you can see what’s being populated on search)…

    <pre>
    <?php print_r($wp_query->query_vars); ?>
    </pre>

    I’m still fiddling around with the search page myself, and i’m not sure what the correct procedure for passing strings to the search function are…

    Here’s what i’m toying around with at the moment (simply so you can see what i’m doing in mine)… (don’t use it on a live site, take what you need from it, if it helps)..

    https://wordpress.pastebin.com/f58012dc1

    Thread Starter benjamin_sp

    (@benjamin_sp)

    Thanks t31os_ but I’m afraid all this code stuff is a little over my head, I’m only beginning to learn wordpress at the moment.

    I tried adding &tag=tagname at the end of the search url and it appears to narrow down a search term by a specific tag. Like the term “iphone” can be narrowed down as appearing in a post tagged with “apple”. But this doesn’t exactly allow tags to be searched like a regular search term.

    It seems like this shouldn’t even be a problem as tags actually appear textually in a post. But unlike the rest of the post content tags aren’t picked up in a search. I guess it’s because tags and posts are stored in separate tables in the database. I hope they make searching tags an inbuilt feature with an upcoming release.

    I searched everywhere and so far it seems the only way to search tags is to use the Search Everything plugin. It just sucks to use a huge plugin just for one of it’s sub-features…

    I agree, it would be nice to have a configuration option to include tags or not in the search without tampering with core or theme code or installing a huge plugin. I always assumed tags were included in a search until I built a comic blog where the content was primarily graphical. The tags do go in the page’s metatags (whether that’s the SEO plugin or core I don’t know.) but I don’t know how much Google believes them if the matching text doesn’t actually appear in the page.

    It’s more important to me to have these posts discovered by an external search like Google, but having the internal tags index posts internally would be very good too.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Include tags in search results’ is closed to new replies.