WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Matching search terms, getting back post IDs (5 posts)

  1. Jon Bourne
    Member
    Posted 7 years ago #

    What is the best way to use WP's built-in search functionality to pass some keywords to WP and get post IDs in return?

    I want to detect the keywords users typed to arrive at my blog from a search engine, search the database with WP's search functions, and get in return a list of post IDs. With these, I could then choose to display the list of post titles as links to the posts themselves.

    I am not interested in using the related posts plugin.

  2. muelheim
    Member
    Posted 7 years ago #

    To retrieve the search-engines' keywords you have to write your own php-code, why not add some specific sql-querys to get the posts instead of using wp-search?

  3. Jon Bourne
    Member
    Posted 7 years ago #

    Well, I could... Do you think that would be better? More efficient? What are the benefits either way?

    As a side note, does WP use MySQL's full-text indexing for its searches?

  4. muelheim
    Member
    Posted 7 years ago #

    Better?

    I would do it (the problem is to retrieve the keywords, not to do a site search), I think.

    If you need the php-code for retrieving the keywords, I can send it to you (found it on the net and used it for one site).

  5. Jon Bourne
    Member
    Posted 7 years ago #

    Retrieving the search engine keywords isn't a problem. I already have that part of my plugin done. Thanks for the offer, though.

    I was able to match the keywords to UltimateTagWarrior tags in the database, do a LEFT JOIN, and get the post IDs that way. Essentially, the IDs of any post that has tags that match a search term are returned.

    I can just pull the posts out based on their IDs. Thanks for your help. I just needed someone to bounce ideas off of.

Topic Closed

This topic has been closed to new replies.

About this Topic