xceller8
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Modifying to have different backgrounds for different postsEUREKA!
It worked! Thank you alchymyth! It feels like an apple fell on my head and it worked. I would say that the apple was my idea and it just hit me but I couldn’t of done it without your help. Thank you again! Really appreciated!
Forum: Fixing WordPress
In reply to: Modifying to have different backgrounds for different postsHello,
So I’ve been trying to figure this out with the tutorial sent to me:
https://www.nathanrice.net/blog/wordpress-2-8-and-the-body_class-function/Since my method didn’t work. Initially I thought that by creating the .php files as quoted in the previous post for example creating the “template-diff-bg-demo1.php” file and writing to code:
body { text-align: center; background: #191919 url('images/bg1d4.jpg') repeat-x top; color: #FFFFFF; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 11px; line-height: 24px; } <body id=" <?php if (is_page_template('template-diff-bg-demo1.php')){ echo "template-diff-bg-demo1";} elseif (is_page_template('template-diff-bg-demo2.php')){ echo "template-diff-bg-demo2"; }else{ echo "default"; }?>" > div#wrapper { text-align: left; margin: auto; width: 800px; }
in the style.css and in the header.php:
<body id=" <?php if (is_page_template('template-diff-bg-demo1.php')){ echo "template-diff-bg-demo1";} elseif (is_page_template('template-diff-bg-demo2.php')){ echo "template-diff-bg-demo2"; }else{ echo "default"; }?>" > <div id="wrapper">
And by simply setting the template for the page to the desired php it would give that page the desired background image. This didn’t work and I don’t know why so I tried my interpretation of alchymyth’s solution which is in the header.php I replaced:
<body id=" <?php if (is_page_template('template-diff-bg-demo1.php')){ echo "template-diff-bg-demo1";} elseif (is_page_template('template-diff-bg-demo2.php')){ echo "template-diff-bg-demo2"; }else{ echo "default"; }?>" >
with…
<body <?php body_class(); ?> >
I tried this for the About section of my page and found the body class code to be:
<body class="page page-id-2 page-template page-template-about-php logged-in" >
So I took the “page page-id-2 page-template page-template-about-php logged-in” and revised the code in the style.css to read:
body { text-align: center; background: #191919 url('images/bg1d4.jpg') repeat-x top; color: #FFFFFF; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 11px; line-height: 24px; } body#page page-id-2 page-template page-template-about-php logged-in { background: #191919 url(images/bg1d.jpg) top center no-repeat; } body#page page-id-254 page-template page-template-default logged-in { background: #191919 url(images/bg1d3.jpg) top center no-repeat; }
This didn’t work and now I’m lost and not sure what to do. I’m reading up on Adding Classes in Nathan Rice’s tutorial and looked into conditions but with my limited knowledge in coding its like trying to fit a large square into a small circle hole and this is not Apollo 13.
If someone can help that would be great and appreciated. Thank you for reading my story.
Forum: Fixing WordPress
In reply to: Modifying to have different backgrounds for different postsThanks alchymyth, I’ll give it a try, but I don’t have ‘template-diff-bg-demo1.php’ of course so I’ll have to work on that part now, but once I do I hope it works.
Forum: Fixing WordPress
In reply to: Modifying to have different backgrounds for different postsSorry here it is in the code box
body { text-align: center; background: #191919 url('images/bg1d4.jpg') repeat-x top; color: #FFFFFF; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 11px; line-height: 24px; } <body id=" <?php if (is_page_template('template-diff-bg-demo1.php')){ echo "template-diff-bg-demo1";} elseif (is_page_template('template-diff-bg-demo2.php')){ echo "template-diff-bg-demo2"; }else{ echo "default"; }?>" > div#wrapper { text-align: left; margin: auto; width: 800px; }
Forum: Fixing WordPress
In reply to: Modifying to have different backgrounds for different postsHi alchymyth, thanks for getting back to me. I definitely restored the style.css code back to its original state, after seeing its result.
As instructed in the tutorial, I changed my header.php code to be:
<body id=" <?php if (is_page_template('template-diff-bg-demo1.php')){ echo "template-diff-bg-demo1";} elseif (is_page_template('template-diff-bg-demo2.php')){ echo "template-diff-bg-demo2"; }else{ echo "default"; }?>" > <div id="wrapper">
According to your suggestion I could input that code into the style.css so that it reads:
body {
text-align: center;
background: #191919 url(‘images/bg1d4.jpg’) repeat-x top;
color: #FFFFFF;
font-family: ‘Lucida Grande’, Helvetica, Arial, sans-serif;
font-size: 11px;
line-height: 24px;
}<body id=”
<?php if (is_page_template(‘template-diff-bg-demo1.php’)){
echo “template-diff-bg-demo1”;}
elseif (is_page_template(‘template-diff-bg-demo2.php’)){
echo “template-diff-bg-demo2”;
}else{
echo “default”;
}?>” >div#wrapper {
text-align: left;
margin: auto;
width: 800px;
}`And this should work? My apologies if I misunderstand, I’m still trying to get a handle on the language.
Forum: Fixing WordPress
In reply to: Modifying to have different backgrounds for different postsOk I tried it and I think I need to change something because now everything that was in the center of the page is now in the left and right
S.O.S
Forum: Fixing WordPress
In reply to: Modifying to have different backgrounds for different postsThanks for the comments alchymyth and t31os_
I reviewed the two sites and well once again limited knowledge = me confused. I did some further digging and I found this site which I thinks is pretty much what I need different templates having different backgrounds.
https://fearlessflyer.com/2009/05/how-to-change-the-background-dynamically-in-your-wordpress-theme/The only problem I’m having, and currently testing out, is modifying my style.css file. In his “How To…” it says modify the body ideas to match what is posted in the header.php. Lets say I kept all the example names the same way and it is the same as what is coded in the header.php would the change I made work?
Below is how the current style.css is written:
body { text-align: center; background: #191919 url('images/bg1d4.jpg') repeat-x top; width: 100% height: 100% color: #FFFFFF; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 11px; line-height: 24px; }
And his tutorial outlines to change the body as:
background:url(images/default-bg.jpg) top center no-repeat #000000; } body#template-diff-bg-demo1 { background:url(images/default-bg2.jpg) top center no-repeat #000000;} body#template-diff-bg-demo2 { background:url(images/default-bg3.jpg) top center no-repeat #000000; }
So would their be any problem if I were to modify the original code to do this:
body { text-align: center; background:url(images/default-bg.jpg) top center no-repeat #191919; } body#template-diff-bg-demo1 { background:url(images/default- bg2.jpg) top center no-repeat #191919;} body#template-diff-bg-demo2 { background:url(images/default-bg3.jpg) top center no-repeat #191919; } color: #FFFFFF; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 11px; line-height: 24px; }
?
I’m confused because how this code was written is different what I am seeing in these help pages. Thanks again for your time and the help given.