Support

Account

Home Forums Backend Issues (wp-admin) get_fields(); with a post name instead of post id

Unread

get_fields(); with a post name instead of post id

  • Hi,
    I am trying to get all the custom fields associated with a post type by post name.
    I would like to use post name over post id so i can get the result even if that post type contain no post.

    I tired that :

    $post_types = get_post_types( array('public'   => true), 'names' ); 
    
    	foreach ( $post_types  as $post_type ) {
    
    		$fields = get_fields($post_type);
    		echo '<pre>';
    		var_dump( $fields ); 
    		echo '</pre>';
    		
    	}

    Unfortunately it returns false.

    in the doc it says about post id This can also be options / taxonomies / users / etc does it mean i can query it by name?

    any ideas on how i could use get_fields(); by post name?

Viewing 1 post (of 1 total)

The topic ‘get_fields(); with a post name instead of post id’ is closed to new replies.