Support

Search results for ""

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

custom field – posts

Hi,
I am using the Favorite Posts plugin and the favorites are stored as meta data on the users.
I am displaying the custom field “simplefavorites” as a post type in admin columns. This works well except for the fact that the list of favorited posts repeats twice in the admin column. The way the data is stored causes the posts to repeat. For example, the comma separated list of values looks like this for one user:
1, 6732, 7076, 13541, 15494, 13584, 1, 1, Default List, 6732, 7076, 13541, 15494, 13584
The actual post IDs are these – 6732, 7076, 13541, 15494, 13584
Is there a way to add a filter for a particular admin column to filter what is output by your plugin?
I would like to be able to parse this field prior to admin columns doing it’s thing with the post ids.
Any help would be appreciated.
Thanks,
Kathy

4 years, 4 months ago
Stefan van den Dungen Gronovius
Developer

Hi Kathy,

I’m not familiar with the Favorite Post plugin, but based on the value that you get for your column, I expect that the data is stored as an array in the database. The only way for you to manipulate the data and make it to something usable for your use case is to use one of our hooks to alter the actual value. The following hook is exactly meant for that but you’ll need to do some coding yourself though since I can’t help you with the actual implementation.

https://www.admincolumns.com/documentation/filter-reference/ac-column-value/

I’m not sure if you’re a developer, but I list the steps here below for you.

1) Create a hook to alter the value
2) Check for the Custom Field column (see example second example)
3) Check for your custom key to target your column
4) Start with the raw value -> $column->get_raw_value( $id )
5) Write your own logic to alter the raw value to make something usable out of it

Let me know if you have any further questions.

4 years, 4 months ago

You must be logged in to reply to this topic.