Forums

[resolved] Slayers Customs Widgets Plugin - HELP (22 posts)

  1. JG99
    Member
    Posted 2 years ago #

    Hello, I am really struggling with this plugin, trying to get it to work properly. I want it to display different categories for individual posts. Anybody had success with it?

    Thanks for the feedback.

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    I want it to display different categories for individual posts.

    Are you saying you want to displayed different widgets based on the category for an individual post when viewing that single post?

    Note: I also deleted your duplicate topic.

  3. JG99
    Member
    Posted 2 years ago #

    Hello MichaelH

    Thanks for trying to help me.

    Let's say my blog URL is DeliciousFoodRecipesDOTcom.

    First posting (only one post per page)
    "Italian Food Recipes" ------------------------------------
    -----------------------------------------------------------CATEGORIES
    -----------------------------------------------------------"Spaghetti"
    -----------------------------------------------------------"Tortellini"

    Next posting (again, one post per page)
    "Mexican Food Recipes"--------------------------------------
    ------------------------------------------------------------CATEGORIES
    ------------------------------------------------------------"Tacos"
    ------------------------------------------------------------"Burritos"

    What I want to be able to do is dictate what appears on the right margin in "Categories," so that each post only shows the category or categories that I have assigned to that one specific post.

    As is stands now, with every posting ALL categories are listed, which means the sum of all my blog posts and the total number of categories I have created. Instead, I want to be able to control which categories are showing on which posts/pages.

    I heard Slayers plugin would do the trick, but it's not working. I have tried every possible combination of settings!

    Thank you again for trying to help me.

  4. JG99
    Member
    Posted 2 years ago #

    MichaelH, I came across this thread, would this coding do the trick?

    http://yoast.com/showing-subcategories-on-wordpress-category-pages/

    The only issue for me is that I don't want subcategories. I simply want to control which categories appear on which postings.

  5. MichaelH
    Volunteer
    Posted 2 years ago #

    <?php
    //for 'first post' in wp_query display categories on that post
    $postid = $wp_query->posts[0]->ID;
    $postcats = get_the_category($postid);
    $ids=array();
    if ($postcats){
      foreach ($postcats as $postcat) {
        $ids[]=$postcat->cat_ID;
      }
      $cats = implode(",", $ids);
      $wlc_param_list='orderby=name&show_count=1&title_li=Categories on first post&include=' . $cats;
      wp_list_categories($wlc_param_list);
    }
    ?>
  6. JG99
    Member
    Posted 2 years ago #

    MichaelH, thank you very much - where do I put this code?

  7. MichaelH
    Volunteer
    Posted 2 years ago #

    In a sidebar.php

  8. JG99
    Member
    Posted 2 years ago #

    MichaelH, thank you again - Do I put this code in the WordPress sidebar, or in the sidebar for my particular theme? I have downloaded both sidebar.php files, and they are very different! The WordPress sidebar.php has many more lines of code in it. What is the starting and ending point for the code you have written above?

    Thank you again, I am sorry for my lack of knowledge in this area!

  9. MichaelH
    Volunteer
    Posted 2 years ago #

    You would put that in your theme's sidebar.php.

    See
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

  10. JG99
    Member
    Posted 2 years ago #

    OK, thank you - I will do some reading as you suggest and let you know how it goes!

    Appreciate the help!

  11. JG99
    Member
    Posted 2 years ago #

    MichaelH, I am sorry to disappoint you. I am unable to figure out where to add the section of code you so kindly provided. Here is the text version of my sidebar.php file from my theme. Where should I add the code?

    <?php thematic_abovemainasides(); ?>

    <?php if (is_sidebar_active('primary-aside')) { ?>
    <div id="primary" class="aside main-aside">
    <ul class="xoxo">
    <?php dynamic_sidebar('primary-aside'); ?>

    </div><!-- #primary .aside -->
    <?php } ?>

    <?php thematic_betweenmainasides(); ?>

    <?php if (is_sidebar_active('secondary-aside')) { ?>
    <div id="secondary" class="aside main-aside">
    <ul class="xoxo">
    <?php dynamic_sidebar('secondary-aside') ?>

    </div><!-- #secondary .aside -->
    <?php } ?>

    <?php thematic_belowmainasides(); ?>

  12. MichaelH
    Volunteer
    Posted 2 years ago #

    Looks like it might be better to download and install Otto's PHP Code Widget, then put that code in one of those widgets.

  13. JG99
    Member
    Posted 2 years ago #

    MichaelH, may I ask why you feel this is the best option?

  14. MichaelH
    Volunteer
    Posted 2 years ago #

    Because it seems your theme supports widgets.

  15. JG99
    Member
    Posted 2 years ago #

    OK, I will try - I appreciate your continuing support.

  16. JG99
    Member
    Posted 2 years ago #

    MichaelH, do I change the execphp.php extension to .txt and then insert your code? And then upload it to my plugins folder? Here is the content of execphp.txt, I am sorry but this looks pretty complicated! Could you tell me please where to insert the code?

    [code moderated]

    === PHP Code Widget ===

    Like the Text widget, but also allows working PHP code to be inserted.

    == Description ==

    The normal Text widget allows you to insert arbitrary Text and/or HTML code.
    This allows that too, but also parses any inserted PHP code and executes it.
    This makes it easier to migrate to a widget-based theme.

    All PHP code must be enclosed in the standard <?php and ?> tags for it to be
    recognized.

    == Installation ==

    1. Upload execphp.php to the /wp-content/plugins/ directory
    1. Activate the plugin through the 'Plugins' menu in WordPress
    1. Use the widget like any other widget.

    == Frequently Asked Questions ==

    = There's some kind of error on line 43! =

    That error means that your PHP code is incorrect or otherwise broken.

    = No, my code is fine! =

    No, it's not.

    Really.

    This widget has no bugs, it's about the simplest widget one can possibly
    make. Any errors coming out of the "execphp,php" file are errors in code you
    put into one of the widgets. The reason that it shows the error being in the
    execphp.php file is because that is where your code is actually being run
    from.

    So, if it says that you have an error on line 43, I assure you, the problem
    is yours. Please don't email me about that error.

  17. MichaelH
    Volunteer
    Posted 2 years ago #

    Okay assuming you have that plugin installed and activated, then visit Appearances->Widgets and drag the PHP Code Widget to the appropriate sidebar then put that code in the widget.

  18. JG99
    Member
    Posted 2 years ago #

    OK! I understand! Sorry that I overcomplicated things in my mind.

    So now IT'S WORKING!

    One small tweak I would like to make:

    With PHP Code Widget, I can write a "title." In this case, I am titling it "Categories."

    However, in your code you have the following line:

    $wlc_param_list='orderby=name&show_count=1&title_li=Categories on first post&include=' . $cats;

    Can I remove the "Categories on first post" somehow? That way, each page will simply show "Categories" (the title I have given the PHP Code Widget).

    How would I alter the code you have given me to accomplish this?

    THANK YOU MICHAELH! I really appreciate your help!

  19. MichaelH
    Volunteer
    Posted 2 years ago #

    $wlc_param_list='orderby=name&show_count=1&title_li=&include=' . $cats;

  20. JG99
    Member
    Posted 2 years ago #

    Michael, that's brilliant - I can't thank you enough.

    One more tweak, sorry to be such a bother:

    As it stands now, the number of times each category appears shows up in parentheses, for example:

    Burritos (3)

    Is there a way to eliminate the number and the parentheses around it, so that it is simply "Burritos?"

    Thank you again.

  21. MichaelH
    Volunteer
    Posted 2 years ago #

    See if you can find the answer in the wp_list_categories() article.

    Hint: it involves the show_count argument.

  22. JG99
    Member
    Posted 2 years ago #

    OK! I figured it out! Michael, you are the man!

    P.S. - Do you think we should clean up this thread a little, maybe remove some of the unnecessary posts where I pasted in all the code? Also, Otto's email address is on here, don't want him getting a bunch of spam emails as a result. I leave it up to you - thanks again for helping me!

Topic Closed

This topic has been closed to new replies.

About this Topic