Support » Developing with WordPress » Get_the_title returning ID only?

  • Noobie question I suppose. I’ve got a custom page template (using Thesis) that is trying to grab recent posts:

    foreach($lastposts as $post) : setup_postdata($post);
        $post_id = $post->ID;
        $post_date = get_the_date($post_id);
        $post_title = get_the_title($post_id);
        $post_url = get_permalink($post_id);
        $post_excerpt = get_n_char_excerpt($GLOBALS['blogright_excerpt_length'], $post->post_content);
                <li><span class="storydate"><?php echo $post_date ?></span><span class="storytitle"><a title="<?php echo $post_title ?>" rel="nofollow" href="<?php echo $post_url ?>"><?php echo $post_title ?></a></span></li>
        if ($current_article_num < $article_count)
            $current_article_num++ ;

    The “$post_title = get_the_title($post_id);” is returning a number (a post ID?). I want to format the date as “Month Day, Year”.

    I tried using “post_date = get_the_date($post_id);” and it returns a date with *everything* (e.g. 2011-09-22 15:02:15).

    Any ideas on how I can get what I want: “Day Date, Year” format?

    Thanks in advance,


Viewing 6 replies - 1 through 6 (of 6 total)
  • Sorry… I contradicted myself at end of post… My goal for date of post format is Month Day, Year (e.g. “September 29, 2011”)…

    get_the_date(); //without parameters
    get_the_date('F j, Y');



    Formatting looks great Oleg. Now I’ve discovered one other nagging problem… all of my posts have the same date…

    I went digging around the WP codex and found info on the_date where it says:

    SPECIAL NOTE: When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() or get_the_date() (since 3.0) with a date-specific format string.

    But I’m using get_the_date… but I’m still only getting a single date back…


    After doing some testing I’ve discovered that the date that’s being returned is the date I created the static page where I’m using the code (if that helps)…


    Try this
    date('F j, Y', strtotime( $post->post_date ) )

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Get_the_title returning ID only?’ is closed to new replies.