• stinkykiller

    (@stinkykiller)


    Hello !
    I’m running a plugin that allows me to execute PHP from posts.
    Just trying to call a post inside a page with this plugin.
    I want to echo the first part of a post, not the entire post, I created a <!–more–> but still showing the complete post.

    Heres the code !

    <div id="post1">
    <?php
    $my_id = 1;
    $post_id_1 = get_post($my_id, ARRAY_A);
    $post_content = $post_id_1['post_content'];
    $post_title = $post_id_1['post_title'];
    
    echo "<strong>\n";
        echo $post_title."\n";
        echo "</strong>";
    echo $post_content ;
    ?>
    </div>

    I search almost all www.ads-software.com without a hint.
    Please help me !

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael

    (@alchymyth)

    Thread Starter stinkykiller

    (@stinkykiller)

    Thanks for the link, but I don’t know how to aply it to my case, I’m a noob on PHP ??

    Thread Starter stinkykiller

    (@stinkykiller)

    Well well…
    I found this piece of code that works for me.

    <?php
    $my_id = 3;
    $mypage = get_post($my_id);
    ?>
    <h2 class="boxTitle"><?php echo $mypage->post_title;?></h2>
    <?php echo substr($mypage->post_content,0,strpos($mypage->post_content, '<!--more-->'));?>
    <?php echo substr($mypage->post_content,0,strpos($mypage->post_content, '<!--more-->'));?>

    Now I have a question,
    Why If I delete one of the last two lines of code, it show me only the title not the content. I try making one strong and the other underline, the last one always remains on page, but can’t delete anyone of those 2 lines,

    WHY ???

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Getting the post from start to’ is closed to new replies.