Jump to content
xisto Community
Sign in to follow this  
Ahsaniqbalkmc

Php Code For A Search Form

Recommended Posts

I had a static HTML website made in front page and I had placed a google custom search on it. A good friend of mine ("Starscream") on this Xisto forum suggested to go to the CMS based website instead of the Static HTML website so I went for it. Now I am very happy with the way things are going in the new interface. It is really easy to add new content and modify old content and there is not much problem with the SEO.I have faced a problem while I am in the last steps of finalizing the "design" of my website. The default search form of my theme displays result unexpectedly. Suppose I write a search term anatomy and press enter, instead of displaying the list of pages containing the term anatomy based on relevancy, it just opens the pages and display complete pages as posts in blog. Suppose three pages match the search keyword, the result of the search will be a single page containing three pages on basis of "unknown".First I want the seawrch to return a list of pages and not complete pages and second I want the most relevant page to appear first.

Share this post


Link to post
Share on other sites

This problem is because your site is treated as static by wordpress core so it diverts the results to specific pages instead of giving the options like in dynamic pages. The search form tries to get the close or accurate keywords and just displays the page. This is sometimes a glitch because you don't get real or accurate results that you want from the query. You can do one thing here though, just use plugin that has google search enabled in it. Also don't forget to use your own adsense ID in it. This plugin will give multiple results to your page and are likely to be relevant. I'm sure it is close to what you'll find for static search widgets. Another alternative is to use search everything page which brings closer results and displays it on page. It never redirects to certain page which is what you want here. If i can understand your problem correctly.

Share this post


Link to post
Share on other sites

This problem is because your site is treated as static by wordpress core so it diverts the results to specific pages instead of giving the options like in dynamic pages. The search form tries to get the close or accurate keywords and just displays the page. This is sometimes a glitch because you don't get real or accurate results that you want from the query.
You can do one thing here though, just use plugin that has google search enabled in it. Also don't forget to use your own adsense ID in it. This plugin will give multiple results to your page and are likely to be relevant. I'm sure it is close to what you'll find for static search widgets.

Another alternative is to use search everything page which brings closer results and displays it on page. It never redirects to certain page which is what you want here. If i can understand your problem correctly.

Adding google custom search engine will not be a problem but its not what I am looking for. I searched on the internet to find codes and I did find a lot of codes but none of them worked.
There were complications like having a separate search.php file or adding code to the header.php file. I did not get it. Is there any way through which I can make my own search engine functional without going for additional plugins.

Share this post


Link to post
Share on other sites

This will be possible only if you code your own theme and set functions for it. Right now you're writing loop which is restrictive to this theme. So only way to extend it's functionality is with the help of plugin or by manually adding search.php or header code.If you write your own theme and design your own search loop for it then things will be the way you want. Basically i found your problem of search result a bit ambiguous. I mean if search results are relevant then why remove it from the search ?If you are going to write your own theme then i suggest taking a look at thematic framework. This framework is free and will make your wordpress theme learning development easier. You can also get a lot of help from thematic developer on forums. I'm sure that guy is likely to know about custom search results the way you want to do for your static site.

Share this post


Link to post
Share on other sites

This will be possible only if you code your own theme and set functions for it. Right now you're writing loop which is restrictive to this theme. So only way to extend it's functionality is with the help of plugin or by manually adding search.php or header code.
If you write your own theme and design your own search loop for it then things will be the way you want. Basically i found your problem of search result a bit ambiguous. I mean if search results are relevant then why remove it from the search ?

If you are going to write your own theme then i suggest taking a look at thematic framework. This framework is free and will make your wordpress theme learning development easier. You can also get a lot of help from thematic developer on forums. I'm sure that guy is likely to know about custom search results the way you want to do for your static site.

I think thematic is good but will I need some knowledge of PHP for making things really good.
How long will it take me to learn php.
What do you suggest me? should I start learning php and waste another weak or two?

Share this post


Link to post
Share on other sites

Errm. You don't need to learn much PHP in order to code theme or to modify them. You can simply learn about wordpress themes from cheatsheet and building some themes from scratch. Thematic developer learned PHP just by modifying the themes and later worked on standalone projects. And if you're trying to earn online and want to have some personality online than learning programming languages never goes to waste. It's my personal opinion, not sure what you think. If you're really interested in PHP then i suggest you to take some chapters from W3Schools online and then work on your own. You can use XAMPP on your machine to code few PHP pages and apps. This is easy to work with and many users are learning this way. Atleast i learned things here this way, hope that helps.

Share this post


Link to post
Share on other sites

Errm. You don't need to learn much PHP in order to code theme or to modify them. You can simply learn about wordpress themes from cheatsheet and building some themes from scratch. Thematic developer learned PHP just by modifying the themes and later worked on standalone projects. And if you're trying to earn online and want to have some personality online than learning programming languages never goes to waste. It's my personal opinion, not sure what you think.
If you're really interested in PHP then i suggest you to take some chapters from W3Schools online and then work on your own. You can use XAMPP on your machine to code few PHP pages and apps. This is easy to work with and many users are learning this way. Atleast i learned things here this way, hope that helps.

Yes I have some knowledge of php and I have xampp already installed on my pc. I have read a book on the topic php for complete beginners and I have got some introduction to php. The problem with me is that I cannot remember those codes because I read the book at a pace of about 100 pages in 3 hours. (I don't think its a big problem because you can search anytime for whatever you want). At this pace I am not going to learn any php but I just wanted an introduction so that I can edit some pages at my website.
I like learning from ebooks and this sort of stuff. I do not like tutorials but if they are excellent, then I do take them. If you can suggest any book to me for learning php, please do it. I really want to make a nice website that can earn me good income.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.