• Resolved Jon Bourne

    (@akbigdog)


    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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?

    Thread Starter Jon Bourne

    (@akbigdog)

    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?

    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).

    Thread Starter Jon Bourne

    (@akbigdog)

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Matching search terms, getting back post IDs’ is closed to new replies.