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

plugins - How to get the custom page get_permalink?

programmeradmin1浏览0评论

I have create two a custom page called page-blogs.php and page-blog-content.php.

In the page-blogs.php I am displaying my all the custom blogs post and page-blog-content.php will display the blog content.

I am usig below code to display the my all the blog post which is working and i am able to access my blog using this url / but my issue is with get_permalink($tid). When I am clickig on the my post the it's not redirecting on my blog-content.php page. It is rediecting on wordpress default post(I think single.php) and my URL is shwoing /

$args = array(  
'taxonomy' => 'blogs_cat',
'post_type' => 'blog',
'post_status' => 'publish',
'posts_per_page' => 30,
'meta_key' => 'latestblog',
'meta_value' => 1,
'order'      => 'DESC' 
);  
$featured = new WP_Query($args);
$fdata ='';
$fddata = '<div class="main-Blog"><ul>';
while ( $featured->have_posts() ) : $featured->the_post(); 
$tid = $featured->ID;


$fddata.=  '<li> <a href="'.get_permalink($tid).'">
<div class="main-blogBoxwrapper">
<img src="'.get_the_post_thumbnail_url($tid).'">
<div class="blogCatname">
<h6><span>'.$catname.'</span></h6>
<h4>'.wp_trim_words(get_the_title($tid), 14, '...').'</h4>
<p>'.wp_trim_words($get_the_content($tid), 20, '...').'</p>
</div>
</div>
</a></li>';
endwhile;
$fddata.='</ul></div>';

echo $fddata;

I know wordpress also providing the single post and content.php(template-part) but i am using this for my category and subcategory. I have different design for category and for blog post.

发布评论

评论列表(0)

  1. 暂无评论