• Resolved webskitter

    (@webskitter)


    Why isn’t this working in a custom text block?

    [pods name=”post”? where=”category.name='{@post_title}'”?template=”latest news”]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Jim True

    (@jimtrue)

    Magic Tags have a very specific context where they will work. They can only be called in a Pods Template or Custom Template (the space between [pods]…[/pods]). Only our Special Magic Tags can be used in where clauses in shortcodes.

    That seems like an odd where clause trying to find the category based on the Post’s Title. What are you trying to accomplish? I can tell you’re trying to grab a list of posts that match a specific category, but I’m looking for a little context as to how that would relate to the current post title.

    Also when you refer to ‘custom text block’, do you mean in the new Block Editor or are you in a Builder of some kind (like Beaver Builder, Elementor, etc.?)

    Thread Starter webskitter

    (@webskitter)

    What I’m trying to do is that news items from this particular category (category name is based on pagetitle) is loaded on each page.

    eg. On page ‘Energy’ news items from category ‘Energy’ is loaded.

    Plugin Contributor Jim True

    (@jimtrue)

    So you’re in a WordPress Page in the Editor block and typing the shortcode? As noted above, you can’t use a magic tag for the post title in the where clause.

    Ideally, you should just use a Taxonomy filter the normal way, especially since these are WordPress Posts:

    /category/news/

    If you’re going to be creating individual WordPress pages for each of those categories, you’re going to have to just use the shortcode in the WordPress editor of:

    [pods name="post" where="category.slug = 'news' template="Latest News"]

    because the magic tag {@post_title} will not work there. You could create a template called ‘Call Latest News’ that only had one line in it:

    [pods name="post" where="category.name = '{@post_title}' template="Latest News"]

    And then in your ‘Energy’ page, you could put [pods template="Call Latest News"] where you wanted the Latest News and that would work, but you’d have to make sure you configured Pods Templates to Call Shortcodes:
    https://docs.pods.io/displaying-pods/pods-templates/using-shortcodes-in-pods-templates/

    In this way, the template ‘Call Latest News’ would from the page titled ‘News’ pass the post_title ‘News’ into the shortcode above and then output the ‘Latest News’.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘load posts by category’ is closed to new replies.