hi there, there are many ways of achieving this! It sounds as if your pages will need to include the HTML for both summer & winter content which can then be switched using a JavaScript toggle. So your final HTML markup might look something like this:
<div class="summer-content">
Summer stuff here...
</div>
<div class="winter-content">
Winter stuff here...
</div>
It would then be quite simple to write a script to toggle between these two.
As to how you manage this content from WordPress, the simplest way would be to just switch to text mode and add the HTML right there!
The next simplest option would be to add a custom field for the Winter content, then update your theme’s loop.php to output the post content & the custom field content wrapped in the appropriate HTML.
If you want it to be friendlier / less technical you could find a plugin that allows you to add nicely labelled custom fields to the Post edit page. I often use Pods for this kind of thing but there are others available.
Hope that helps
Dan
Hi Dan
cheers for that I’ll look into it, seems like custom fields in conjunction with the main content is the best option, thanks for your advice.
Best
Harry
Hi Dan
Great advice, I used advanced custom fields in the end to make the summer content and use the standard page content for the winter one. Then it turns out the theme i’m using(Virtue theme) has built in tab toggle functionality, so I then wrapped the content and the custom field in the appropriate html. The only issue i’m facing now is, I want a way for the the tabs to be wrapped in an if statement, i’m not to sure how to do that.
I basically have this html for the two tabs:
<ul class="nav nav-tabs sc_tabs">
<li class="active"><a href="#winter">Winter</a></li>
<li class=""><a href="#summer">Summer</a></li>
</ul>
and this to declare the custom field:
<div class="tab-content postclass">
<div class="tab-pane clearfix active" id="winter"><?php the_content(); ?></div>
<div class="tab-pane clearfix" id="summer"><?php the_field('summer'); ?></div>
</div>
Any ideas on how I might make this into an if statement?
cheers for your help
Best
Harry
hiya,
I don’t really understand what you’re asking.
What are you trying to achieve with the if statement?
Dan
Hi Dan
What I’m basically trying to do is check if my custom field summer has content in it(Images writing whatever) if so then deisplay the ul/li html if not then don’t.
Does that make more sense?
Cheers
Dan
Oh I see. Try this:
<?php
$summer = get_post_meta( get_the_ID(), 'summer', true );
if ( !empty( $summer ) ):
?>
<ul class="nav nav-tabs sc_tabs">
<li class="active"><a href="#winter">Winter</a></li>
<li class=""><a href="#summer">Summer</a></li>
</ul>
<?php
endif;
?>
Then later in your page template:
<?php
if ( !empty( $summer ) ):
?>
<div class="tab-pane clearfix" id="summer">
<?php echo( $summer ); ?>
</div>
<?php
endif;
?>
Ok cool, cheers dan I’ll try that.
Ha ha you my friend are a legend, thank you very much. I had to change <?php echo( $summer ); ?> to <?php echo the_field('summer'); ?> but that’s only because I’m using advanced custom fields. Thank very much for all your help, cant thank you enough.
All the best
Harry
You’re welcome, glad it worked out π