how do i produce a list of wp posts based on taxonomy tag in my pod page?

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  johnnyn 1 year, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #167153

    johnnyn
    Member

    here is the scenario.
    I have a pod page of medical treatments. This is the detail page, and on the bottom of this page I want a list of the related news posts that are tagged with the same treatment name. The news posts are regular wp posts, with tags "news" and "[treatment name]"

    e.g. if my pod detail page is "heart surgery" then, at the bototm of the page I want a list of all the news articles that are tagged with "heart surgery" (and of course "news")
    the pod’s treatment name will be the same as the taxonomy tags used in my news articles.

    what would be the best way to do achieve this?

    #167154

    chris.pilko
    Member

    I actually have this on my list to add to one of my sites. Thanks for spurring me to do the research on it now.

    It looks like you can do something like this. See query_posts() on the WP-Codex for more information. You can also take a look at get_posts(), but the documentation there is severely lacking.

    You should be able to create a pick field on the related taxonomy terms from within pods. I haven’t tried this yet. Note that the tag you pass to query_posts() should be the tag’s slug.

    If you get this working, please post your code. I’m probably a month away from implementing this myself.

    #167155

    johnnyn
    Member

    thanks Chris, I will post what i end up doing.

    #167156

    johnnyn
    Member

    here is what i ended up using, thanks for the pointer Chris.

    I believe the ‘category name’ argument uses a comma as "or" and a plus as "and" but I don’t think you can mix "AND" "OR", for example, the following did not work for me.

    but these did work

    I have used categories, but tags works just as well if you want to filter by tags instead of categories. Just change the argument as below.

    I don’t see any way in the API to get both some articles from a category as well as some articles from tags, so you would probably have to run get_posts() twice and then join the results up.

    update…
    this is what i put on my pods detail page…
    I have a field in my pod called "tag" this is what i am filtering by as well as the category "news"

    you could probably use templates to do a better job

    — edit
    you can use categor_name as well as tag in the arguments. just add them both and it works.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Wordpress Cloud Hosting