• Hello,

    Have if I can help traverse an array, I blocked here
    I’m in a page, running a loop that gives me posts with a certain category.
    What I need is to get all the ID of those posts, but separately.
    This is what I have>

    [please read https://codex.www.ads-software.com/Forum_Welcome#Posting_Code for posting code; the code below is either unreadable or corrupted]

    <? php query_posts (‘category_name = skatepark’);?>
    <? php if (have_posts ()): while (have_posts ()): the_post ();?>
    <? php
    $ postIDSkate = get_the_ID ();
    $ postIDSkateA = explode (”, $ postIDSkate);
    echo $ postIDSkateA [0]
    ?>
    <? php endwhile;?>
    <? php endif;?>

    >>>>>>>>>>

    Okay, so I printed three numbers that are the 3 ID that I have.
    Now I need to cross it again to give me

    echo $ postIDSkateALoop [0] = first number
    echo $ postIDSkateALoop [1] = second number
    echo $ postIDSkateALoop [2] = Third number

    What I can do???
    Thank you so much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • it is not really clear to me what you are trying to achieve;
    maybe start by explaining your goal in more detail.

    also, please repost your code.

    Thread Starter Paul Goethe

    (@paul-goethe)

    Sorry, but my english is very poor. I will try explining again …

    Iam into a loop for running all post with one concrete category.
    I have this:
    $postID = get_the_ID();

    And I print this:
    echo $postID[0];

    (My ID’s are 50, 60 & 70)But I obtain:
    50, 5060 , 506070

    I need obtain 50, 60 & 70. Separatelly.

    I would need create an array for can print this values separetly. For example like this:
    [0]= 50
    [1]= 60
    [2]= 70

    Do you understand me?
    Im really gratefully.
    Chears

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Running a loop’ is closed to new replies.