I run http://www.rapnews.co.uk and I was wondering how hard it would be for a novice user of wordpress to make an alteration to my main page’s design, so that there was a banner at the top of the list of posts, beneath the header image.
What I’m aiming to do is something similar to what’s show in this photoshop mockup:
If I could allow this banner to rotate a few different images in the same location, that’d be great also.
Thanks for any advice in advance.
1) Go edit your Theme file, edit the
index.phpand (if exits) the
home.php. Somewhere before The Loop starts (i.e. usually the line that says
if have_posts()etc.), add in the
imgtag for your banner.
2) For banner rotation, check out the Codex Plugins list for the “Random Banner” plugin, and instead of the
imgtag in (1) above, use the plugin to randomly display one of your banner images.
Thanks a lot for your very useful reply. I added the code
before the loop starts and it successfully put the image in roughly the same place.
my problem now though is that the image begins directly beneath the site’s header logo. I need there to be a gap, such as that in my example image I showed in the post before. i tried tags to no effect.
I would be extremely grateful of any help that you can offer me. thank you ever so much,
I would suggest first that you put an ID on that image, e.g.
<img id="admock" src="..." .../>, and then in your theme’s style.css, style it appropriately.
You need to place this image tag after your
<div id="content" class="...">tag. This means that it will have the same width boundaries as your posts and not eat into your sidebar space.
If you want to adjust the image’s spacing, dump this into your theme’s
margin: UP RIGHT DOWN LEFT;
admock” is the ID you gave your
imgtag, and UP, RIGHT, DOWN, LEFT are four numerical margin values for the image, in that order.
But before you do this, first try enclosing the
imgtag with a
<div class="post"><img ...your image...></div>
This should work. If not, then try the ID thing.
Thanks for your help.
I added an ID to the image and the image appeared successfully, just without the correct spacing between it and the bottom line of the site’s header title image. Luckily the image is the correct width as required.
I tried editing the style sheet with the enclosing method you suggested. This didn’t work in getting space between the bottom border of the title graphic and the top border of the advert banner.
I then tried doing the style sheet suggestion of assigning margin values, but this didn’t work, and regardless of how big I set the values, no change on the presentation was made.
Do you possibly have any other suggestions, or would you be so kind as to paste me some code which you feel would work? I’d be very grateful. I’m quite a novice to this. Someone else designed my entire site but they’re no longer about.
Just upping this so that the Americans can see it as they’re waking up about now? Don’t want my problems to get deeply rooted and buried!
If you could upload your theme’s
index.phpsomewhere, and also the banner image, maybe we can be more specific, perhaps getting to a solution rightaway. It’s inefficient to keep on guessing and trying.
Hi. Thanks very much for your extended help. I know I’m being quite demanding. You’re really generous with your time!
The banner image is located at:
whilst the index.php is in the main public_html folder of rapnews.co.uk as well as wp-content. For some reason it kept downloading as a blank txt file. I copied its content and made a .txt file but wherever I uploaded it on my site, it wouldn’t let itself get downloaded or viewed for some reason. If you could ‘view source’ on my actual site, rapnews.co.uk that’d be great.
View source is not going to help as I need to see the PHP code, not the resulting HTML. What you could do is zip it up and upload it using the WordPress built-in file upload feature, then give a link to it here.
You can’t view the
.phpfile directly because your server is executing the code.
If you still can’t get it to work, just send me the index.php file via email to
alexwang.moonfire AT gmail DOT com.
Here’s my suggestion:
<div id="content" class="narrowcolumn">
<p class="postmetadata alt2"></p>
<?php if (have_posts()) : ?>
Basically this just replicates your post structure to get the same spacing and lining. It ended up I didn’t really need to see the index.php—contrary to what I suspected, there’s nothing weird going on in the source code. Would have got this resolved two days ago if I had read your reply carefully. My apologies.
No need to apologise at all. You’ve been a great help! Thanks for this code. I’m sorry for being dumb, but where should I insert this!? I’ve tried a few positions in the index.php and I keep getting ‘error on line x’ errors when trying to view the site. Best, Tee.
If I’m not mistaken in reading whats been going on, copy that snippet of code and paste it over whatever you currently have been the first line and last line of the snippet in your index.php. Remember of course to keep a backup 🙂
edit: oops, too long trying to figure out what was going on while you were working it out 😛
- The topic ‘Adding a banner onto my main WP page’ is closed to new replies.