Support » Plugin: Custom Content Shortcode » Ordering a Related Loop

  • jdnn

    (@habannah)


    Hi Eliot,

    I hope you’re doing well! It’s been years since I’ve needed to request support for this plugin, but it continues to be one of my favourite must-haves. So before asking my question, I just want to say thank you so much for all the work you’ve continued to put into CCS!

    Hopefully, what I am trying to achieve will be simple to implement. I would like to use a custom field value to order a related loop, like so:

    <p>
    	<ul>
    		[if exists]
    			[related type=offer taxonomy=travel-type,destination,travel-interest orderby=field_num key=end_date order=ASC]
    				[-if field=end_date value=future]
    					<li>
    						[field title-link]
    					</li>
    				[/-if]
    			[/related]
    		[else]
    			<li>
    				Nothing found
    			</li>
    		[/if]
    	</ul>
    </p>

    With the loop shortcode, the orderby parameter can be used with the field_num value for numerical fields, and the key parameter is used to identify the correct field to use. I would like to do the same with the related shortcode. Unfortunately, it’s not possible to use the orderby parameter with a field value in the related loop. Would it be possible to add that ability to the plugin?

    Also, as an aside, you can see from the example that [if exists] is being used with an [else] condition. However, with the loop shortcode, there is no need for an [else] condition at all, because [loop exists] only prints items returned by the loop in the first place. If at all possible, I would much prefer being able to use something like [related exists] and getting rid of superfluous “Nothing found” text on my site.

    Many thanks in advance for any assistance you can provide!

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