How to get_term_meta on single custom post?

You will need to use get_the_terms() to get the taxonomy terms associated with the post and loop through them until you find one that has an image set: $post. = get_queried_object(); $terms. = get_the_terms( $post, ‘taxonomy_name_here’ ); $image_url = null; if ( $terms && ! is_wp_error( $terms ) ) { foreach ( $terms as $term … Read more

Access ACF fields within custom preview function?

As documented, the preview_post_link passes the post object as the second parameter. You can use this to get any fields that you might want: add_filter( ‘preview_post_link’, function( $preview_link, $post ) { $custom_field = get_field( ‘custom_field_name’, $post ); return $preview_link; }, 10, 2 // MUST be 2 to get the $post parameter. );

Function that replaces the image in the absence of the post meta

found the solution: $poster_path = get_post_meta($post->ID, “poster_path”, $single = true); if( $poster_path == “” ){ echo ‘<img width=”53″ height=”80″ src=”https://via.placeholder.com/370×556?text=No+Poster&000.jpg” />’; } else { echo ‘<img width=”53″ height=”80″ src=”https://image.tmdb.org/t/p/w370_and_h556_bestv2′.$poster_path.'” />’; }

search custom post type by custom fields on front end

I solved it and share it here if its help some one else add_shortcode(‘user_search’,’My_User_search’); function My_User_search($atts = null){ $out = user_search_form(); $args = array(‘post_type’ => ‘umrahpackage’,’order’ => ‘asc’, ‘meta_query’ => array( array( ‘key’ => ‘country’, ‘value’ => $_GET[‘s_value’], ‘compare’ => ‘Like’, ) ) ); $the_query = new WP_Query( $args ); if( $the_query->have_posts() ): while( $the_query->have_posts() … Read more

How to show meta value code HTML after x paragraph

The purpose of echo is sending strings to the output buffer. In your code you are concatenating the result of 4 to the result of the call to echo, which returns nothing. Also, get_post_meta already returns a string so you don’t have to do the type cast. Try: add_filter( ‘the_content’, ‘prefix_insert_post’ ); function prefix_insert_post( $content … Read more