How would I code this for wordpress?

Hello I am fairly new to wordpress.

I was wondering if you guys have any idea on how to display post from wordpress and tweets
all in the same ‘loop’.

Read More

I know It is possible using a if statement that displays a tweet ever nth-wordpress post. But I would like for both the tweets and the posts to be displayed by date in the same page. any ideas?

so far this is what my page looks like

<?php 
get_header();

if(have_posts()) {
    while(have_posts()) {
        the_post();

        $post_link = get_permalink(get_the_ID());
        //($beforeString, $afterString, T/F)
        //T/F retun in html-T or in php-F
        the_title('<h1><a href="'.$post_link.'">', '</a></h1>');
        the_content('<p>', '<p>');
        //echo <a href="get_permalink()" 
    }
}
get_footer();
?>

Related posts

Leave a Reply

1 comment

  1. I’d try to get both sources into one array, then sort it and print it out:

    <?php 
    get_header();
    
    //define array
    $entrys=array();
    
    //get wp-posts
    if(have_posts()) {
        while(have_posts()) {
          the_post();
    
          $timestamp=//timestamp of post
          $entries[$timestamp]=array(
            'link'=>get_permalink(get_the_ID()),
            'title'=>get_the_title(get_the_ID()),
            'content'=>get_the_content()
          );
        }
    }
    
    //insert the twitter-data into the same array here
    
    //sort array
    ksort($entries);
    
    //print array
    foreach($entries as $e){
      echo '<div class="entry"><h1><a href="'.$e['link'].'">'.$e['title'].'</a></h1>';
      echo '<p>'.$e['content'].'</p>';
      echo '<a href="'.$e['link'].'">Link</a></div>';
    }
    get_footer();
    ?>