WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Displaying titles of posts from category in a sidebar (6 posts)

  1. ninjaboy
    Member
    Posted 8 years ago #

    I realise there are plug-ins for this kinda feature ('asides?'), but I am trying to learn more about the code behind WP and have hit a block here!

    I have the regular loop running on a page (main content area), but really need to be able to display the (linked) titles of the latest 3 posts made in a specific category in the sidebar in various pages/categories on the site.

    I have tried a-lot of different ways, but I am no PHP/WP expert and have not been able to achieve this... whenever I paste code into my sidebar file it seems to stop the 'main page' content appearing - this is because I need to run another loop Im guessing, and it is screwing up the main one... I just can't get it to work!

    Please help me out guys (and gals!), it seems such a simple thing to do, but I just can't work it out!

  2. moshu
    Member
    Posted 8 years ago #

    Maybe I am missing here something but a simple recent_posts plugin where you can define the number of posts and the category to be displayed should do the job.
    Like this one:
    http://www.coffee2code.com/archives/2004/08/27/plugin-customizable-post-listings/

  3. ninjaboy
    Member
    Posted 8 years ago #

    Cheers for the link, that plugin is quite good (although a little old maybe, but if it aint broke dont fix it is what I say!).

    I have has a good play around with it and it certainly does what I need, although I really wanted to implement this with pure WordPress code rather than using a plug-in.

    I have spent alot of time copy and pasting code from this and other sites to try and get this to work, but nothing has worked so far - please help me learn WP a little better!! I simply want to display the titles of the most recent posts in a certain category as links in various pages of my site.

  4. moshu
    Member
    Posted 8 years ago #

    Sorry, but I don't get your obsession with "pure WP code"...
    And to be honest, we do not offer lessons for learning the WP code. You can do it on your own - open the files in a text editor and study them. If you know how to do it. I don't, because I am code-illiterate, so I cannot help.

    The WP code has its core features and the "customization" was left to the plugin authors. The developers try to keep WP as thin as possible, so the hundreds of additional functions/features are done through plugins. Certain things you just can NOT be done with the basic code. That's what you need to learn :)

    The plugin I linked to can do exactly what you want, you just have to configure it for your needs.

  5. ninjaboy
    Member
    Posted 8 years ago #

    Well - the idea was to work out the simple WP code, and just have that in my sidebar - call it a very simple 'asides' application rather than have an all singing and dancing plugin with loads of lines of code... I thought this code stuff was meant to be poetry!!

    I have configured the plugin to do exactyl this with only very slight midification, so this is bascially resolved I guess!

  6. ninjaboy
    Member
    Posted 7 years ago #

    This thread is basically dead now - but if anyone comes across it I have tried a few solutions out, so I thought I'd share my experiences.

    The bottom line is I wanted to show posts made in certain categories - without having to post to 'asides' category in a sidebar.

    The best way I have found to do this is with the excellent inlineRSS plugin over at http://www.iconophobia.com/ - with just a simple line in the inlineRSS config txt file to call the named feed like:

    pninja,http://www.photoshopninja.com/?feed=rss2&cat=16,0

    I can call a categories post titles - just what I needed! I hope this plugin has been developed a bit more - so it has a page in the admin area to configure the feeds, but I can live with the config file alteration for the moment!

    There has been some solid work on this plugin and for those of you worries about the drain on speed of hitting and rendering out all those RSS feeds, it has cache control to keep things fast. It seems very flexible and seems to deal with pretty much anything you can throw at it!

    FetchRSS is ok - but it seems quite slow and I'm almost certain it doesn't cache the feeds, although it does have a admin page within the WP admin menu. From my experience inlineRSS is the best - certainly if you want more power for 'asides'.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.