Haroon Q. Raja on "[Plugin: Advanced Custom Fields] Generate Media Description from Custom Fields"

ساخت وبلاگ

I have added a few custom text fields to media attachments using ACF. These include:

  • hqr_artwork_artist
  • hqr_artwork_medium
  • hqr_artwork_price

Now what I need to do is that whenever an attachment is saved, the Description field (the one that comes built-in with WordPress for media items and is essentially the_content for the attachment post type) gets updated automatically to the following:

Artist: <?php get_field( "hqr_artwork_artist" ) ?><br />
Medium: <?php get_field( "hqr_artwork_medium" ) ?><br />
Price: <?php get_field( "hqr_artwork_price" ) ?>

So essentially, I need to take the values of these ACF fields and use them to create a custom content string for the Description field that I can then show in a lightbox in galleries, or use elsewhere in the theme (such as on the attachments template) using a single template tag.

I don't know which action to use for the purpose (and how to use it) so that this works immediately after a media item is saved, be it when adding a new item to the media library and specifying these custom fields for the first time, or when editing an existing item in the media library and changing the values of any of these custom fields.

Any help in this regard (preferably as a working example) will be immensely appreciated.

https://wordpress.org/plugins/advanced-custom-fields/

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 368 تاريخ : دوشنبه 18 مرداد 1395 ساعت: 0:51