Difficulty displaying related-post images in views

Support MB Views Difficulty displaying related-post images in views

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #36379
    Brent WilsonBrent Wilson
    Participant

    I am trying to set up a MB Views item to display related presenters at the end of single event posts. I have the presenter titles showing up, but am having difficulty getting the presenter featured images to show. Can you please tell me what I might be doing wrong? In addition, I would like the featured images to be displayed in the medium large size. How can I do this?

    <h2>
    	Presenters
    </h2>
    {% set args = {post_type: 'presenters', nopaging: true, relationship: {id: 'events_presenters_relationship', from: post.ID}} %}
    {% set presenters = mb.get_posts( args ) %}
    
    <div class="presenters_card">
    	{% for presenters in presenters %}
    		<div>
    			{{ mb.get_the_post_thumbnail( presenters, 'thumbnail' ) }}
    			<h3>{{ presenters.post_title }}</h3>
    		</div>
    	{% endfor %}
    </div>

    https://postimg.cc/LgBwQsgt
    https://postimg.cc/bSTVHF4L

    #36380
    Brent WilsonBrent Wilson
    Participant

    Also, what code to I need to use in MB Views to access the URL of the related post?

    #36388
    Long NguyenLong Nguyen
    Moderator

    Hi Brent,

    In a custom query, you can use the post field items in the Insert Field tab to display the post URL, post content ... in a custom query. Please check this screenshot https://monosnap.com/file/NBke9ScHpdSk2Njp22dwYUu4ulWtRG

    #36396
    Brent WilsonBrent Wilson
    Participant

    What about the questions in my first post above?

    #36410
    Brent WilsonBrent Wilson
    Participant

    When I add the post URL using the insert field, it is the URL of the current post, not the related post. How do I get this to show the image or the URL or whatever for the related post?

    #36425
    Long NguyenLong Nguyen
    Moderator

    Hi Brent,

    Please make sure that you have the correct post object in the loop. By default the post object when adding fields from Insert Field is post, you should change it to presenter. For example

    {% for presenter in presenters %}
    <div>
    	{{ mb.get_the_post_thumbnail( presenter, 'thumbnail' ) }}
    	<h3>{{ presenter.post_title }}</h3>
    	{{ presenter.url }}
    	<img src="{{ presenter.thumbnail.thumbnail.url }}" width="{{ presenter.thumbnail.thumbnail.width }}" height="{{ presenter.thumbnail.thumbnail.height }}" alt="{{ presenter.thumbnail.thumbnail.alt }}">
    </div>
    {% endfor %}
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.