Custom Fields
Re-Envisioned
Support General How to display relationship fields NOT as list items

  • Creator
    Topic
  • #28353
    Testamentum
    Participant

    Hi, I have two custom post types, hotels and cities, and I want every hotel to display custom fields for the city hotel is located in. The problem is fields are always displayed as list items, with bullets.

    I tried in two ways. First, without setting up a relationship, just adding a city field inside Hotel CPT, and pointing that field to cities cpt. Cities data is displayed using Elementor widgets even though there is no relationship.

    Then I added a relationship between them, and then the relationship appears in edit column of the post (like here: https://www.youtube.com/watch?v=JBqIRrdzGDc) and I can choose the city there as well.

    In both cases in the post edit screen I got either a checkbox or a select field to choose the city. But in both cases output is a list item. How can I do this so the output is not a list tiem?

    p.s. I know how to remove the bullet via CSS, but that is still a list item.

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #28379
    Long Nguyen
    Moderator

    Hi,

    You can add your own HTML tags when showing the list posts relationship without the default <ul><li>, such as

    {% for post in relationships.posts_to_pages.from %}
        <div class="block-relationship">
            {{ post.title }}    
        </div>
    {% endfor %}
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.