• Hello, we would like to output a recommendations list in the sidebar that is based on the tags of the current post. So lets say the post has tag1 tag2 and tag3, we want to output 3 random posts of all posts that also have tag1 or tag2 or tag3. I discovered the categorypage parameter that detects the current category. Is there any possibility to also detect the currents tags?

    https://www.ads-software.com/plugins/list-category-posts/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Fernando Briano

    (@fernandobt)

    Adding this to version 0.44 too, check it out!

    Thread Starter Sofian777

    (@sofian777)

    but, please tell me, did you write it now after my posts because you liked the idea, or is it such a syncronicity that you worked on exaxtly the two options i need right now?

    if option 1, then thank you for your amazing fast response and integration of the parameters.

    i will check it out soon, at latest tomorrow i will give you feedback…

    sidenote:
    https://www.ads-software.com/plugins/list-category-posts/other_notes/
    there is one star too much, giving wrong formatting:
    **currenttags*

    Thread Starter Sofian777

    (@sofian777)

    First test:

    I added [catlist currenttags=yes] into a text widget and it seems that it works on a AND base, so only the posts that have exactly all the same tags are shown (in my case only the same post ?? I guess this is more rarely needed.

    I would need it on a OR base, meaning it is enough if one of the tags of two posts are the same to be taken into the list. Is this possible as well? I think this behaviour would make more sense in general for most situations.

    On pages, the widget gives an error message (of course it should not be displayed on pages with such a function, since they have no tags, but maybe it can just stay empty)

    Warning: Invalid argument supplied for foreach() in /var/www/vhosts/sundari-spiritual-art.de/httpdocs/imlichtewplay/wp-content/plugins/list-category-posts/include/CatList.php on line 241

    Thread Starter Sofian777

    (@sofian777)

    Hello again, i saw you already fixed the error message in a new update. Could you please let me know about the AND / OR fact, just a short line if you consider to add/change it, thank you once more…

    Plugin Author Fernando Briano

    (@fernandobt)

    Hi Sofian777,
    Yep got the warning fixed.

    About the other question, I am using the tag__in parameter from WP_Query. So it should be using (it is in my tests) the OR relationship. To use an AND relationship, I should use the tag__and parameter.

    How are you using it on the text widget? Just the shortcode and it works?

    It’s really strange :S
    Double check your tags and let me know, see if we can fix this.

    Thanks!

    Thread Starter Sofian777

    (@sofian777)

    The shortcode didnt simply work, i added
    add_filter('widget_text', 'do_shortcode');
    to my functions.php ??

    I made now more detailed testing and it is true, it works after the AND principle, the mistake was in our tag structure that made it look different. With specific testposts i can now confirm AND.

    Yet i discovered

    – one unclear behaviour:
    When the post has no tag, or a page is opened (which has no tags by nature), the error message is fixed, but the list is not empty, but full, it seems to take “nothing” for “everything”. Maybe a little “if posthavetag” or something could avoid this. I think if there is no match, it needs to be empty.

    – one improvement:
    the post itself is also listed, which i think in rare cases is wanted or needed. can it be excluded?

    Thread Starter Sofian777

    (@sofian777)

    I just read another post now:
    https://www.ads-software.com/support/topic/remove-current-post-from-list
    which solves my last point here.

    Plugin Author Fernando Briano

    (@fernandobt)

    I’ll add a condition for when there are no tags to not show any posts. Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Detecting current tags’ is closed to new replies.