WordPress.org

Ready to get started?Download WordPress

Forums

how to add more content to a post (5 posts)

  1. bermaneyal
    Member
    Posted 3 years ago #

    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?

  2. jeFFF
    Member
    Posted 3 years ago #

    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

  3. bermaneyal
    Member
    Posted 3 years ago #

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

    now just to implement some jquery and everything will work fine

    wordpress forever!

  4. jeFFF
    Member
    Posted 3 years ago #

    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

  5. bermaneyal
    Member
    Posted 3 years ago #

    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 -->

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.