• Hi Very new to WordPress and am muddling my way through.

    I have my functions.php file set up to pull posts from a category and then am using the excerpt field in the wordpress backend of the post itself to enter in the title of the post itself. Long story but needed to do it this way.

    So my functions.php file has this:

    function show_posts_from_category( $numberofposts = 10, $category_name = ‘News’ ) {
    $post_cat_id = get_cat_id($category_name);
    $posts = get_posts(“numberposts=”.$numberofposts.”&category=”.$post_cat_id);
    foreach ($posts as $post)
    {
    echo ‘

    • <span>’.$post->post_excerpt.'</span>’;
      echo ‘ID).'”>Read More
    • ‘;
      }

      Then in my static home.php file/sidebar area I am doing this:

      <?php show_posts_from_category(10, ‘News’); ?>

      This displays the title of the post (as filled in the excerpt field in the backend) but I would also like the sidebar to show the date of the post as well.

      So I believe I need to add (<?php the_time(‘F j, Y’); ?>) to the above functions.php code file so it will display under the post name, right before it shows the Read More link.

      This seems so simple but I keep blowing it up. Any chance someone could steer me on how to add this to my functions.php file?

      Any help is appreciated!

Viewing 1 replies (of 1 total)
  • Thread Starter nlesti

    (@nlesti)

    Sorry, that echo in the functions.php is displaying incorrectly in the above post. I am hoping this will display that code correctly, but if not, I have the Read More Link functioning correctly already.

    echo ‘

Viewing 1 replies (of 1 total)

The topic ‘Adding date pull to functions.php’ is closed to new replies.