Support

Search results for ""

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

Click on ACF column to edit field

Hi.

I am using the pro edition of the plugin together with ACF.
I have created a custom post type and added a date-field with ACF. I am not going to use the title for the posts.

I have added a piece of code that automatically sets the title of the post to the value of my custom date field.
The reason that I don’t want to use the title field to store the date is that 1) it does not provide the user with a date-picker, or any validation, and 2) the posts will not be sorted correctly by date.

I have added the date column with your plugin, but if I remove the title-column from the post listing I cannot click to edit a post, because the date-column is not linked to the post.

Is there any way to solve this for me?

8 years ago
Stefan van den Dungen Gronovius
Developer

Hi Audun,

It seems that in our latest release the primary column, the column where WordPress adds the action row, is not set correctly. I’ve created a ticket for this and already made a fix. This fix will be in the next release.
https://github.com/codepress/admin-columns-issues/issues/475

You can use a filter to set the primary column yourself in your function.php something like this.

function cac_set_primary_column( $default, $screen ){
	if( 'edit-post' == $screen ){
		$default = 'column-acf_field';
	}
	return $default;
}
add_filter( 'list_table_primary_column', 'cac_set_primary_column' , 10, 2 );

In this example I set the primary column for the post screen (edit-post) to my first ACF field (‘column-acf_field’). You can find the correct column name if you inspect the table cell with the value. If you only have 1 ACF column, you can probably use the same string I used -> ‘column-acf_field’.

8 years ago
Audun

Hello and thank you for the answer.

I have tried your solution, but can’t get it to work. Perhaps I am missing something.

This is my date column: http://imgur.com/30HlwX6

It is named ‘column-acf_field-1’ (this other column is ‘column-acf_field’, and is linked to another custom post type. So I use this function:

function cac_set_primary_column( $default, $screen ){
	if( 'edit-post' == $screen ){
		$default = 'column-acf_field-1';
	}
	return $default;
}
add_filter( 'list_table_primary_column', 'cac_set_primary_column' , 10, 2 );

But nothing. I am not familiar with this filter – did I get something wrong?

Thanks
Audun

8 years ago
Stefan van den Dungen Gronovius
Developer

Hi Audun,

The check for your $screen variable is not correct.
In you screenshot you use the post type Møter and in my code example I checked for the default post screen.
The post_type slug for you post type will be something like ‘møter’ or ‘moter’.
You can find the correct slug in your url -> post_type={post_type}

Then you have to change the if-statement to your post type, something like:
if( 'edit-moter' == $screen ){ or if( 'edit-møter' == $screen ){

8 years ago

You must be logged in to reply to this topic.