Is there any special parameter that i can pass to search url to sort it by date .
And is there any parameter to increase the number of search results returned ?
Thanks
WordPress search is already sorted by date, most recent first. If that's not what you're looking for, you're out of luck without using plugins and/or editing source code. So no, (taking a guess here) you can't pass URL parameters to a search on a 3rd party WordPress site to change the info you get back.
This quote from Joost de Valk, one of the leading WordPress gurus out there, from his site yoast.com
WordPress default search kinda sucks. It sorts the results by date, newest first, and interface wise it doesn't have any of the cool things we're used to when we search in for instance Google.
That article is mainly on how to improve the search functionality of your own site.
I've made some modifications on the Search Unleashed plugin, it's the best one I've found and is pretty customizable
I believe this plugin will allow you to sort by date: http://wordpress.org/extend/plugins/search/
Hope it helps!
Related
I have created a custom page in Wordpress which presents different data based on the query string. So my query string right now looks something like
http://example.com/extcat/?uid=15&src=blog
Now this is not getting picked either by Google's spidering software or by tracking software properly. They are all tracking it as one single page
http://example.com/extcat
without the uid.
What I want is to rewrite the above query in a format like one of these
http://example.com/extcat/uid/15/src/blog
http://example.com/extcat/15/blog
http://example.com/extcat/15/?src=blog
http://example.com/extcat/15/
I don't care which format I use.
I tried using .htaccess and the WordPress api both. Nothing seems to work.
Here is an in-depth article on how to accomplish what you are doing. Basically, you'll need to register your custom query variables so WP can do it's magic using add_rewrite_rule(). It's a long article, but will provide a better answer then I can write. Plus, you'll learn a whole lot!
https://premium.wpmudev.org/blog/building-customized-urls-wordpress/
Firstly thank you for taking the time to look at my question.
I have a project where I have integrate a find nearest location function on a Wordpress website. The functionality should work as:
A user inserts their postcode into the search bar, and the results shown are shops which are nearest to their postcode.
Has anyone done anything like this before and if so do you have any recommendations on plugins or tutorials which could possibly help me.
Thanks
The functionality you are looking is basically radius search for given zip code. I will suggest you to go through with this nice article to get start and complete your task.
https://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/
After much research I found a suitable plugin for the job:
https://wordpress.org/plugins/gwebpro-store-locator/
There are many plugins out there with the same functionality, but I chose this one.
I edited the plugin heavily to get it to work how I want it to work.
I created an external link for J-locate plugin for Joomla that would help show a certain locations I need on the map since there is no way to set a default location through the plugin. It goes something like this: view=jlocate&state=nc&zip=27604&radius=10
I am trying to figure out a way to get rid of the state filter so it doesn't restrict the zipcodes closest location by the states. Is it possible to put multiple states in the external link I made? It would be nice if it works so it filters through all states, i tried putting something like the following: view=jlocate&state=nc&ca&fl&zip=27604&radius=10 so it would go through multiple states but it only selects the first one, so if the zipcode is not in NC, it wouldn't find it.
My goal is to make the map available so anyone can search all states by the zipcode field alone without putting in a state. This will resolve a border line locations that i am facing right now due to the fact that its filtering states.
Thank you in advance for any positive help.
here is the link to the plugin i am using: http://joomlavida.com/jlocate-joomla-store-locator-demo?zip=33761&state=FL
It really depends on the component.
The correct way to pass a list could be an array
&state[]=nc&state[]=va&state[]=nj
but since you want to do without, why not omit it? If it's forced somewhere beyond your control you could still unset() it.
Otherwise in the unlikely scenario that the programmer is not doing server-side sql injection filtering, pass
&state=%
where % is the wildcard for SQL.
(Programming Language: PHP v5.3)
I am working on this website where I make search on specific websites using google and bing search APIs.
The Project:
A user can select a website to search from a drop-down list. We have an admin panel on this website. If the admin wants to add a new website to the drop-down list, he has to provide two sample URLs from the site as shown below.
On the submit of form a code goes through input and generates a regex that we later use for pattern matching. The regex is stored in database for later use.
In a different form the visiting user selects a website from the drop-down list. He then enters the search "query" in a text box. We fetch results as JSON using search APIs(as mentioned above) where we use the following query syntax as search string:
"site:website query"
(where we replace "website" with the website user chose for search and replace "query" with user's search query).
The Problem
Now what we have to do is get the best match of the url. The reason for doing a pattern match is that some times there are unwanted links in search results. For example lets say I search on website "www.example.com" for an article names "abcd". Search engines might return these two urls:
1) www.example.com/articles/854/abcd
2) www.example.com/search/abcd
The first url is the one that I want. Now I have two issues to resolve.
1) I know that the code that I wrote to make a regex pattern from sample URLs is never going to be perfect considering that the admin adds websites on regular basis. There can never be enough conditions to check for creating a pattern for different websites from same code. Is there a better way to do this or regex is my only option?
2) I am developing on a machine running Windows 7 OS. preg_match_all() returns results here. But when I move the code to server which is running Linux OS, preg_match_all() does not return any results for the same parameters? I can't seem to get why that is happening. Anyone knows why is this happening?
I have been working on web technologies for only past few weeks, so I don't know if I have better options than regex. I would be very grateful if you could assist me or guide me towards resources where I can find solution for my problems.
About question 1:
I can't quite grasp what you're trying to accomplish so I can't give any valid opinion.
Regarding question 2:
If both servers are running the same version of PHP, the regex library used ought to be the same. You can test this, however, by making a mock static file or string to test against the regex and see if the results are the same.
Since you're grabbing results from the search engines and then parsing them, the data retrieve might not be the same. Google/Bing change part of the data regarding the OS you use and that might alter preg results.
I'm writing an app that allows you to filter database results based on Location and Category.
If someone was to search for Liverpool under the Golf category the URI would be /index.php/search/Liverpool/Golf.
Should someone want to search by Location but not category, they would be sent to /index.php/search/Liverpool
However, should someone want to filter only by category they would be unable to use /index.php/search/Golf because that would be caught by the location search.
Is there a best practice way to have /index.php/search/Golf be recognised? Some best practice as to what else to add to the URI to make these two queries distinct? /index.php/search/category/Golf perhaps?
Though that is beginning to show characteristics of /index.php?search&category=Golf which is exactly what I'm trying to avoid.
Try using $this->uri->uri_to_assoc(n)
described here http://codeigniter.com/user_guide/libraries/uri.html (half way down on page)
basically you will structure your url like this:
mysite.com/index.php/search/location/liverpool/category/golf
NOTE: the parameters are optional so you dont have to have both in there all the time. you can just as well do
mysite.com/index.php/search/location/liverpool/
and
mysite.com/index.php/search/category/golf
this way it will return FALSE if the element you are looking for does not exist
It would probably be best to keep your URI segments relavent no matter what they are searching for.
index.php/LOCATION/CATEGORY
If they are not interested in a location then pass a filler to the system:
index.php/anywhere/golf
Then in your code you just check for that specific string of ANYWHERE to determine if they only want to see the activity. I assume that you are going to be redirecting them with either links or forums (and that they aren't typing the URI string themselves) so you should be safe in just passing information that you expect and testing against that.
I use the format suggested by Tom above and then do something along the lines of below to determine the value of the parameters.
$segment_array = $this->uri->segment_array();
$is_location_searched = array_search('location', $segment_array);
if($is_location_searched && $this->uri->segment($is_location_searched +1))
{
$location = $this->uri->segment($is_sorted+1);
}
Have a look at http://lucenebook.com/#/p:solr/s:wiki and click around a bit on the left-hand navigation. Pay close attention to what happens in the url when you do. I really like this scheme for many reasons.
It's SEO-friendly.
"Curious" people can mix/match the urls and it still resolves to a proper search.
It just looks good!
Of course, the trick is really in the code, in how you build the thing. It took me a few weeks to sort it out, but I finally have my own version of that site. Just not ajax based, because I like search engines better than ajax. Ajax don't pay the bills.