Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Rocco

Column Informations

Hello, I need to find the name of a column from his meta.
If I know that a column meta for a specific custom post type is column-meta-1, how can I find the name of this column.
Or better can I find the name of custom field related with this column?

8 years, 7 months ago
Tobias Schutter
Developer

Hi Rocco,

If you would just like to retrieve the Custom Field key that corresponds to the column name I would suggest using the Column object.

Here is an example code that retrieves the column object and outputs the custom field key.


function ac_get_column_by_name_example() {

	$post_type = 'post';
	$column_name = 'column-meta-1';
	$layout_id = '';

	if ( $column = cpac()->get_column( $post_type, $layout_id, $column_name ) ) {

		// output column label
		echo $column->get_label();

		// output custom field key
		echo $column->get_field_key();
		exit;
	}
}
add_action( 'cac/loaded', 'ac_get_column_by_name_example' );

Here you will find further documentation about the Column object and it’s methods.

8 years, 7 months ago

You must be logged in to reply to this topic.