The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Help with functions.php

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #26166

    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 feed 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 ‘<li><span>’.$post->post_excerpt.'</span>’;
    echo ‘<a href="’.get_permalink($post->ID).’">Read More</a></li>’;

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

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

    I would also like to add the date, (<?php the_time(‘F j, Y’); ?>) to the functions file so it will display under the post name.

    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 post (of 1 total)
  • The forum ‘Other’ is closed to new topics and replies.