- This topic is empty.
-
AuthorPosts
-
April 5, 2009 at 7:41 pm #24500cjkMember
Hey all,
I have been playing with the custom template function in WordPress as I would like to use a special layout for a special section of pages.
I have figured out how to create a custom page.php file and assign it etc., however, I have not been able to find in the codex (or figure out even if it is possible) whether I can grab a custom header.php sidebar.php that would only appear in pages that use the custom template.
In a nutshell, I would like to use a different header and sidebar on pages that use the custom page template.
Is there a way?
Best regards,
ChrisApril 5, 2009 at 10:36 pm #55839apostropheParticipantJust create your custom sidebar/header and save it as sidebar2.php/header2.php or something equally imaginative and the call it/them in your custom template with
Code:
April 7, 2009 at 10:25 am #55931cjkMemberHey thanks Apostrophe,
I would have been surprised if there wasn’t a way to do this (seemed like a popular request for feature to me!) but couldn’t find it in the codex at all. You saved me a ton of time!
I am going to assume that I directly replace the get_header and get_sidebar with these include calls?
Cheers!
ChrisApril 7, 2009 at 10:42 am #55932apostropheParticipantThat’s right. get_header and get_sidebar are just WordPress specific functions relating to the sidebar and the header. Just place the includes where you would usually use the WP functions.
April 8, 2009 at 4:21 pm #55989cjkMemberHey,
Close…. but not quite what I was hoping for. My sidebar.php is widget ready and so of course any widget that I have in the main sidebar shows up in any and all copies, if they are also widget ready (which i would really like if possible as there are some widgets I would like to use on certain pages only). I guess I could just strip the widget function out of those custom sidebars, but I would really like the functionality.
So, I dug into the codex one more time and found this page http://codex.wordpress.org/Customizing_Your_Sidebar where it explains how to;
Quote:New way of adding sidebarsYou can register more than one sidebar. In wp-includes/widgets.php you find the function-definition for register-sidebars() which you may use in your custom function within your theme-folder (functions.php – if not existent, create an empty php-file by that name):
Code:‘custom’ would mean you have to create a custom sidebar-file under the name sidebar-custom.php. Sidebars get indexed. Your default sidebar (sidebar.php) gets indexed as 1. Every succeeding one will have an index higher than 1. You will see your sidebars now listed in ‘Apearance’ -> ‘Widgets’.
In your sidebar-templates you may now call the dynamic generated content (widgets) by the index of your sidebars:
Code:
… regular html …
… regular html …
You can integrate your sidebars in your template-files (e.g. index.php, single.php, archives.php):
Code:gets you the default sidebar.
Code:should display your custom sidebar.
What I can’t figure out is where and how to put this code in my functions.php file. I am looking at the default functions.php for Kubrick. The first 8 lines are:
Code:‘- ‘,
‘after_widget’ => ‘‘,
‘before_title’ => ‘‘,
‘after_title’ => ‘‘,
));Which doesn’t exactly match up the code from the codex!
This is then followed by a lot of code which seems to be relevant only to the function for modifying the kubrick header image and background colours, which I don’t use.
I am thinking I can just delete everything after line 8, but am hesitant to do so!
Anyone able to guide me through this? What a great learning experience! :D
April 8, 2009 at 4:38 pm #55991apostropheParticipantFunnily enough I saw this article today and thought of you http://wpcandy.com/articles/tutorials/how-to-make-the-most-out-of-your-sidebar.html
April 9, 2009 at 1:56 pm #56041cjkMember"apostrophe" wrote:Funnily enough I saw this article today and thought of you http://wpcandy.com/articles/tutorials/how-to-make-the-most-out-of-your-sidebar.htmlThanks!! This post and link are extremely useful. I have it working nicely locally and "hopefully" all will go well when I upload to my site.
Cheers!
ChrisJanuary 23, 2011 at 10:16 am #64434mlynnMemberYou could also simply use a plugin to create custom sidebars for each page or post. The Graceful Sidebar Plugin does this for you.
- ‘,
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.