0
votes

I'll try and explain this the best I can! I am using a child theme of the new Twenty Thirteen Theme.

I have been creating custom page templates for individual pages, however I have found myself adding code to my pages from within the CMS under Page > Add New Page.

for example

<code><div class=”container”><p>Some content!!</p></div></code>

This makes me feel uneasy! Is this good practice to do this?

sometimes when I re visit the page from within the CMS, extra characters have been added. For example additional tags.

Is it possible to call the content from within the custom page template and echo out the individual paragraphs into their respective “container” classes?

Template extract

<div class="entry-content">
    <div class="custom-slider">

    </div>
    <?php the_content(); ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
    </div><!-- .entry-content -->
    <div class="container">
    //echo some content here
    </div>
    <div class="container-1">
    //echo some content here
    </div>
    <div class="container-2">
    //echo some content here
    </div>

The standard way <?php the_content(); ?> calls all the content as a block.

Is there a better way? For example using widgets, which will mean all the content will be in widgets! or would this affect SEO?

Really what I am asking is, what would you consider to be best practice to achieve this? Hope someone can advise! - Thanks

1

1 Answers

1
votes

It really depends how much markup you need to put in your content. If there is a lot you will start to have problems - as you've noticed the WordPress editor can add or remove markup.

If you have a fixed number of sections of content I would consider using the Advanced Custom Fields plugin (http://www.advancedcustomfields.com/). It's an excellent plugin and it will allow you to have multiple WYSIWYG (or any other type of content) fields on a single page which you can then output in your template like this:

<div class="container-1">
  <?php the_field("container_1"); ?>
</div>
<div class="container-2">
  <?php the_field("container_2"); ?>
</div>

And so on... Hope that helps.