Custom Field Filter in Shortcode

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 10 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6299 Reply

    Hi there,

    I have a question regarding the shortcode usage.
    What I would like to accomplish is to use a shortcode within a page to show events featuring a certain value in a certain custom field key.

    Example:
    Customfield key = Customer
    Customfield value = JohnSmith

    I could imagine that very shortcode looking something like this:
    [eo_events event_customfield_key=”Custom1″ event_customfield_value=”JohnSmith”]

    Would that be possible in some way or another?

    Thanks for your kind help!

    Linus
    #6302 Reply

    Hi Linus,

    The event list shortcode passes all the attributes to eo_get_events() (itself a wrapper for get_posts() ). While I’ve not tested it, in theory the following should work:

    [eo_events meta_key="Custom1" meta_value="JohnSmith"]
    

    Of course, any more complicated meta queries, or queries involving multiple keys wouldn’t be possible.

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Custom Field Filter in Shortcode
Your information:




To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax


<a href="" title="" rel=""> <blockquote cite=""> <code> <pre> <em> <strong> <del datetime=""> <ul> <ol start=""> <li> <img src="" border="" alt="" height="" width=""> <p style=""> <span style="">