I want add a pagination
How can I do this on both loop.php and search.php. I want show alphabetic index to search only posts with starting letter = [E] for example. Right now, if I search with E it search for any match, title+content+part of title
.
[A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] …….[Z]
Easy Post Title – By Admin on 2013
post content….bla bla bla…
Example Post – Another Test – By Admin on 2013
post content….bla bla bla…
[A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] …….[Z]
This is the code I get from here, but I don’t remember the exact page, and this is my working page of letter B on my website (using the same code as you see below)
This is a nuts-and-bolts way of getting at this problem. This modifies the SQL query itself, but it’s pretty much a 1 liner. I’m sure there are other ways, but this method is not very invasive to the query building process as it only mods the SQL at the end. Note I realize this method could be usurped by the syntax of a query builder at some point.
First hook into the filter:
Then let’s modify the exact portion of the SQL request, note that we’re looking for the condition where the search / filter being run is for a First Letter and in our particular case, it is if the $input contains ‘short-company-name’. Tune your conditional to your liking.
Note that if this is not exactly like your particular query, just dump out the $input, find the errant one, and tune the SQL at this stage so that your query is looking for “… LIKE [letter]%” against the column you need. All the “replace” is really doing is exactly locating the particular query and removing the “LIKE %[letter]%” and replacing it with “LIKE [letter]%”.
I did it this way because I was using a front end plugin for filtering / querying posts already and could not easily use a stand-alone SQL query to just find a first letter. I was dealing with a multi-parameter, user driven, and / or logic filtering query situation and it was easier to modify the end result for this one case.