Custom Fields
Re-Envisioned
Support General How to get value of Custom Fields in Block Render Settings without HTML formatti

  • Creator
    Topic
  • #31820
    Resolved petr@vopelak.cz
    Participant

    Hello,
    custom field for Taxanomy Advanced ( https://docs.metabox.io/fields/taxonomy-advanced/ ) returns the value already wrapped in HTML list.

    
    {{ my_tags }} outputs:
    
    <ul>
    <li><a href="..." title="...">...</a></li>
    <li><a href="..." title="...">...</a></li>
    </ul>
    

    The same applies for IF statement {% if my_tags == ...
    No luck using loops either.

    It can be stripped out of HTML tags, yet for the Post field ( https://docs.metabox.io/fields/post/ ), it becomes near to impossible to extract information about selected posts in a way it can be further used in a template. I need to be able to iterate through the selected posts, access their properties and output them the way I need them to be structured.

    I have also noticed that RADIO button always returns the value, not the key. There seem to be some filter for outputing variables of any kind. It's nice and easy for sure, yet not suited for more complex tasks.

    Is there any way to get unformatted output?
    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #31828
    petr@vopelak.cz
    Participant

    I also know about the rwmb_get_value function, but none of rwmb_* functions returns anything for me.

    That works:

    {{ my_field }}
    
    That not works: (returns nothing at all)
    {{ mb.rwmb_get_value('my_field') }}
    {{ mb.rwmb_get_value('my_field', '', post_id) }}
    

    I'm still inside Block Render Settings of Custom Fields, if that means anything.

    #31843
    Long Nguyen
    Moderator

    Hi,

    You can try to use the helper function mb_get_block_field() to get the field value (raw) in the block. Get more details on this documentation https://docs.metabox.io/extensions/mb-blocks/#render_callback

    #31845
    petr@vopelak.cz
    Participant

    Works like a charm. Couldn't find it.
    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.