• silkweb

    (@silkweb)


    Hello Everyone, I hope someone can assist. I have modified a php string on my homepage to show the recent posts but I cannot for the life of me figure out how to reduce the # of posts to 4 and change the title. Here is my code:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter silkweb

    (@silkweb)

    Michael

    (@alchymyth)

    <?php the_widget('WP_Widget_Recent_Posts', array('number' => 4), $args); ?>
    or:
    <?php the_widget('WP_Widget_Recent_Posts', 'number=4', $args); ?>

    http://codex.ww.wp.xz.cn/Function_Reference/the_widget#Recent_Posts_widget
    http://codex.ww.wp.xz.cn/Function_Reference/the_widget

    instance
    (array or query-string-style) the widget’s instance settings. See each widget below.

    Thread Starter silkweb

    (@silkweb)

    Thanks very much, I did find both those links and I did read everything that was there about doing this, but it doesn’t give examples of how it is to be presented and not very intuitive. Can you advise what I would do if I wanted to change the title because right now is it called “Recent Posts”, or if I wanted to remove the title completely?

    Thank you so much!

    Michael

    (@alchymyth)

    <?php the_widget('WP_Widget_Recent_Posts', array('number' => 4, 'title' => 'Some Other Title'), $args); ?>

    or you could try with a single space character as title – however this will still output the ‘before_title’ and ‘after_title’ html tags:

    <?php the_widget('WP_Widget_Recent_Posts', array('number' => 4, 'title' => ' '), $args); ?>

    or to get rid of the html title tags and show no title:

    <?php the_widget('WP_Widget_Recent_Posts', array('number' => 4, 'title' => ' '), array('before_title' => '', 'after_title' => '')); ?>
    Thread Starter silkweb

    (@silkweb)

    Thank you again for your help and fast response. 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Recent Posts PHP’ is closed to new replies.