WordPress.org

Ready to get started?Download WordPress

Forums

How to make a hyperlink to a predefined search? (11 posts)

  1. dustinrm
    Member
    Posted 2 years ago #

    Ok Sorry for the confusing title, but basically what I'm trying to do is create a way for someone on my website to simply click a hyperlink with the anchor text "dentist" and for all the search results for the search term "Dentist" to appear.

    I'm using this on a small mobile site built in WordPress that is for a very small local directory. So since people are on a phone it's easier to have the word "Dentist" or whatever that leads to the listing. Also we aren't able to use "Categories" or "tags" with this particular mobile site so that ruled that out.

    Thanks for all your help!

  2. Jeff Clark
    Member
    Posted 2 years ago #

    Code below should do it.

    <a href="/?s=dentist&submit=Search">dentist</a>

  3. Jeff Clark
    Member
    Posted 2 years ago #

    Sorry it created a link

    /?s=event&submit=Search

    put the code above in an href and it will work

  4. Jeff Clark
    Member
    Posted 2 years ago #

    weird now it is showing up haha. Anyway that should work

  5. dustinrm
    Member
    Posted 2 years ago #

    Awesome jclark! That worked, but I need to figure out how to have it only pull and display results from the mobile version. The mobile version is made using custom post-types I think.

    I thought there was a way to add some code to the functions.php file, but honestly I'm NOT a programmer so not sure. Maybe you know?

  6. Jeff Clark
    Member
    Posted 2 years ago #

    is your mobile version just css changes or are you calling content independently?

  7. dustinrm
    Member
    Posted 2 years ago #

    Just CSS changes I think? I didn't develop it and I'm not too techie so I believe that's the case. It's a plugin that I'm using

  8. Jeff Clark
    Member
    Posted 2 years ago #

    For you to only be able to search what you have on your mobile site you would have to have some way of defining if the content was mobile content or not. And yes there is a way to do that. But I dont think I could explain it to you through this forum. It would take a little bit of work.

  9. dustinrm
    Member
    Posted 2 years ago #

    I understand. Yeah I was thinking of using the fact that it's a custom post type to define the content. I thought that might work I just don't know HOW to make it work LOL

  10. Jeff Clark
    Member
    Posted 2 years ago #

    I can get you something that will search only stuff in a custom post type if that will work?

  11. dustinrm
    Member
    Posted 2 years ago #

    Yeah man that would be great. if I could use that with the code you already gave me that would probsbly work just fine

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags