• Resolved vdl

    (@dellalibera)


    I put together a solution that is already working with the Custom Post UI, however Pods works better for me, so I want to migrate to it.

    My code working correctly today with CPT UI is:

    function course_settings($config) {	
    	$terms = get_the_terms( get_the_ID(), $config );
    	$lista_nomes = null; 		 
        $list = array();
     
        foreach ( $terms as $term ) {
            $list_names[] = $term->name;
        }
    	
        $list_done = join( ", ", $lista_nomes );
        return $lista_done;
    }

    So I tried to do the same thing with Pods, but it is returning all fields from all custom posts in my $ config parameter.

    function course_settings_pods($config) {	
    
    	$params = array();	
    	$mypod = pods( 'course_2',$params);
    
    	$list=array();
    	while ( $mypod->fetch() ) {
    		$list[]=$mypod->field( $config );
    	}
    
    	 $list_done = join( ", ", $list );
     	 return $lista_done;

    I don’t know how to make it return only the fields of the current post. Can someone help me?

    • This topic was modified 4 years, 5 months ago by vdl.
    • This topic was modified 4 years, 5 months ago by vdl.
    • This topic was modified 4 years, 5 months ago by vdl.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @dellalibera

    Your original code should work fine with Pods as well. No need to change anything as far as I can see there.

    So I tried to do the same thing with Pods, but it is returning all fields from all custom posts in my $ config parameter.

    How is the function course_settings called? By a filter?

    Cheers, Jory

    Thread Starter vdl

    (@dellalibera)

    No, it is called by another function which is called by a shortcode.

    • This reply was modified 4 years, 5 months ago by vdl.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hello @dellalibera

    Can you share these functions and shortcode? I need to know how it all exactly works currently in order to help you.

    Cheers, Jory

    Plugin Author Jory Hogeveen

    (@keraweb)

    Closing topic due to no reply. Feel free to reopen if you still niet help!

    Cheers, Jory

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Take only one field from a one custom post.’ is closed to new replies.