• Hi.
    I’m using a theme with a tabbed sidebar.
    This is the theme I’m working on – https://www.solostream.com/demo/wp-clear.html
    Over in the tabbed widget in the sidebar, instead of displaying popular posts, I’d like to show the titles & links of the last 5 posts from one specific category.
    I know where in the code the change needs to be made but don’t know what the code needs to be changed to.
    Thanks.

Viewing 1 replies (of 1 total)
  • i_g_wright

    (@i_g_wright)

    Hi,

    I haven’t seen the code for that theme but you mention you know which code needs changing… Hopefully the example below we give you some help.

    This example will pull the latest five posts from a certain category ID – in this case category ID 3.

    Hope this helps.

    // Setup our loops parameters - 5 posts from category ID 3 ()
    $args = array(
    	'numberposts' => 5, 'category' => 3
    );
    $postslist = get_posts( $args );
    foreach ($postslist as $post) :
    	setup_postdata($post);
    	print '<h2><a href="'; the_permalink(); print'" title="'; the_title(); print '">'; the_title(); print '</a></h2><p>'; the_content(); print '</p>';
    endforeach;

    (Wrap the following code in PHP tags)

Viewing 1 replies (of 1 total)
  • The topic ‘How to alter code so theme shows posts from one category in tabbed sidebar’ is closed to new replies.