How to set up a echo? [closed]

You can use get_post_type() function and pass current post id to it. global $post; if(get_post_type($post->ID) == ‘videos’) { // do this } Update <?php global $post; if(get_post_type($post->ID) == ‘videos’) { ?> <video class=”video” width=”https://wordpress.stackexchange.com/questions/91208/<?php echo get_field(“width’); ?>” height=”https://wordpress.stackexchange.com/questions/91208/<?php echo get_field(“height’); ?>” controls preload> <source src=”https://wordpress.stackexchange.com/questions/91208/<?php echo get_field(“mp4′); ?>” media=”only screen and (min-device-width: 960px)”></source> <source src=”https://wordpress.stackexchange.com/questions/91208/<?php … Read more

Good practical way to do loop within loop to show child custom type using a template code

<?php global $post; foreach ($event_photos_obj as $post) : … … // set up product in order to use native wordpress api setup_postdata($post); /* Include the single view for the product (photo). */ include ….. endforeach; wp_reset_postdata();?> my mistake my code is that setup_postdata with $product instead of $post as the tutorial said : https://codex.wordpress.org/Function_Reference/setup_postdata This … Read more

Custom Field Search

Use pre_get_posts to filter search results: function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set(‘post_type’, ‘custom_post_type_name’); $query->set(‘cat’, intval($_POST[‘cat’]); // assuming you have a select with categories with name “cat” } } } add_action(‘pre_get_posts’,’search_filter’);

Retrieve a post with its ACF repeater fields in wordpress

<?php $the_query = new WP_Query(array( ‘post_type’ => ‘our-partners’, ‘posts_per_page’ => 1, ‘order’ => ‘DESC’ )); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); if( have_rows(‘slider_partenaires_hp’) ): //”slider_partenaires_hp” is the repeater field // loop through the rows of data while ( have_rows(‘slider_partenaires_hp’) ) : the_row(); // display a sub field value echo “<li … Read more

Pagination for custom post type on multisite not working

Just briefly looking at the code, the first thing I spotted is ‘post_type=game&posts_per_page=4&paged=$paged’. Because you’re using single quotes, paged will never equal the current page. You should use double quotes so the $paged variable is actually used in your query: “post_type=game&posts_per_page=4&paged=$paged” You can learn more about single quoted and double quoted strings in the PHP … Read more