Viewing 10 replies - 1 through 10 (of 10 total)
  • Have you tried setting up a custom menu that doesn’t include this page?

    Thread Starter Jackie Chan

    (@jackie-chan)

    I have a custom menu set up however this is not what i mean, The red box on the actual content page, i need it moved so there is no white gap above it or next to it so it would look like a header, yet still on the actual content page.

    I hope this makes a bit more sense if not i will upload an example of what i mean.

    The picture is insede of <h1></h1>

    Check first your css. There is top margin for that.

    Check this too from css:

    – .home #primary-content {padding-top: 30px; /* because we don’t have a content title */}

    You have a few css rules that are pushing it down in addition to it being wrapped in a p tag from the visual editor. I you want this on every page I would add it in the the page template itself. It should look something like this:

    <div class="post">
    <?php if ( have_posts() ) :
    <img class="post-header" src="" />
    while ( have_posts() ) : the_post(); ?>
    <div class="post_content">
    <?php the_content(); ?>
    </div>
    <?php endwhile; ?>
    <?php endif; ?>
    </div>

    This will allow you to easily give that image a class that you can manipulate and avoid visual editor quirks. If you want it to be a different image on each page just use the featured image or a custom field to grab the url.

    Thread Starter Jackie Chan

    (@jackie-chan)

    Thanks for the replies, where can i find the Page Template to paste the code?

    You will have to ftp into the directory. It will be in your theme folder which is in wp-content > themes > your theme.

    Backup the old page.php file first. Also don’t just paste the code. Yours will be slightly different so you are using the basic idea not the code verbatim.

    Thread Starter Jackie Chan

    (@jackie-chan)

    I dont really understand CSS, i have page.php open, what do i do next?

    Well, first you aren’t looking at css. You’re in a php file that likely has a mix of html and php.

    Your best bet if you don’t understand the code is to just start playing with template tags. As long as you put them in the loop they will do something. They are just bits of code that tells wordpress to grab something from the db and print it as html on the frontend.

    The loop is a way to structure how and when those things get printed. if posts is looking to see if any posts exist. If any exist no matter how many it will do something once. While have posts looks at how many posts you have and does something one time for each post that exists. The post is just a way for wordpress to get all the db info regarding your posts.

    You need to put the image in the if posts part of the loop so that you get the one image in your page. You need to manually set your class so you can target it later with css and avoid the visual editor quirks.

    Hope this makes some sense to you. The best thing for you to do is just backup your current files and then start breaking stuff. Pull things out of the current page.php template, add new template tags, insert the image in different places and see what happens. Once you get a fair understanding of how to do what you want specifically restore your backup and make the mods.

    Best of luck

    Resources:
    https://codex.www.ads-software.com/Template_Tags
    https://codex.www.ads-software.com/The_Loop

    Thread Starter Jackie Chan

    (@jackie-chan)

    I’ve put the code below into Page Template [page.php] however it just makes my website blank, is there part of the code that i need to change?

    <div class="post">
    <?php if ( have_posts() ) :
    <img class="post-header" src="https://www.designandprintcentre.net/wp-content/uploads/2011/06/Header2jpg.jpg" />
    while ( have_posts() ) : the_post(); ?>
    <div class="post_content">
    <?php the_content(); ?>
    </div>
    <?php endwhile; ?>
    <?php endif; ?>
    </div>

    [Please post code snippets between backticks or use the code button.]

    into Page Template [page.php]

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Moving image on page’ is closed to new replies.