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.
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.
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.
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.
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.
<?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);
}
?>MichaelH, thank you very much - where do I put this code?
In a sidebar.php
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!
You would put that in your theme's sidebar.php.
See
Stepping Into Template Tags
Stepping Into Templates
Template Hierarchy
OK, thank you - I will do some reading as you suggest and let you know how it goes!
Appreciate the help!
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(); ?>
Looks like it might be better to download and install Otto's PHP Code Widget, then put that code in one of those widgets.
MichaelH, may I ask why you feel this is the best option?
Because it seems your theme supports widgets.
OK, I will try - I appreciate your continuing support.
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.
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.
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!
$wlc_param_list='orderby=name&show_count=1&title_li=&include=' . $cats;
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.
See if you can find the answer in the wp_list_categories() article.
Hint: it involves the show_count argument.
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!
This topic has been closed to new replies.