admin管理员组文章数量:1333177
I am using a Gutenberg's 'Latest Posts' block on my front page. Featured image display and grid layout are enabled in the block settings.
By default, only the post title is linked to the actual post. However, users are tempted to click on the post image or even somwhere on the excerpt in order to get to the respective article.
So, how can I apply a filter to the block output, which adds a link to the whole list item rather than just the post title? I'm looking for something like this:
function my_post_item( $post ){
// Fetch the link
$post_url = get_permalink( $post );
// Wrap anchor tag around list item's content
$list_item = '<li><a href="' . $post_url . '">';
$list_item .= $default_latest_post_item_content;
$list_item .= '</a></li>';
return $list_item;
}
add_filter( 'gutenberg_latest_post_item', 'my_post_item' );
Any ideas?
本文标签: filtersHow to link the whole list item in Gutenberg39s latest posts block
版权声明:本文标题:filters - How to link the whole list item in Gutenberg's latest posts block? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742275463a2445110.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论