1. This website uses cookies to improve service and provide a tailored user experience. By using this site, you agree to this use. See our Cookie Policy.
    Dismiss Notice

Any PHP'ers out there? I have a little question.

Discussion in 'PHP & Perl' started by shapeshift3r, Apr 19, 2009.

  1. shapeshift3r

    shapeshift3r Junior Member

    Mar 26, 2009
    Likes Received:
    I made a blog using wordpress.

    I made categories to organize my posts.

    I wanted to display links to all posts in a given category on my sidebar when that category is selected.

    I got a widget to display the links. The way the widget works demands that you can only use one of its kind for each category. So I make one for each of my categories. Problem solved...not quite.

    When I visit a category page and click any of the post links the widget disappears. But I have a plan...

    I get a plug in that will allow me to continue to display the widget as long as certain PHP conditions are being met.

    Im currently using the conditions:
    is_single || is_category('category-slug-here')


    If I just use is_category the widget does not display on individual posts

    If I just use is_single the widget doesnt display on the category pages

    If I use both with an OR operator (||) it displays on both pages but because I used a different widget for each category it displays every widget.

    I only want to show links to the posts relevant to the category.

    What code could I use to do this?
    The plug in will allow absolutely any PHP, not jsut conditions.
    I just suck at PHP and have no idea how to do it.

  2. oldenstylehats

    oldenstylehats Elite Member Premium Member

    Apr 10, 2008
    Likes Received:
    Moved to the appropriate section.
    • Thanks Thanks x 1
  3. MakeLemonade

    MakeLemonade Junior Member

    Mar 30, 2009
    Likes Received:

    You're probably using the wrong plugin for the job. There's actually at least 7 out there for handling categories. I know because I just finished adapting one for some custom code I was doing yesterday. Here's a few to check out.



    If you're stuck on using your plugin, your "is_category" call looks like it's hardcoded. I just checked my code and I'm using a numeric category number. Not sure how you'd find out which category it is using code.