Admin meta Image Path

Unfortunately your question is still unclear after all the explanations, but based on your efforts, I guess you need to pass the image’s URL to a meta field or some sort of array. So, turning your current code into this will fix the issue: ‘img1’ => ‘<img src=”‘.get_template_directory_uri().’/inc/admin/images/layout.png” alt=”Image 1″ title=”Image 1″>’

Display custom fields on post excerpt or teaser

The way to retreive some meta data is knowing the name of the custom field, for my example I will use: listing, property and address; normally this can be done after while (have_posts()) : the_post(); $listing = get_post_meta($post->ID, ‘listing’, true); $property = get_post_meta($post->ID, ‘property’, true); $address = get_post_meta($post->ID, ‘address’, true); then you can print the … Read more

WP_Query: include custom post type only with specific meta value

If the key-2 is uniquely assigned to cpt-3 post type, then you can add another meta query argument to your query arguments: array( ‘key’ => ‘key-2’, ‘value’ => 1, ‘compare’ => ‘=’ ) If not, you can run another query, and then merge them as follows: $final_query = array_merge( (array) $query_1, (array) $query_2 ); But, … Read more

How can I store a file in the database in the same way WordPress and ACF do?

ACF doesn’t store any file in Database, it simply provides meta fields with user friendly interface. You can however, store them yourself. To store a field, you need to be familiar with PHP a bit. Here’s how saving a meta field happens, by using the add_post_meta() function: add_post_meta ( $post_id, ‘meta_key’, ‘meta_value’, $is_unique ); There … Read more

Save the_content into custom field

You can get the content with $_REQUEST, Try the below code: add_action(‘publish_post’, ‘save_content_to_field’); function save_content_to_field($post_ID) { if(isset($_REQUEST[‘content’])) { update_post_meta($post_ID, ‘desc’, $_REQUEST[‘content’]); } } UPDATED With the below code if you want to sore with shortcode support: add_action(‘publish_post’, ‘save_content_to_field’); function save_content_to_field($post_ID) { $post = get_post($post_ID); $result = apply_filters(‘the_content’,$post->post_content); if($result) { update_post_meta($post_ID, ‘desc’, $result); } }