• i need to add more content to a custom post type (“trip”)
    i want to create tabs with content for day1, day2,day3…

    how to do that?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    I see to ways to do it, if you want to keep all the data in one post you can use multiple “more” tags in the content and split it within the loop with :
    $multiparts_content_array = explode("<!--more-->", $post->post_content);

    The result is an array an then you can put the items in differents DIV tags.

    The other way is to use Pages. You create a page template for the “trips”, create day1, day2… using posts; then in your template you gather the posts and display it.

    Hope this is useful to you.
    cheers,
    jeFFF

    Thread Starter bermaneyal

    (@bermaneyal)

    great, i tried the first way and it’s work,

    now just to implement some jquery and everything will work fine

    wordpress forever!

    Glad I could help 😉

    Just a quick advice, if you have some trouble with line breaks when displaying the content of the $multiparts_content_array just add the wautop function.

    Example :
    echo wautop($multiparts_content_array[1]);

    Cheers
    jeFFF

    Thread Starter bermaneyal

    (@bermaneyal)

    thanks,

    any idea how to pass a tab name?
    maybe i can use custom field to pass an array of string for tabs name?

    <div class="entry-content">
    						<?php// the_content(); ?>
    						<?php $multiparts_content_array = explode("<!--more-->", $post->post_content);
    						$i = 0;
    						?>
    						<div id="tabs">
    							<ul>
    						<?php
    						foreach ($multiparts_content_array as &$value) {
    							echo '<li><a href="#tabs-'.$i.'">name of tab</a></li>';
    						$i++;
    						}
    						?>
    							</ul>
    						<?php
    						$i = 0;
    						foreach ($multiparts_content_array as &$value) {
    							echo '<div id="tabs-'.$i.'">'.wpautop($value).'</div>';
    							$i++;
    						}
    						?>
    						</div>
    						<script>
    jQuery(function() {
    		jQuery( "#tabs" ).tabs();
    	});
    	</script>
    
    						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'amief' ), 'after' => '</div>' ) ); ?>
    					</div><!-- .entry-content -->
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘how to add more content to a post’ is closed to new replies.