• Resolved rainyh

    (@rainyh)


    I’m trying to make my Pods List Items widget display a list of custom post types but I need have a function be applied to a certain field before they’re listed. So far the template & function does work BUT I only get 1 item displayed, even though widget settings specify that 3 items should be listed.

    This is my Upcoming Events template:

    <?php function fix_date_field( $time ) {
    			if (( is_numeric($time) && (int)$time == $time )) { 
    				return '<p>'. date('m-d-Y',$time) .'</p>'; 
    			} else { 
                return '<p>'. $time .'</p>'; }
    			}
    
    ?>
    		
    <li>
    <h4><a href="{@permalink}">{@title}</a></h4>
    	{@wpcf-date_time,fix_date_field}
    </li>

    And these are the settings for that widget:
    Title: Upcoming Events
    Pod: Events
    Template: Upcoming Events
    Before Content: <ul class=”test”>
    After Content: More Events
    Limit: 3

    • This topic was modified 5 years ago by rainyh.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @rainyh

    You are not allowed to use PHP code within templates.
    Please add that function in your functions.php of your theme or in a custom plugin.

    On the amount of items issue. If there are more items available then this should work fine. Do you have other filters active like a where clause?

    Cheers, Jory

    Plugin Author Jory Hogeveen

    (@keraweb)

    Closing topic due to no reply, feel free to reopen if you still need help!

    Cheers, Jory

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Using a function in pods template?’ is closed to new replies.