• Resolved rothschild86

    (@rothschild86)


    Hi,

    The documentation says the following regarding the tag param:

    Only return posts belonging to a specific tag name or slug.

    It’s the slug part I’m interested in. But when I specify a slug for a specific post, no filtering takes place.

    Using wpapi=true

    Any thoughts?

    • This topic was modified 4 years, 2 months ago by rothschild86.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Could you give me an example, so I can run some tests and see what’s happening?

    Thread Starter rothschild86

    (@rothschild86)

    Ended up adding these 3 tweaks to the plugin code directly and slug filtering works perfectly:

    712: ‘slug’ => ”,

    737: $slug = sanitize_text_field( $atts[‘slug’] );

    890: if ( $slug ) { $args[‘slug’] = $slug; }

    Reference: https://developer.www.ads-software.com/rest-api/reference/posts/

    Thread Starter rothschild86

    (@rothschild86)

    Looking at the code and the official docs, I think your documentation is misleading. Your ‘tag’ param maps to a ‘tags’ param in the api call, which filters strictly on tags. So I wouldn’t expect it to filter by a slug…

    Thread Starter rothschild86

    (@rothschild86)

    Here’s a sample that does not work:

    [jeherve_post_embed url=https://wptavern.com/ wpapi=true include_content=true include_images=false include_credits=false tag=new-plugin-displays-wordpress-environment-type-for-admins?number=1]

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Oh, I see what you mean now! When reading “slug”, you expected this to be a post slug, while I meant it as tag slug, e.g. wordpress-plugins, in opposition to a tag name (“WordPress Plugins”).

    If I were to update the text from “Only return posts belonging to a specific tag name or slug.” to “Only return posts belonging to a specific tag name or tag slug.”, would it be clearer?

    Thread Starter rothschild86

    (@rothschild86)

    Yes it would be clearer ??

    Please consider adding the above 3 lines as well. This guy was asking for the same functionality as well – https://www.ads-software.com/support/topic/retrieve-specific-page/ (which is what filtering by a post slug allows you to do)

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    I’ve made the change, thanks for the feedback!

    Please consider adding the above 3 lines as well. This guy was asking for the same functionality as well

    I made note of this here:
    https://github.com/jeherve/rest-api-post-embeds/issues/2

    Thread Starter rothschild86

    (@rothschild86)

    bravo ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Trouble filtering by slug’ is closed to new replies.