How to display relationship fields NOT as list items

Support General How to display relationship fields NOT as list itemsResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28353
    TestamentumTestamentum
    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.

    #28379
    Long NguyenLong 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 %}
    #34169
    SharifSharif
    Participant

    And how can this be applied to Elementor? It shows up as a bulleted list item here as well.

    #34276
    YasmineYasmine
    Participant

    +1

    I have been doing this with CSS - but it would be easier if there was a custom setting to add onto the custom field. Thank you!

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