How to show partial content of a page on another in wordpress?

I have a page called Dashboard and would like to show the contents of say page A and B on the Dashboard page. I can achieve this with the following code but I only want to show partial content of A and B like snippets. How can I show this in exactly the same styling as it appears on page A and B ?

function show_post($path) {
 $post = get_page_by_path($path);
 $content = apply_filters('the_content', $post->post_content);
 echo $content;
}

<?php show_post('pageA');  // Shows the content of the "PageA" page. ?>
<?php show_post('pageB');  // Shows the content of the "PageB" page. ?>

Page A shows the content with this code:

Read More
 <ul class="leftlist">
        <?php
        while ( $loop->have_posts() ) : $loop->the_post();
        ?>
        <li class="todo" id="<?php echo get_the_ID();?>" itemage="<?php echo get_post_meta(get_the_ID(),'_todotime',true)?>"><a href="javascript:;"
        <?php if($all_meta_for_user[get_the_ID()][0]){              
        ?>
        class="strike"
        <?php
         }
        ?>
        >           
        <?php if($all_meta_for_user[get_the_ID()][0]){?>
            <span class="check_box cb"></span>
            <?php }else{?>
        <span class="uncheck_box cb"></span>
        <?php }?>   
        <p><?php the_title(); ?></p></a>           
        <?php
        endwhile;
        ?>            
        </ul>

Thanks in advance

Related posts

Leave a Reply

2 comments

  1. you can easily do this by post create 2 posts suppose A and B. it will generate id’s like 20,22 … and use this code in your pages for page A:

    <?php  $cquery = new WP_Query('cat=20'); $i=1; ?>
          <?php if($cquery->have_posts()): while($cquery->have_posts()):  $cquery->the_post();   
          <?php the_post_thumbnail();   ?>
          <?php the_content(); ?>
          <?php $i++; endwhile; endif; endif;  ?> 
    

    and similarly for post B with having id 22.

  2. I am not extremest php coder. But i am trying it.
    Here is the code you can do it by with php explode .

    In your page A or B just put an identifier for explode.
    Like this :

    Here is the first of the contents of the page. 
    <!--start-->
    From this part you want to show something
    <!--stop-->
    Here is the rest of the contents
    

    And then your function is like :

    function show_post($path) {
     $post = get_page_by_path($path);
     $content = apply_filters('the_content', $post->post_content);
     $explode=explode('<!--start-->',$content);
     $explode=explode('<!--stop-->',$explode[1]);
     echo $explode[0];
    }