How to get post ID from button and pass title to Modal

When we display post data in model with on click of button we have to provide the post-id with data attribute in for specific model target. Please add post-id in data-target in anchor tag as well as in main div tag ID. I have modified your code here: <div><?php echo wp_get_attachment_image($image_upload,$size=”full”);?><br/> <span class=”name”><?php echo $title; … Read more

Separate First Post Loop

Try like this which fill skip first post: $i = 0; while ( have_posts() ) : the_post(); if($i > 0) get_template_part( ‘template-parts/content-home’, get_post_type() ); else { // design your first post as you wish with HTML, CSS the_title(); the_permalink(); the_post_thumbnail(); the_content(); the_author(); the_date(); } $i++; endwhile;

Loop posts based on permalink term

Got it to work with: $queried_object = get_queried_object () ; and ‘terms’ => $queried_object->slug, full code now: <?php $queried_object = get_queried_object () ; $posts = array ( ‘post_type’ => ‘writing’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘type’, ‘field’ => ‘slug’, ‘terms’ => $queried_object->slug, ), ), ); $loop = new WP_Query( $posts ); … Read more

how to get category`s slug in WP_Query loop?

get_the_category() retrieves WP_Term objects for all the categories assigned to the post. You can combine that with wp_list_pluck() to just get the slugs: $categories = get_the_terms( null, ‘project-category’ ); $category_slugs = wp_list_pluck( $categories, ‘slug’ ); $category_slugs will now be an array of slugs for the categories of the post.

How to pass current loop data into nested loop

What you’ve done with the variable is correct (defining it before starting the next loop), but you’re not outputting it correctly: <p>current post = <?php $current_page; ?></p> If you want to output $current_page to the screen, you need to echo it: <p>current post = <?php echo $current_page; ?></p>

display posts of custom post type with custom taxonomy

I would use “get_the_terms” to get the terms related to the post instead of “get_terms”, here is a quick suggestion (not tested) $args=array( ‘post_type’=>’tour_package’, ‘post__not_in’ => array(get_the_ID()), ‘posts_per_page’=> 5, ‘caller_get_posts’=>1,//handle sticky post but not in first ); $categories = get_the_terms( get_the_ID(),’tour_category’ ); if ($categories) { $category_ids = array(); foreach($categories as $individual_category){ $category_ids[] = $individual_category->term_id; } … Read more

inserting content of 1 Post to in another with a template hierarchy

Yes, get_page_by_path() will return a post object or array on success, and not the post ID. $faq_post = get_page_by_path( $post_slug, OBJECT, ‘land’ ); // object $faq_post = get_page_by_path( $post_slug, ARRAY_A, ‘land’ ); // array So there is no need to make the custom new WP_Query call, and your code below is good: $faq_post = get_page_by_path( … Read more