• Hi,

    I would like to add a variable in the loop.
    this is my loop:`
    <?php
    global $post;
    $myposts = get_posts(‘include=3,6,13,’);
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>
    do stuff
    <?php endforeach; ?>`

    Instead of 3,6,13, I would like to add a variable called $myposts.
    How do I do this, I really don’t understand.

    Thanks in advance!!
    `

Viewing 1 replies (of 1 total)
  • $myposts = '3,6,13';
    $myposts = get_posts( 'include='.$myposts )

    or

    $myposts = array( 3,6,13 );
    $myposts = get_posts( 'include='.implode( ',' , $myposts ) )

    .. or any variant thereof..

    Assuming that’s what you mean..

Viewing 1 replies (of 1 total)
  • The topic ‘Add a variable to my loop-arguments’ is closed to new replies.