• Resolved hsnyc

    (@hsnyc)


    I have a template as follows:

    [if active]
    	<div class="home-container">
    		<h2 style="display:inline-block">{@post_title}</h2> - <h4 style="display:inline-block; color:#B74D5B">{@home_category}</h4>
    		{@post_thumbnail.large}
    		{@post_content}
    		<p>Posted: {@post_date, post_date}</p>
    	</div>
    [else]
    
    <h3>No homes available</h3>
    
    [/if]

    So this will check if the post has a custom field named active set to true and if so display the post. But if it does not then show the message ‘no homes available’.

    Problem is, the message is being outputted one time per post. Here is the URL: https://towneplacehoa.com/sales-and-rentals/

    What am I doing wrong here. Any help is appreciated. Thanks for your help!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Jim True

    (@jimtrue)

    How are you calling the template? That will control whether it’s shown once for the current post or for all of them.

    If you’re wanting this to run on the current post, use Auto Templates to call this template. If you’re using a page builder, add an HTML block to the Theme Layout or the Layout Builder for the Single Post Detail and call the template with [pods template="Home Listing"] (or whatever you called it).

    If it’s calling for every home, it sounds like you’ve called it with a shortcode with name="post-type" in the parameters list. This takes the shortcode out of the context of the current post. If you want the pods shortcode to be based on the current post, you can’t use ‘name’.

    Thread Starter hsnyc

    (@hsnyc)

    Hi Jim, Thanks for the reply. On the Sales and Rentals page (https://towneplacehoa.com/sales-and-rentals/) I have the following short code: [pods name=”home” template=”Homes”]. The ‘Homes’ template code is above. The pod ‘home’ has a single Yes/No field named ‘active’.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Else statement in template’ is closed to new replies.