WordPress.org

Ready to get started?Download WordPress

Forums

URL Beyond Category Page (6 posts)

  1. Gemfruit
    Member
    Posted 1 year ago #

    I'm wondering how I would go about making a php file that is like the category page, but specific, and has the url structure like so:

    site.com/category/custom-php-page-here

    The permalink structure for my site is as follows:

    site.com/category/post-name

    Thing is, that's for posts. My category pages are all customized individually with a php page for each, but I want to go beyond site.com/category, with a php file for the specific pages I have in mind.

    Is this possible, and if so, how do I go about doing this?

  2. doc4
    Member
    Posted 1 year ago #

    Since each category has it's own php page you shouldn't have trouble making any one of them the parent page of a new page. Create the new page and be sure to add a parent in the right side dropdown, typically under the save area.

  3. Gemfruit
    Member
    Posted 1 year ago #

    Each category doesn't actually have a "Page", as in a wordpress page, each category simply has a .php file, like so:

    category-cat1.php
    categroy-cat2.php
    etc

    I'm not using actual pages, and was told I should avoid doing so. I know that WordPress internally expects there to be a page for each category, so having a category-name.php file works. Thing is, most practical navigation / url structuring calls for going beyond one or two / in the url. I want to do site.com/category/post-name, as well as site.com/category/some-custom-php-created-page (page being webpage, not an actual page).

  4. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    I'm not using actual pages, and was told I should avoid doing so

    Where and more importantly, why?

    A custom category template file will be used when a category is navigated to.

    http://codex.wordpress.org/Category_Templates

    You could go further and use Custom Post Types.

    http://codex.wordpress.org/Post_Types#URLs

  5. Gemfruit
    Member
    Posted 1 year ago #

    I originally designed the site using pages, and changed them because of a technical issue, which then lead to me reading that it's a bad practice. Essentially every article I found (and many conversations on these forums) stated that using pages almost always fights against what WordPress naturally does, and just creates a messy site. Every topic where people had the same questions as me, they thought pages were the trick, but we all eventually found out that using the template hierarchy and posts was the way to go.

    As for custom posts types, I've read about those, but I'm not sure they're a good fit here. I'm not trying to create a post that's using formatting based off of a php file, I'm trying to create pages, with lots of content from all over. Imagine this:

    site.com/restaurants
    AND
    site.com/restaurants/specific-restaurant OR site.com/restaurants/listing

    site.com/restaurants would use the category template. Here you could easily use query_posts to list the most recent, some featured post, etc. Think of it as a home page, for a single category, rather than the classic listing of all posts (default behavior).

    Then site.com/restaurants/specific-restaurant is simply a post, about a specific restaurant (there would be many of these).

    Lastly, you want to list all of the restaurants on a page, perhaps with some featured restaurants at the top, or the ability to sort the restaurants a certain way (not really post material if you see my point). This would be at site.com/restaurants/listing, and would WANT to use a .php page for it's styling, but how?!

    If you followed along, I think you can see how my image is a very good site structure. It's very logical, it handles my data well, and the navigation makes sense. I simply want to figure out how to give a page with a url beyond category, the ability to be a .php script.

  6. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    As for custom posts types, I've read about those, but I'm not sure they're a good fit here. I'm not trying to create a post that's using formatting based off of a php file, I'm trying to create pages, with lots of content from all over. Imagine this:

    site.com/restaurants
    AND
    site.com/restaurants/specific-restaurant OR site.com/restaurants/listing

    Actually, I believe that is exactly what CPT's can do well.

    site.com/restaurants is a custom post type archive page
    site.com/restaurants/specific-restaurant is a custom post type single post page.

    single posts of a custom post type will use single-{post_type}.php
    and their archives will use archive-{post_type}.php

Topic Closed

This topic has been closed to new replies.

About this Topic