Support » Fixing WordPress » Search page on my custom page

  • sricher

    (@sricher)


    Hi,

    I’m currently developping my own theme. I have this custom portfolio page that display blog posts “specially”. I want to add a search box and category filtering on that page. I’m not really sure how I should go about this.

    I have this portfolio.php page that is a also a template. And so I created a page in the wp_admin, using that template. The permalink now is mysite.com/portfolio/.

    Adding search parameters will send my site to index.php rather than to portfolio.php so I currently have trouble getting my “s” parameters from the query string.

    I’m an experienced developer, just quite new with wordpress and trying to do it the right way (I could simply create my own SQL queries and bypass the whole thing and code it myself, but then what would be the point of using wordpress hehe).

    Thanks for any help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • sricher

    (@sricher)

    No one can help me with this?

    deepbevel

    (@deepbevel)

    Search widgets are default with wp. (Apperance/Widgets) You can also find many search plugins.

    You can display categories and or category content as lists or each on it’s own archive page. You can do that with query_posts or just use plugins which do the same, or create category pages with a custom menu (Appearnce/menus).

    sricher

    (@sricher)

    I’d like to simply use query_posts, but my portfolio.php page (template name portfolio) (I also have a page in the admin), but whenever I put in s=xxxxx, the site uses index.php and not portfolio.php.

    I guess I’ll try and name my search parameter differently.

    deepbevel

    (@deepbevel)

    I’m afraid you lost me. Are you talking about a custom page template? if so how are you trying to get it? Normally you select them in the page editor, but you can also redirect to them through the wp hierarchy using taxonomies like categories, tags, page id’s, custom taxonomies, ect. This is done with conditionals.

    sricher

    (@sricher)

    Hmm… I’m not so sure, currently I created a portfolio.php file and then at the top I wrote:

    <?php /* Template Name: Portfolio */ ?>

    Then I filled my .php page with the code for the stuff I want to display.

    Next I went in my admin and created a new “page” and said it was of template type “Portfolio”.

    Now at this point it works well, I have some links in my theme that point to /portfolio/ and that renders the correct page.

    Currently I changed my “s” param to “rech” , and now I’m getting it directly from $_GET. Next I plan to make a custom query and then loop that to show the “search result” kind of manually.

    Maybe I’m totally going wrong about this.

    Thanks!

    deepbevel

    (@deepbevel)

    You are more advanced in php than I, but I do know wp. Sounds like you’re on the right path, if not it will soon appear. Good luck:)

    vjpo

    (@vjpo)

    According to template hierarchy WP uses index.php if there is no search.php.
    You can set your search.php to display portfolio items through conditional statements.
    IMHO It could be better to create custom post type for portfolio items if you are planning to use standard posts also.

    You can goole for an info about custom search output by category or custom post types.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Search page on my custom page’ is closed to new replies.