• Newbie here!

    I just read this in documentation which i need:

    <h2>Recent Posts</h2>
    <ul>
    <?php
    	$recent_posts = wp_get_recent_posts();
    	foreach( $recent_posts as $recent ){
    		echo '<li><a href="' . get_permalink($recent["ID"]) . '">' .   $recent["post_title"].'</a> </li> ';
    	}
    ?>
    </ul>

    I jsut want to show in my frontpage a list of links from a specific category. I will have to modify the above code i know, but HOW i get this to show on a page or widget? what is tha procedure.

    I got a template from themeforest which doesnt have a simple list so i want to create one from scratch.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Earthdog,

    The example code you have is to be placed in a theme file. If you’re not comfortable with editing theme files it’s probably bes to go back to the theme author and ask if there is a way to do what you need.

    If you need to edit the theme files, it’s a good idea to create a child theme and do your changes there so you don’t break the updates for the theme.

    Child themes: http://codex.wordpress.org/Child_Themes

    Cheers,
    Joel

    Thread Starter earthdog

    (@earthdog)

    Hi

    I am comfortable with changing anything , but i wouldnt know what and where as i am new to wordpress inner workings.

    I have already created a child theme which is working as it should

    i am just confused as to what are my options.Sure there is an option of just putting php code into a page by using one of the plugins that do this but i dont like it due to security concerns.

    I could create a widget with this but it seems an overkill to create a widget just to bring five article links. I would expect this to be easier for someone who doesnt want to go so deep for such simple things.

    Dont get me wrong i am writing c# with asp.net mvc almost daily , but that is completely another story since it is created from 0.

    Hi Earthdog,

    No worries. Entering PHP into pages directly is not a great idea.

    Generally what you’re trying to achieve is done via the theme files (but depends how the them you are using is setup).

    Another option that sounds like it might be a good option, is you could write a simple shortcode function, place it in your themes function.php and use that shortcode in the page’s editor.

    Reference: http://codex.wordpress.org/Function_Reference/add_shortcode

    Cheers,
    Joel

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Just get the latest posts code from documentation to run’ is closed to new replies.