Support » Fixing WordPress » Get Recent Posts with shortcode

  • Hello All,

    I am trying to display latest posts using wp_get_recent_posts function, in one of the post i have used a shortcode [newsletter] but instead of diaplying the content of shortcode, this itself is got printed [newsletter] my code is this
    `$args = array(
    ‘numberposts’ => 2,

    $recent_posts = wp_get_recent_posts($args);

    foreach( $recent_posts as $recent ){

    echo ‘<li><span class=”header”><a href=”‘ . get_permalink($recent[“ID”]) . ‘” title=”Look ‘.esc_attr($recent[“post_title”]).'” >’ . $recent[“post_title”].'</a></span> ‘. $recent[‘post_content’].'</li> ‘;

    Please Help me out

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi swayam.tejwani,

    I think that the shortcode [newsletter] is wrapped into an html element. In order to fix this, you need edit your post, then go in the text tab on top right of the content editor. If the shortcode [newsletter] is wrapped into any html element ( like div or p) remove that element and update your post.

    I hope this help,


    Hello Julien,

    In the editor i have only shortcode [newsletter] and nothing else, for more info i am pasting here my code of shortcode
    function nl_form(){
    <?php //echo DB_NAME(); ?>
    <p>Vestibulum sit amet tincidunt sit amet, tincidunt at dolor. </p>
    <form action=”javascript:void(0)” method=”get” id=”nl_formid” onsubmit=”return callajax();”>
    <input required placeholder=”Your Email” class=”email” type=”text” name=”emailname” id=”email_id” title=”keyword” />
    <input type=”submit” name=”Subscribe” value=” Subscribe ” alt=”Subscribe” id=”subscribe_btn” title=” Subscribe ” class=”subscribe_btn” />
    <span class=”email_validate” style=”display:none;”>Enter Valid Email Address</span>
    <img id=”loadingimage” style=”display:none; float: right;position: relative; left: 36px;top: 20px;” src=”<?php echo plugins_url(‘images/ajax_loading.gif’,__FILE__); ?>”>
    <div class=”cleaner”></div>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get Recent Posts with shortcode’ is closed to new replies.