Custom Templates Not Duplicating Actions On All Pages
-
Hello,
I’ve been studying all morning about creating custom templates for a few of my pages, and I’m having trouble understanding how to recreate the custom features of one across several pages.
I want “The Gallery” to be dark and full-width. I can make this happen for this one page by adjusting the “full-width” template which came with my Custom Community theme by inserting the following into it:
<?php if (is_page(‘1691’) ):
// page 1691 ?>
<style type=”text/css”>
body {background-color:#505050;}
div#container {background-color:#303030;}
</style><?php endif; // end the if, no images for other other categories ?>
See here for a test page to demonstrate.
Perfect! Looks super. Now, I want to recreate this action (dark background and container with no sidebar) in the Photos and Videos pages, as well. The first thing I tried was to simply add the code above with the page numbers for the Photos and Videos pages into my theme’s standard “full-width” template again, like this:
<?php if (is_page(‘xxxx’) ):
// page xxxx ?>
<style type=”text/css”>
body {background-color:#505050;}
div#container {background-color:#303030;}
</style><?php if (is_page(‘yyyy’) ):
// page yyyy ?>
<style type=”text/css”>
body {background-color:#505050;}
div#container {background-color:#303030;}
</style>That didn’t work. Got a syntax error. So, I tossed that simple attempt, and moved to plan B, which I though would be the “right” way to do it: I used the theme’s original “full-width” template as a base for my own, thinking that I’d assign each of my custom pages it’s own custom template. So, I copy and pasted, verbatim, the code from my theme’s “full-width” template, which I know worked great for one page, and made it the foundation for the Photos and Videos pages. Of course, the only change I made was to the bit of syntax (at the top of this post) to reflect the appropriate page ID for each of my pages. I uploaded those files to my theme’s folder in ftp. Finally, I went to the “Edit” screen for each of these three pages and selected the appropriate template from the drop down menu.
I was certain this would work…
No-go. I can get the background and container colors to change on only one page, and I can’t make the screen full-width on any of them! This is strange because I used the “full-width” template for my base for my own custom template.
The Gallery: https://centraloverland.com/blog/?page_id=1683
Photos: //centraloverland.com/blog/?page_id=1104
Videos:http: https://centraloverland.com/blog/?page_id=1664Can someone help me understand why the custom templates I’ve created won’t display the same characteristics as the base template from my theme?
I’m thinking now that I should just create a temple that dictate the dark background and container and no sidebar, but is not page specific, like my code above demands. That way, I could just choose that template for every subsequent page I want formatted like this. Problem? I don’t know what that code looks like. What would I change from the examples above?
Thanks so much. I’m doing my best to learn this coding stuff.
- The topic ‘Custom Templates Not Duplicating Actions On All Pages’ is closed to new replies.