• <?php
        function wptuts_recentpost($atts, $content=null){
          global $more;    // Declare global $more (before the loop).
      $more = 0;       // Set (inside the loop) to display content above the more tag.
            $getpost = get_posts( array('number' => 1) );
            $getpost = $getpost[0];
            $return = $getpost->post_title . "<br />" . $getpost->post_content . "…";
            return $return;
        }
        add_shortcode('newestpost', 'wptuts_recentpost');
    ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • try:

    $return = $getpost->post_title . "<br />" . apply_filters('the_content',$getpost->post_content) . "…";

    although this might also get you some formatting which you might not want (?)

    Thread Starter macaela007

    (@macaela007)

    do you mean like this

    <?php
        function wptuts_recentpost($atts, $content=null){
          global $more;    // Declare global $more (before the loop).
      $more = 0;       // Set (inside the loop) to display content above the more tag.
            $getpost = get_posts( array('number' => 1) );
            $getpost = $getpost[0];
            $return = $getpost->post_title . "<br />" . $getpost->post_content . "…";
           $return = $getpost->post_title . "<br />" . apply_filters('the_content',$getpost->post_content) . "…";
        }
        add_shortcode('newestpost', 'wptuts_recentpost');
    ?>

    it doesnt display any post

    I mean to replace the obvious line with the suggested code.

    i.e. replace this:

    $return = $getpost->post_title . "<br />" . $getpost->post_content . "…";

    with:

    $return = $getpost->post_title . "<br />" . apply_filters('the_content',$getpost->post_content) . "…";

    it doesnt display any post

    did it display a post before the edit?

    can you post a link to your site to a post/page with the shortcode in teh content?

    Thread Starter macaela007

    (@macaela007)

    yes it did display before I even have two functions they mean to do the same job display latest post. the first one works fine except that it show the last post twice on the homepage at the top and at the bottom of the content,

    the second function I just cant get the ( MORE ) to appear.
    here a link to my page

    click on the link (click here to see the function txt file) to see the the two functions

    My aim is to be able to display the latest post on the homepage and use the more function on the text editor to shorten the display on on the homepage

    would really appreciate any help.

    Thread Starter macaela007

    (@macaela007)

    here the link to my site
    my site

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘how can I get the ( read more )sintax on text editor to work with the code bello’ is closed to new replies.