最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Getting a Post ID to show its content in a Popup

programmeradmin4浏览0评论

Im using a function to add a readmmore at the end of excerpts I dont want to link to a single-w.e.php

Because I want to popup the page and the only way ive found to do this is to add the page to the popup with the shorcode api

Now my issue is How Do I Display just that Custom Post type Items Content When clicking the readmore

function new_excerpt_more( $excerpt ) {
    return $excerpt. '... <a class="more-link popmake-content-popup" href="'. get_permalink( get_the_ID() ) . '">' . __('READ MORE') . ' </a>';
}
add_filter( 'get_the_excerpt', 'new_excerpt_more' );
<?php
get_header();
?>
 <?php

     $review = new WP_Query(array('post_type' => 'review', 'posts_per_page'=>'1', 'order_by' => 'post_date', 'order' => 'ASC'));
     if($review->have_posts()) : while ($review->have_posts()) : $review->the_post();

     
?>
<div class="container mg-top-m service-content">
    <?php the_content();?>
    
</div>

<?php endwhile; endif; wp_reset_postdata(); ?>
<?php
get_footer();
?>


So I have a review (I Click readmore) -> Popup shows up -> Shows That reviews full content I know you can fetch a single post using

$mypost = get_post(244);
echo apply_filters('the_content',$mypost->post_content);

something like that but how do I get it to populate the ID dynamically

Clarifying:

I have. Custom post type called - Reviews

I have archive page where i Show all these reviews, Now Because of the design some of these are to long to display all the way So i Shorten them to a excerpt then add a readmore to the end of that with the function new_excerpt_more Now usually

That Read more would go to Single-review.php But I dont want that I want to display it using a popup

Im using A PLugin called Popup Maker which uses a Block editor to show popups then adding a class to a link activates the popup thus the popmake-content-popup Class name on my links

But I dont know how to display the content of the Link(Post) the user clicks in that popup

I suspect I would have to pass the ID i get from the Function new_excerpt_more to the Popup "Page" Then read it there into a Query to get the data and show the content But I dont know how to do that either

发布评论

评论列表(0)

  1. 暂无评论