• I’ve been asked to set up a wordpress site that the home page is pretty much static, but there is a block of text next to a picture in the post that will appear as the homepage that they people would like to be able to change without messing up anything else on the page. Is there a way to do this?

    Thanks,
    Eric

Viewing 15 replies - 1 through 15 (of 16 total)
  • Yes, the easiest way to do this is to create a new template called front-page.php

    When you have a template named front-page.php, WordPress will use it only for the home page.

    You can then insert the code you need to display that one image and anything else you want around it.

    Thread Starter saundhaus

    (@saundhaus)

    Here’s an example of what I need to do. I’ve pointed out the only thing that needs to change so that will help.

    https://baghdadbythebaysf.com/images/sample.jpg

    I know in most CMS systems they used blocks to build a page. I’ll look into the custom template though.

    Thread Starter saundhaus

    (@saundhaus)

    This is actually a semi-static page as the text noted in the picture attached in the previous post will change from time to time.

    Eric

    Yes that’s what I thought.

    You will need something like this:

    <?php get_header(); ?>
    <div id="main">
    	<div id="quote">
    	Insert your quote here
    	</div>
    	<div id="main-part">
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<?php the_content();?>
    	<?php endwhile; endif; ?>
    	</div>
    	</div>
    	<div id="bottom">
    		Insert bottom stuff here
    	</div>
    <?php get_sidebar(); ?>
    </div><!-- end of main div -->
    <?php get_footer(); ?>

    You’ll want to use better div names though.. Those are just examples.

    Thread Starter saundhaus

    (@saundhaus)

    Would I apply that to a new page template and put that above the html below?

    Thanks,
    Eric

    This would be the front-page.php

    You are still using your header.php, footer.php and sidebar.php

    There’s no other html code…

    I may not be understanding what you are wanting to do…

    Thread Starter saundhaus

    (@saundhaus)

    I just need to have front-page.php be mostly static, but have that one section of text where my client can go into the back end and change the text in there when they, “feel like it.”

    Eric

    And if you follow my instructions that’s what you will have.

    Where I have “Insert your quote here” that’s static stuff.

    You can also ignore the <?php get_sidebar(); ?> and just put static stuff there.

    I don’t see why you would want the header.php and footer.php to be static.
    If you’re building a wordPress site and the other pages will have a header and footer, why not re-use it?

    Thread Starter saundhaus

    (@saundhaus)

    I’m not really too up on php yet, but the section of static stuff would be html, so could I insert the html in the space you noted?

    Thanks for you help,
    Eric

    I would recommend that you build the rest of the site using wordPress and then once you have it good to go, create your home page and by then you should have a better understanding of how WordPress works.

    In the back end, you can create a page called home.

    Set that page as your front page under settings > reading

    and then use the front-page.php which I’ve suggested.

    Good luck

    Thread Starter saundhaus

    (@saundhaus)

    I understand how wordpress works, but I don’t fully understand PHP yet. I do agree that it would be best to get the rest of the site up first, but my client is asking for a front page first. That’s why I was asking if I insert the html where you mentioned.

    I’m also a bit curious as to how that page knows exactly where to put the text box that they can change.

    Eric

    The part that’s important is the loop:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    	<?php the_content();?>
    <?php endwhile; endif; ?>

    If you insert this in your template, then you can put whatever you want around it.

    But you NEED to create a page called home in the back end and set it as the front page in the admin via the settings.

    Thread Starter saundhaus

    (@saundhaus)

    OK, last question which hasn’t been answer yet:

    Do I insert html into the place where you said, “Insert your quote here”. If not, then that would mean that I have to insert it into the template which then doesn’t serve the purpose of only have the client have to deal with the text and no other items on the page. If I have to build the template in PHP, then I’ll have to pass on this job as I don’t know it well enough.

    I understand all about making the new template the front page. That’s not the problem. I just need to know where to put the html that will be static, so that when they call up the page they will be able to change the dynamic information that they want to change.

    Eric

    The page template is an HTML page with a php extension, that’s it.

    Make the page the way you want to if it were just all HTML. Now put the php bits in and change the extensions to be .php. Voila! Magic! ??

    Thread Starter saundhaus

    (@saundhaus)

    Ah, but they can’t edit that within the back end of WP. When I assigned the template to the page it didn’t matter what I put into the page as it was all overridden by the front-page.php html contained within it.

    Now should I assign the div element to the box that I want the type to change in? If so that makes sense and I would put the html that surrounds it where it says “insert quote here” for the header and the html below it would be put in the “insert bottom stuff here” Am I catching on?

    Eric
    PS. I tried a test and it’s up at https://www.jdsg.com/wp/ but as I said, it’s static.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Need a static front page with one dynamic part’ is closed to new replies.