Coding advice for Custom Page Template
-
I have two sidebars and only want to get rid of the right one on the home page.
My page.php includes the following:
<?php get_sidebars(); ?>
<?php $theme->hook(‘main_after’); ?>
</div><!– #main –>
<?php get_footer(); ?>
I have copied this for my new template. How do I alter this to remove the right sidebar?
The style.css looks like this:
[Please see the forum guidelines re: posting code –
http://codex.ww.wp.xz.cn/Forum_Welcome#Posting_Code ]
-
I don’t understand what ‘backsticks’ are? Even after reading about it?
So I’m going to guess:
I have two sidebars and only want to get rid of the right one on the home page.
My page.php includes the following:
<?php get_sidebars(); ?> <?php $theme->hook('main_after'); ?> </div><!-- #main --> <?php get_footer(); ?>I have copied this for my new template. How do I alter this to remove the right sidebar?
Yay! I think I understand backsticks!
So here’s the rest of my question…
Once I’ve got rid of the side bar do I need to alter the code in the style.css or custom css?
What code do I need to write to stretch the content over the space left empty by the removed sidebar?
I will be calling my custom page template CustomRight. Would it be correct to enter the following code
.customright {width: 100%;}Thanks
In general terms, you would need to remove the call to the sidebar and then using the existing CSS selectors, change the layout of those elements to fill out the space. A browser tool like Firebug should be able to help you.
Hope you are using a child theme so that your changes will not be erased when the theme is updated –
https://codex.ww.wp.xz.cn/Child_Themes
Specifics of the coding are theme specific, so you may want to consult with the developers of your theme – as these forums have no way to support commercial themes.
Thank you for replying
OK. I think I need to do some more research on what child themes are. I’ve read a bit about them but not fully grasped it. I haven’t changed anything yet. I want to be clear that I know exactly what to do first.
I might ask for more help when I can ask some intelligent questions!
Sorry about the post above re the code. I managed to work out the
backsticksfor the post above that one. Putting in the samebacksticksdidn’t seem to work the second time round? Don’t what I did wrong?I found this video
The video didn’t mention child themes but did suggest backing up the website.
If you modify the theme files directly – or add new ones, they will all be lost when the theme is updated. A child theme avoids that :)!
I was going to download filezilla. Log on to FTP. Transfer the page.php and style.css file to my computer. Then create a new file called page-customright.php. Save this file and put the template name at the top. Then copy and paste code from page.php and modify it to only the side bar on the left. The video I have been using for help is for removing one side bar with none remaining. Therefore I don’t know what I need to enter to keep the left sidebar.
My understanding to stretch the content is that I also need to change
<div id="content">' to '<div id="content" class="customright">I think I then need to modify the style.css file to add an entry for the css class called customright in the page-customright.php file. I’m not sure what code I need to enter here? The video tutorial I have been referring to suggests the following
.customright {width 100%;}Do I still enter 100% or is this different if I still have the left sidebar?
The final step was to transfer the page-customright.php file and amended style.css file to the host.
Not mentioned in the video is whether to transfer back the original page.php file? I would have thought this would be necessary as it’s still required for pages requiring both sidebars.
Apologies if I’m going totally down the wrong track! Also apologies if any of the ‘backsticks’ above haven’t worked.
Cheers
The very first step is to create a child theme – see that link I posted above.
Then put the custom template file in the child theme.
And in the child theme style.css file, ADD CSS to modify the layout of that new template. The child theme style.css file should contain only changes, not a copy of the entire parent theme CSS file.
But all of this may be theme-specific – I have no idea how the theme you are using is coded, and these forums have no way to support commercial themes, so you really should be asking the developers of the theme for help with this if the above doesn’t work.
http://codex.ww.wp.xz.cn/Forum_Welcome#Commercial_Products
And yes, all of these files, including the child theme, need to be uploaded to the server via FTP.
Thank you WPyogi.
I will look into this. Have to go out now. Thanks for your help thus far.
Cheers
Thanks for your help WPyogi. I’ve looked at the link you provided for child themes. I think I’m out of my depth so have decided to pay someone.
A local company has quoted 2.75 hours work to create custom template for the home page. If I want custom templates for the other pages it will be another 1.5 hours work as they say they will need to ‘stretch’ content for each page. Does this sound right to you? I don’t mind paying but I thought the point of a custom page template was to be able to use it on any page? I’m not sure I’m allowed to ask this as I know it’s not OK to look for business on this forum. This is not a commercial dispute. I would just like to know what is involved so I can make an informed decision. I’m using Canode theme.
Thanks
The topic ‘Coding advice for Custom Page Template’ is closed to new replies.