WordPress.org

Ready to get started?Download WordPress

Forums

Search page on my custom page (8 posts)

  1. sricher
    Member
    Posted 2 years ago #

    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!

  2. sricher
    Member
    Posted 2 years ago #

    No one can help me with this?

  3. deepbevel
    Member
    Posted 2 years ago #

    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).

  4. sricher
    Member
    Posted 2 years ago #

    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.

  5. deepbevel
    Member
    Posted 2 years ago #

    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.

  6. sricher
    Member
    Posted 2 years ago #

    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!

  7. deepbevel
    Member
    Posted 2 years ago #

    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:)

  8. vjpo
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic