Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Forum: Hacks
    In reply to: Customising search query
    Thread Starter Johnster

    (@johnster)

    Mark – You’re right. Slash is not the problem. I found the problem!!! The reason I was not able to run my custom query page was the “s” query string parameter. Just to expand so other people can understand.

    http://www.sitename.com/search/?s=search+phrase doesn’t work but try renaming your query string “s” = “somethingelse” (i.e sitename.com/search/?phrase=search+phrase) works beautifully. I’m not sure whether its due to the wordpress or my customised theme. I was just trying various things to get this working and just renaming the search text field name in search form made it work.

    Thanks your patience Mark and if it wasn’t for your point on 404 behaviour, i wouldn’t have harded coded my custom query to isolate parts and eventually got where I’m now!

    Forum: Hacks
    In reply to: Customising search query
    Thread Starter Johnster

    (@johnster)

    Thanks Mark. My custom search page works if I call it directly. i.e wwww.sitename.com/search. yes, I’m attaching a page template. I’ve hard coded a mysql query for test purpose and the above link returns records and its fine on its own.

    Problem is the when calling this page via a submit button / search form as described few replies back, Which redirects to http://www.sitename.com/search/?s=search+phrase&sa1=Search which redirects to the 404 page. So it drills down to the submit form instead of my custom search page as the custom page sitename.com/search works on its own.

    I understand the below:

    http://www.sitename.com/search = http://www.sitename.com?pagename=search. But i don’t think http://www.sitename.com/search?s=search+phrase = http://www.sitename.com/search/?s=search+phrase. The slash is the problem.

    I want a way to let my search form call this custom query page with parameters.

    Hope this narrows the problem? Any idea.. Much appreciate your response.

    Thanks,
    J

    Forum: Hacks
    In reply to: Customising search query
    Thread Starter Johnster

    (@johnster)

    Thanks Mark. But it doesn’t work.

    Even if i try directly put this URL in the browser address, wordpress still redirects me to the above slashed version.

    for example: wwww.mysite.com/dc – works fine.
    if use http://www.mysite.com/dc?s=search+phrase it redirects to http://www.mysite.com/dc/?s-search+phrase which results in 404! May be i’ve change something else in the wordpress url rewrite class for search functionality?

    Any idea?

    Many Thanks,
    S

    If your search form is in a widget then look for the code in theme-widgets.php under wp-content/themes/yourtheme/includes .

    S

    I got this working by modifying “google-maps-geocoder/geocoder.php” line number 150 ..Just change those field names to reflect to your own custom field names!

    Thread Starter Johnster

    (@johnster)

    thanks sorted!

    Forum: Hacks
    In reply to: Customising search query
    Thread Starter Johnster

    (@johnster)

    thanks David. But my query is complex than that. Let me explain:

    I’m modifying the search form, so users can submit a post code along with their search phrase. And i need to display all the posts matching to the phrase ordered by distance. I.e All the posts currently has post code and its geo-coordinates (longitude / latitude)- custom fields. My simplified raw query will look like this:

    “SELECT p . * , d.Distance FROM wp_posts p INNER JOIN ( SELECT pm_lat.post_id, “
    . “ROUND((((ACOS( SIN( ( 61.4124777 * PI( ) /180 ) ) * SIN((pm_lat.meta_value * PI( ) /180 ) ) + “
    . “COS( ( 61.4124777 * PI( ) /180 )) * COS((pm_lat.meta_value * PI( ) /180 ) ) “
    . “* COS( ( (- 0.0802669 – pm_lng.meta_value) * PI( ) /180 )))) *180 / PI( )) *60 * 1.1515)) AS distance FROM “
    . “wp_postmeta pm_lat INNER JOIN wp_postmeta pm_lng ON pm_lat.post_id = pm_lng.post_id AND “
    . “pm_lng.meta_key = ‘lng’ WHERE pm_lat.meta_key = ‘lat’) d “
    . “ON p.ID = d.post_id WHERE d.Distance <10000 and post_title LIKE ‘%searchphrase%’ ORDER BY d.Distance LIMIT 0 , 1000 ” ;

    So its not the matter of adding filters and modifying the query by Join or providing custom where clause. Its the entire query. So i wrote a custom search results page with custom query and that works – problem solved but I can’t get my search form to submit to this custom page – different problem :).

    My original search form tag “<form action=”<?php bloginfo(‘url’); ?>” method=”get” id=”searchform” class=”form_search”>”

    My new search form tag below: Please note the “/dc” which is the custom page.
    <form action=”<?php bloginfo(‘url’); ?>/dc” method=”get” id=”searchform” class=”form_search”>

    but above strangely submits to http://www.sitename/dc/?querystrings instead of wwww.sitename/dc?querystrings. Note the “/” slash!

    I hope this gives a rough idea of my problem?

    Thanks,
    S

    Forum: Plugins
    In reply to: custom search results

    @mfacer – have you solved yours? I’m currently got the same requirement. I need to use a crazy custom query to display my search results. Only thing i found so far is the custom page but still figuring out how to modify the submit button to redirect to that new search results page with the parameters. Any advise?

    S

    Hi Designodyssey,

    did you manage to get this working? I want to do the following:

    Populate Longitude and Latitude for every posts.
    My posts have custom fields for address details and i’ve created lat and lng which are currently stored in postmeta table in the DB.

    How can I map these fields so the code can populate the values from gmap? Should i customise the plugin code?

    Cheers, S

Viewing 9 replies - 1 through 9 (of 9 total)