0

I have the next code what works in the same way: 1. When i click on the title link, the content of the post is displaiyed without page reloading. 2. I want to add to this code the next functionality: To add in another DIV, a list from posts with a specific tag. So, in first part of the page i should have list of titles, then the content of post, and at the end a list with thumbnails and titles of posts with specific tag (at my choice)

This is my code:

<div id="content" role="main">

    <div style="float:left; width: 380px; margin-right: 50px">
        <h2>List :</h2>
        <ul>
            <?php global $post;
            $wpposts = get_posts('numberposts=5&post_type=>post');
            foreach($wpposts as $post):
                setup_postdata($post);?>
                <li><a href="<?php the_permalink() ?>">
                        <?php the_title(); ?></a></li>
            <?php endforeach; ?>
        </ul>
    </div>

    <div style="clear:both;">&nbsp;</div>

</div>

and my script:

jQuery('#content').append('<div class="displayPost"></div>');
jQuery('#content li a').click(function(event){
event.preventDefault();
var page = jQuery(this).attr('href');

jQuery('.displayPost')
    .load(page+' .post')
    .slideDown(2000);

});

Who knows how to improve my code for getting a result that i described?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.