0
votes

I am quite new to Wordpress and try to customize my Wordpress theme. My posts are always different. But basically there is a title, a text and a NivoSlider/Image/Vimeo Video.

If I use the basic the_content function it displays the post like that:

<h2>Title of the Post</h2>
<p><div class="slider-wrapper">Slider</div>Text</p> 

It always includes the Slider/Image/Video in the

Tag. How can I split the_content object?

I would like to have my posts display like that e.g. for the NivoSlider:

<div class="slider-wrapper">Slider</div> 
<h2>Title of the Post</h2>
<p><Text</p> 

It would be really great if somebody could tell me the easiest way to do for all the different kinds of posts.

I hope you understand my explanation, if you need more details, just tell me.

Thanks in advanced.

Best, Brigi

3

3 Answers

0
votes

Personally, I would take the shortcode out from your Content Body altogether, and place it in a Custom Field (named something like "postSlider"). Then you can structure your template like so:

<?php
do_shortcode(get_post_meta(get_the_ID(), 'postSlider'));
?>
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
0
votes

You needs to create a custom page template for your posts. In that page template you can define your slider. Then just put your text in the content section.

Before doing serious coding refer this: Stepping Into Templates

0
votes

Thanks again for your answer. Finally I used the Types plugin for Wordpress. You can easily customize your own field and use it in your index.php file with the following code:

Custom Field Image:

<?php echo(types_render_field("field-slug-image", array("alt"=>"Product image", "width"=>"600","height"=>"300","proportional"=>"true"))); ?>

Shortcode Custom Field for the Slider:

<?php echo apply_filters('the_content', get_post_meta($post->ID, 'field-slug-slider', true)); ?>   

Shortcode Custom Field for the Vimeo video:

<?php echo apply_filters('the_content', get_post_meta($post->ID, 'field-slug-video', true)); ?>       

Title and Content:

<h2><?php the_title(); ?></h2>
<?php the_content('Read the full post',true);?>