The MU forums have moved to WordPress.org

How to get title, author, date and part of the post by sitewide post id? (3 posts)

  1. Christophe25
    Member
    Posted 15 years ago #

    Hi,

    Can someone help me with the following?

    I want to make a 'most read' page with the ten most popular sidewide articles on the homepage of mu-installation. I determine which are the most popular by analytics (google)

    Is there a possibility I just have to give ten ID's of the most popular posts and put them in an array on the 'most read' page, so wordpress can take the title, the date, author and the first part of the content, just by knowing the ID of the posts?

    I hope someone can help me with this. I'm searching for days now :(

    Kind regards,
    Christophe

  2. Christophe25
    Member
    Posted 14 years ago #

    This is what I got so far ...

    <?php 
    
    			$posts = array(1799, 1367, 1364);
    
    		?>
    
    <?php foreach($posts as $i => $postid) : ?>
    
    <?php
    	$current_post = get_post($apostid) ;
    	$current_post->post_title;
    	echo '<br />fef';
    ?>
    
    <?php endforeach; ?>
    <?php switch_to_blog();
    query_posts("p=6");
    while (have_posts()) : the_post();
    // display post here (attachments included)
    
    endwhile ; ?>

    ... but it just gives me fef 3 times :(

    Can someone help me please.

    thx in advance,
    Christophe

  3. Christophe25
    Member
    Posted 14 years ago #

    Update ...

    ´<?php

    $posts = array(1799, 1367, 1364);

    ?>

    <?php foreach($posts as $i => $postid) : ?>

    <?php
    $current_post = get_post($postid) ;
    $current_post->post_title;
    echo 'fef';
    ?>

    <?php endforeach; ?>
    <?php switch_to_blog();
    query_posts("p=6");
    while (have_posts()) : the_post();
    // display post here (attachments included)

    endwhile ; ?>´

    Someone ... or any suggestions. Still not working :(

About this Topic

  • Started 15 years ago by Christophe25
  • Latest reply from Christophe25