Support » Plugin: Same Category Posts » Posts belonging to several categories

  • Resolved aecorn

    (@aecorn)


    Hi, ive swapped to your widget since it was more up to date than the one I was using.

    A feature i am missing, is that my posts are associated with several categories, but your widget only shows the first of the categories in the sidebar. Is there a way to include this in the widget, or for me to add code?

    For every post-category
    create ul
    etc.

    There could be a checkbox or integer entry in the widget area, for the upper limit of how many categories you want in the sidebar.
    (Where “0” could be all, if you actually want 0, you would just disable the widget).

    https://wordpress.org/plugins/same-category-posts/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Daniel Floeter

    (@kometschuh)

    You can make a pull request at GitHub (https://github.com/DanielFloeter/same-category-posts). I need your proposal also for my own site and will provide a change in the next few days here on WordPress.org.

    Plugin Author Daniel Floeter

    (@kometschuh)

    I release a new version 1.0.7 with your requested fix.

    You can leave a replay if it works for you?

    Greetings and have a nice day.

    Hi, thanks for the fast response!
    Ive updated to 1.0.7 through the wordpress dashboard, but I dont see any difference in the “widget area”. How do I use this feature?
    I still see only one category in the sidebar of my posts.

    Plugin Author Daniel Floeter

    (@kometschuh)

    Can it depends that your setting ‘Number of posts to show’ shows not all posts? Set ‘Number of posts to show’ to 0, this works for me. 😉

    Or you can set ‘Sort by’ to ‘Random’.

    Ive changed to these settings:
    %cat%
    (checked) Make widget title link
    Number of posts to show: 0
    Sort by: Random
    (checked) Exclude current post

    The site is still only showing one category, and 18 posts in that category.

    Tried downloading from github. Does not make any difference.
    Setting the post number high enough includes more than the category contains however…
    What Im after is something like this:

      associatedCategoryname1 (link to category archive)

    • post1
    • post3
    • post4
      associatedCategoryname2 (link to category archive)

    • post5
    • post6
      associatedCategoryname3 (link to category archive)

    • post2
    • post7
    Plugin Author Daniel Floeter

    (@kometschuh)

    Can you try to set the ‘Number of posts to show’ to: +/-30?
    Maybe your Theme set a filter which isn’t removed after using, which set the post per page to 18.

    I get a lot of posts, if I set the limit to 500 for example. I think it is including posts from other categories than the first one.

    I think my main issue is that I want there to be several headlines of the categories. Right now you are converting the “widget-title” to the first category name with %cat%, but this means that there is no room for other category-headlines to get a headline. The second headline is what im talking about:

    <h2>category 1</h2>
    <ul><li> post1 </li>
    <li> post2 </li>
    <li> post3 </li></ul>
    
    <h2>category 2</h2>
    <ul><li> post4 </li>
    <li> post5 </li>
    <li> post6 </li></ul>
    Plugin Author Daniel Floeter

    (@kometschuh)

    Interesting layout, it’s an order by category.

    Do you have interest in write PHP code and make a pull-request on GitHub?

    Or you can use two or more Category Posts Widgets (https://wordpress.org/plugins/category-posts/) and one Same Category Posts Widget above.

    I dont know that much php yet, I am looking into it, and I want to learn, so I might give it a try. I do know basic programming logic, so Ive made a plan, I think this logic should work for your plugin as well, you could set the “category limit” to 1 for example.

    if post_single
    
    post_limit = 15
    cat_limit = 3
    
    cat_array = associated categories
    cat_num = number categories
    
    if cat_num > cat_limit
    cat_num = cat_limit
    
    cat_count = 0
    
    for cat_count < cat_num
    	post_array = posts of cat_array[cat_count]
    	post_num = number of posts in cat_array[cat_count]
    	sort post_array by date
    
    	if post_num > post_limit
    	post_num = post_limit
    
    	post_count = 0
    
    	if post_num > 0
    		<h3> <a cat_array[cat_count]_archive> cat_array[cat_count]_title</a> <h3>
    		<ul>
    		for post_count < post_num
    			<li class> <a post_array[post_count]_url> post_array[post_count]_title </a></li>
    			post_count ++
    		</ul>
    
    	cat_count ++
    Plugin Author Daniel Floeter

    (@kometschuh)

    Hello Aecorn,

    if you want you can beta-test the option ‘seperate categories’ here:

    Are you familair with GitHub? Because you can download the code there (https://github.com/DanielFloeter/same-category-posts) and copy it to your plugin folder ([your-wp-installation]/wp-content/plugins/same-category-posts) to your wordpress installation.

    Plugin Author Daniel Floeter

    (@kometschuh)

    Hello Aecorn,

    I released the a new version with your feature option. Test a lot and I ‘seperate categories’ works great.
    Like the idea because the option give the user more overview if he works with much categories and it gives a dynamic layout variation.

    Wow! Amazing! Exactly what I was after!
    Been busy this summer so haven’t had the time to download from Github, but thank you so much! The site has been updated and it works perfectly.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Posts belonging to several categories’ is closed to new replies.