• Resolved goldmember

    (@goldmember)


    on this PAGE of my site (https://greenrefurbishing.com/wordpress/blog/), I have the php code below pasted in the HTML content editor of the PAGE in order to show the entire most recent post to the Blog category (category 1).

    but for some reason, the title of the post does not appear, even though the Posted On date does, and so does the content.

    how do I get the post title to appear? Please advise. Thanks!

    <?php
    $latestposts = get_posts('numberposts=1&category=1');
    foreach($latestposts as $post) :
       setup_postdata($post);
    ?>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
    <?php twentyten_posted_on(); ?><br />
    <br />
    <?php the_content(); ?>
    <?php endforeach; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • This code should really be placed in the theme template file for the home page and not in the edit page area of the admin.

    Yes, you always will place this kind of code directly in the template files. The HTML content editor is only for entering post/page content.

    You’ll need to go to Appearance > Editor and then find “index.php” (assuming you want the latest post to show on the front page) for your current theme. That’s the file where this code should go!

    Thread Starter goldmember

    (@goldmember)

    ok. thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get_posts php issue’ is closed to new replies.