• Resolved Iseemtobeaverb

    (@iseemtobeaverb)


    Hello all. I’m setting up a new website using WordPress and would like to have a homepage as well as an auction page (using PHPbay). The problem is that all the categories I’ll be using for the auction information show up on my homepage. I’d like for the auction page to have separate categories and a separate sidebar if possible. Any thoughts on how I can achieve this?

Viewing 11 replies - 1 through 11 (of 11 total)
  • When you say “auction page”, do you mean you will use a wordpress “Page” ?

    S.

    Thread Starter Iseemtobeaverb

    (@iseemtobeaverb)

    Yes. I created a WordPress “Page”, but now I am thinking that this is not going to work because I cannot post to a page right? PHPbay works by creating posts for each category of item you choose to feature, you paste a bit of code in each post and the code will populate the post with eBay items in that category. So I may have a post for “bike frame” and that post would list 15 or so bike frames pulled from eBay.

    I was wanting to have my regular blog with all its requisite categories, as well as a separate area for the auction listings with its requisite categories.

    Ok, there is many way you can do that. You can use category, pages, wathever you like. I don’t know what will be the best to fit your needs.

    You could use pages for each of your Ebay items… Page1=bikes, page2=cars, page3=wathever…

    If you like to do so, then :

    1) make a page template named “auction_page”… For all these items…

    2) open your sidebar.php, and “save as” with another name… Let’s say “auction_bar.php”… Upload this new file to your template directory.

    3) In the “auction_page” template, do not call the normal side bar with the usual <?php get_sidebar(); ?>… Instead, use this code to display your brand new “auction_bar” :

    <?php include (TEMPLATEPATH . '/auction_bar.php'); ?>

    4) When you write a page to display some Ebay items, choose your template “auction_page”.

    You follow me ? Now, every page with this template will not display the “normal” side bar, but the “auction” side bar…

    You can then adjust what you want in each side bar… i.e. listing only certain category, only pages, some pages, wathever you like.

    You can even do it with categories (maybe better)… Let’s say your “auction” category have the id “24”, then create a category-24.php file and call your “auction” side bar instead of the normal one with the same code I wrote above… Category-24 could be the “mother” category of all your “items” categories…

    Like I said, there is many way to do so… Hope this gives you some ideas… ??

    S.

    Thread Starter Iseemtobeaverb

    (@iseemtobeaverb)

    Simon,

    Thanks for the explanation, I’ll try this out – though I may have more questions later. ??

    Thanks so much.

    -Verb

    Thread Starter Iseemtobeaverb

    (@iseemtobeaverb)

    Ok, I’m slowly getting this to work, but I have some more questions…

    I’ve gone through and created the following files in addition to their originals:

    sidebar_auction.php
    page_auction.php
    category_auction.php
    single_auction.php

    I’ve managed to get the sidebar_auction.php to load into page_auction.php by setting page_auction.php as a page template.

    I have the auction sidebar showing the categories that I want.

    As of right now, I can click on my auction page and see my auction sidebar, but when I click on a category and the archive for that category comes up I loose my auction sidebar, ditto for any posts in that category.

    My question is this:
    How do I call on the category_auction.php and the single_auction.php so that only the auction categories and posts will show the sidebar_auction.php?

    I see no use for category_auction.php.

    You can edit category.php (if it doesn’t exist, archive.php) and enclose the php statements that display the sidebar in a if conditional like so:

    <?php if(is_category(3) || is_category(6)) { //display sidebar_auction.php} else { //display the regular sidebar } ?>

    where 3 and 6 are IDs of your auction categories.

    You might want to read https://codex.www.ads-software.com/Category_Templates

    Re-hello Iseemtobeaverb

    Well, you’ll have to be more familiar with the template hierarchy of wordpress. As Srikat told you, you can’t use “category_auction.php” as is…

    https://codex.www.ads-software.com/Templates_Hierarchy

    As Srikat suggest, you could use the conditonals tags in your category page.
    https://codex.www.ads-software.com/Conditional_Tags

    On my side, I prefer to keep the things separate.

    So, if you see the template hierarchy :
    category.php will be used to display all categories.

    If you want a special file for your category, you have to name this file with the category ID (the number associated with the category in your wp-admin manage category section)

    Let’s say your category auction is number 14…

    So, your category file will be : category-14.php

    ===

    For different single page, this is how I do it :

    You will need three files. Your normal “single.php”… Then, make two other files. One named “single_normal.php” and the other, as you did “single_auction.php”

    With the template hierarchy, you can understand that worpress will always call “single.php” whenever you want to see a single post.

    So, in the “single.php”, you can use a conditional tag like this.

    <?php
    if (in_category('14')) {include (TEMPLATEPATH . '/single_auction.php');
    }
    else { include (TEMPLATEPATH . '/single_normal.php');
    }
    ?>

    This is all you need in this file. In english, it means : if we are in the category 14, get and display the “single_auction.php” file. Else, if we are in any other category, get and display the “single_normal.php” file.

    Of course, you adjust the (in_category('14') to fit your category id…

    You follow me ? You only use single.php like a switch, to ask wordpress to use a file or another…

    At this point, you can figure what to do next… Use your “single_normal.php” to display your “normal” content that you want in all your blog, and use “single_auction.php” to display what you want for posts under the auction category… The category 14… Your auction_sidebar.php for instance and wathever you like.

    There is almost nothing you can’t do with wordpress and the conditional tags, as long as you respect the template hierarchy… You must understand how wordpress “think”, then you know how to ask him to fit your special needs… ??

    S.

    Thread Starter Iseemtobeaverb

    (@iseemtobeaverb)

    Srikat & SimonJ,

    Thanks for the detailed reply. I think I understand what you’re saying. I’m sure it’ll become more clear once I mess around in the files a bit.

    Again, thanks for all your help.

    -Verb

    Thread Starter Iseemtobeaverb

    (@iseemtobeaverb)

    After implementing your advice I now have the auction sidebar showing for all my auction categories and posts.

    I did this by using the techniques you recommended, I now have the following files:

    single.php
    single_normal.php
    single_auction.php

    category.php
    category_normal.php
    category_auction.php

    Using single.php and category.php as switches for the other files.

    One last question though…

    I only have one post per category so I have no need for the intermediate “category archive” that comes up when I click on my categories from the auction page.

    Where might I start looking if I would like to skip straight from an auction category to the post in that category, bypassing the archive?

    Correct me if I’m wrong, but I’m guessing that I need to put a conditional statement in my category_auction.php telling WordPress that if a post is attached to a certain category ID to skip straight to the post or else show the archive for that category. I’m unsure of how to do this though.

    Thread Starter Iseemtobeaverb

    (@iseemtobeaverb)

    Well, I guess I posted prematurely. I found a solution by targeting the single_auction.php file in my category.php file as follows:

    <?php if (in_category(’23’) || in_category(’19’)) {include (TEMPLATEPATH . ‘/single_auction.php’); } else { include (TEMPLATEPATH . ‘/single_normal.php’); } ?>

    I think(hope) this is a good solution. ??

    Hola Verb.

    Just to be sure you understood what I said, the technique I wrote for two different “single” page is not made for category…

    … You can control the aspect of each category with a category-n.php file… n=the category id.

    You can of course use the category.php as a switch the same way I told you, but you have to use a different conditional tag :

    if (is_category('14')) not if (in_category('14'))

    IS… not IN

    ===

    For your question : I don’t know If I understand well what you wrote, but if you list links to category in your side bar, you will always go to the category page… There is no way to bypass the category to go in a single post with a category link…

    If you want, in your sidebar, a list of link direct for the posts in your auction category, you will need to list links to the posts.

    In this thread, we discuss some technique to do so… You can use an RSS feed from your category, a plugin, or a code HandySolo teached us :

    https://www.ads-software.com/support/topic/155342?replies=12

    S.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Seperate categories and sidebar per page’ is closed to new replies.