You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the above hook accepts an array of options, I can return the array $query_arguments. But for the title hook, if I just want to add say, the first category name to all association titles, I just want to return the $title once I'm done without having to specify an $id. Is that possible?
The text was updated successfully, but these errors were encountered:
The hook only expects you to return a title - the other arguments are there to help you out with extra information should you need it.
Here's an example:
add_filter( 'carbon_fields_association_field_title', function( $title, $field_name, $id, $type, $subtype ) {
$field = 'related_posts'; // the field you wish to filterif ( $field_name !== $field ) {
return$title; // not the field we want to filter - return the title unmodified
}
return'Custom Prefix: ' . $title; // add a custom prefix to all options
}, 10, 5 );
This filter will cause all of your options to have a "Custom Prefix: " prefix.
@atanas-angelov-dev That works perfectly. Just what I needed. Thank you. It'd be great to see some of these examples on the docs. Perhaps I'll fork the docs and make a contribution. 😄
Hi there,
I've been browsing the hooks page, and I'd like to edit the titles of my association field items on the dashboard.
https://carbonfields.net/docs/advanced-topics-hooks/?crb_version=2-1-0
I tried using the
carbon_fields_association_field_title
hook but it didn't seem to work quite like the only other hook I've tried for query options:Since the above hook accepts an array of options, I can return the array
$query_arguments
. But for the title hook, if I just want to add say, the first category name to all association titles, I just want to return the$title
once I'm done without having to specify an$id
. Is that possible?The text was updated successfully, but these errors were encountered: