• Following the instructions given, I put the following code in index.php & single.php:

    <?php echo list_posts_of_cat(get_the_category(), 5, 5); ?>

    However, no related posts are found.

    Changed “get_the_category()” to “the_category_id”, it works. However, this tag is deprecated.

    Also, what if the post belongs to a few categories? how can I determine the related posts are from which category?

    Assistance is greatly appreciated ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • Sorry about that! looks like SOMEONE changed some variable names under the covers… grrrrr. The two cases of ->category_id needed to be changed to ->cat_ID inside cg-samecat.php. get_the_category() returns a category ‘object’, which apparently had variable name changed, whereas the_category_id just returns a cat ID #. list_posts_of_cat can take category IDs (comma sep’d string if more than one), or a category-object array-array like get_the_category returns.

    I’m working on 1.5.1.1 right now (have been ALL week…), and may release it today and move on to .1.2 for further issues. Enough little things like this have built up.

    I just test it both sidebar and per-post, and works fine with my above change.

    If the post belongs to a few categories, then those categories will be the filter. If you don’t want specific categories in the filter, you’d need to remove them before passing through to list_posts_of_cats. That’d be pretty much what any such plugin would do, given multiple categories. ??

    You can also explicitly pass a category ID if you wish to show posts from a specific cat. Useful for showing ‘latest posts

    -d

    Thread Starter cheewl

    (@cheewl)

    Hi David! haha, thanks for your reply.

    The reason why I use the_category_id() is because get_the_category() doesn’t work with the plugin. It always says no related posts.

    My question is whether there will be a problem if I use the_category_id() instead of get_the_category() (of coz, if get_the_category () works, I will use it).

    Secondly, with the implementation of multiple categories, get_the_category() & the_category_id() are deprecated, so how should we deal with it?

    Anyway, I would definitely be looking forward to your updated plugin today. Keep everyone posted ok? ??

    You should be using get_the_category() — just needs my two tiny fixes to work with 1.5.1…

    Unfortunately, got backlogged with my ‘paying’ workload, so it’ll be tomorrow evening at the earliest before I can put out a new version.

    -d

    Thread Starter cheewl

    (@cheewl)

    yupyup! it worked! thanks alot David!

    No problems. Hopefully I’ll have the official fix in the next day or so. ??

    -d

    Thread Starter cheewl

    (@cheewl)

    Hi David, I changed the following code:
    from $apost->post_excerpt to $apost->post_content
    in order to show the full content of the related posts. The problem is, it removes all line breaks. All the contents are in 1 paragraph now instead of multiple paragraphs. any solution to that? ??

    you’d have to describe better what you are trying to use the plugin for. generally it is used JUST for the links. I added the excerpt thing just in case. Showing full post content, you’d need to do much more complex processing (as the content is all post-processed, so just grabbing ->post_content won’t do the job…).

    -d

    Thread Starter cheewl

    (@cheewl)

    Hi David,

    I am using the plugin to display the full content of related posts, i.e. when you view post 1 of category 1, all the content of other posts in category 1 will also be displayed after post 1. do you know what are the complex processing i need to do to the post_content in order to display them properly?

    Thanks in advance ??

    hmmm. that’s a tough one. you’d need a second instance of “The Loop”, with a new query to find all posts in category X, minus post Y, and then output them as desired. There’s been a number of recent discussions around here about adding a second Loop to the index page, though in this case you’d just be adding it to the Single page (after you output the main article, run another query and output all other articles).

    This could be VERY VERY server intensive, depending on how many articles are within a category. I can’t think of a case offhand you’d want an unlimited number of full articles output, but I don’t know what you’re planning. ?? ??

    -d

    David,

    Thank you for referring me to your CG-Same Cat.

    So far so good. I will let you see my fangirly site when I have it in better shape.

    No problem.

    I should have the 1.5.1.1 release of the PowerPack up this weekend, with the SameCat improvements, plus a few extra features in other plugins (and laying groundwork for a few new plugins…).

    -d

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘CG-SameCat not working with WP 1.5.1’ is closed to new replies.