How to copy a custom field from the user’s CPT to the user’s normal posts

You can use the wp_insert_post action for when a user creates/saves a “normal” post, then find their custom post and copy over any fields you need: function wpse_203349_copy_post_meta( $post_ID, $post, $update ) { if ( $post->post_type !== ‘post’ ) return; $users_custom_posts = get_posts( array( ‘posts_per_page’ => 1, ‘post_author’ => $post->post_author, ‘post_type’ => ‘custom_post_type’, ) ); … Read more

Loop through incrementing custom fields

How can I loop through the fields and display the content without having to deplicate it? This for loop will cycle through the four field names to avoid duplication. <?php for ($i=1; $i<=4; $i++) { $fieldName=”featured_content_” . $i; $featuredContentPostID = get_field($fieldName)->ID; $selectedFeaturedContent = get_post( $featuredContentPostID ); ?> <li> <a href=”https://wordpress.stackexchange.com/questions/204839/<?php echo esc_url( get_permalink($featuredContentPostID) ); ?>”> … Read more

Variable Products as custom post types

Use it can be done using CUSTOM META BOX. Add following to function.php: /* Adds pizza size meta box to the post editing screen ******************************************************/ function prfx_custom_meta() { add_meta_box( ‘prfx_meta’, __( ‘Pizza Size’, ‘prfx-textdomain’ ), ‘prfx_meta_callback’, ‘post’ ); } add_action( ‘add_meta_boxes’, ‘prfx_custom_meta’ ); /* Outputs the content of the meta box **************************************/ function prfx_meta_callback( $post … Read more

Display custom meta on page that has been check in custom post type

You just want a meta_query based on the current page’s ID: $query = new WP_Query( array( ‘post_type’ => ‘sidebar_boxes’, ‘posts_per_page’ => -1, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘meta_query’ => array( ‘key’ => ‘checkfieldBox’, ‘value’ => $post->ID, ) ) ); You can really only depend upon $post in the way I did on “singular” pages … Read more

Adding Template Post Content

It’s possible you may have to define your own ACF Custom Field Type which holds your templates. And after a template is selected then you would programmatically copy the fields to a repeater. Awesome ACF has quite a few examples, WordPress has quite a few plugins and there is a User Submitted Add-Ons support forum.