I'm building my first full site into WP and I am rather confused on the process involved to load the content you enter via the WP Pages editor into the actual page.
For example, I am having a static home page and I have this in index.php
of my theme file.
// Output header
get_header('home');
// Start Code that wraps the content
/***** Content of the page ******/
// End Code that wraps the content
get_sidebar();
get_footer();
Now the "Content of the page" should be the code/content that the user has control over via the WP Admin Pages menu.
How do I get this into the page? I have read you need to do something like this..
if (have_posts()) {
/* Start the Loop */
while (have_posts()) {
the_post();
get_template_part('content');
}
}
But I'm confused as this uses another content page yet again (content.php). Why do I need to create another content page when all I need is the code/data from the pages content area? I don't need to add any more coding myself.
I played around with it a bit and if I call it this way and make a content.php
file and just put <?php the_content(); ?>
inside of it, the content shows.
Still confused on the purpose of doing it this way.
I'm assuming so that you can use the index file for many things and then put specific code differences inside the content file!?
To help you understand my question even more, I have included the exact code from my index.php
file below and I'm wondering how I would split this up between index.php
and content.php
?
<?php
// Output header
get_header('home');
?>
<div id="main_holder">
<div class="banner">
<div id="slider">
<div class="slide slide1">
<div class="title">
<p>We Navigate the</p>
<p>Maze for You</p>
</div>
<div class="text">
We provide a start-to-finish service in an area<br />
that can often be complex and confusing.
</div>
<div class="button button_big">
<a href="">Read more about<br /><span>registering a trademark</span></a>
</div>
</div>
<!-- Slide 1 Ends -->
</div>
<!-- Slider Ends -->
</div>
<!-- Banner Ends -->
<div class="content">
<div class="main">
<div class="search_button">
<div class="left">
<h2><a href="<?php echo get_permalink(10); ?>">Free Trademark Search</a></h2>
</div>
<div class="right">
<a href="<?php echo get_permalink(10); ?>">Get Started Now!</a>
</div>
</div>
<!-- Search Button Ends -->
<?php
if (have_posts()) {
/* Start the Loop */
while (have_posts()) {
the_post();
get_template_part( 'content', get_post_format() );
}
}
?>
</div>
<!-- Main Ends -->
<?php get_sidebar(); ?>
<div class="contentClear"></div>
</div>
<!-- Content Ends -->
</div>
<!-- Main Holder Ends -->
<div class="bottom"></div>
<?php
// Ouput footer
get_footer();
?>
Thanks very much!
get_template_part
if you do not want to. I believe the purpose is so that you can reusecontent.php
across multiple templates. – Joseph Leedy Aug 25 '12 at 20:09the_content()
instead just insideindex.php
and it worked; which is strange as I'm sure I tried it before and it didn't work haha..... thanks for the response. :) – Brett Aug 26 '12 at 7:34