If one meta key value is empty, try to get another meta key, and if both meta keys are empty show something else?

You can use if else: <div class=”video-embed” style=”margin-top: 0px; z-index:102; margin-bottom: 0px;”> <?php $url1 = get_post_meta( $post->ID , ‘video_play’ , true ) ?: get_post_meta( $post->ID , ‘video_stop’ , true ) ?: false; if( $url1 ): $search=”#(.*?)(?:href=”https://wordpress.stackexchange.com/questions/302040/https?://)?(?:www\.)?(?:youtu\.be/”youtube\.com(?:/embed/|/v/|/watch?.*?v=))([\w\-]{10,12}).*#x”; $replace=”http://www.youtube.com/embed/$2″; $url = preg_replace($search,$replace,$url1); ?> <iframe width=”560″ height=”315″ src=”<?php echo $url; ?>” frameborder=”0″ allow=”autoplay; encrypted-media” allowfullscreen></iframe> <?php else: echo … Read more

How to redirect to home page according to a specific page custom fields value and user name

After the headers have been sent (output has been written to the screen) you can not use wp_redirect() try placing your code in the header.php before any output and see if that works well enough. If not you will have to hook into ‘send_headers’, ‘template_redirect’, or ‘init’ and check the values and redirect before any … Read more

How can I check if a custom field was updated?

I think you forgot the priority of hook and number of arguments otherwise code is perfect. If you can update post meta for custom post type then you refer this. https://codex.wordpress.org/Plugin_API/Action_Reference/updated_(meta_type)_meta Try Like this: add_action( ‘updated_post_meta’, ‘bg_update’, 10, 4 ); For custom post type EX: abc <?php add_action( “updated_{$meta_type}_meta”, $function_name’, 10, 4 ); ?> <?php … Read more

Output Post with ACF Fields into other Post

To not duplicate code you could make a file in your theme/child-theme for the html of the post which you intend to embed, let’s say x_cpt_render_html.php: function get_x_cpt_html(){ ?> <div class=”x-cpt”> <h2> <?php the_title(); ?> </h2> <div class=”content”> <?php the_content(); ?></div> <div class=”custom”> <?php the_field(‘custom’); ?> </div> </div><?php } Then you could embed this file … Read more