1
2
3
4
五
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 |
function print_post_title() { global $post ; $thePostID = $post ->ID; $post_id = get_post( $thePostID ); $title = $post_id ->post_title; $perm = get_permalink( $post_id ); $post_keys = array (); $post_val = array (); $post_keys = get_post_custom_keys( $thePostID ); if (! empty ( $post_keys )) { foreach ( $post_keys as $pkey ) { if ( $pkey == 'external_url' ) { $post_val = get_post_custom_values( $pkey ); } } if ( empty ( $post_val )) { $link = $perm ; } else { $link = $post_val [0]; } } else { $link = $perm ; } echo '<h2><a href="' . $link . '" rel="bookmark" title="' . $title . '">' . $title . '</a></h2>' ; } |
1 |
<?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">' , esc_url( get_permalink() ) ), '</a></h2>' ); ?> |
1 |
<?php print_post_title() ?> |
external_url
在“Name”字段中输入要添加到“ Value”字段中的帖子标题的URL 。
external_url
从下拉菜单中选择自定义字段,然后在值字段中输入外部链接。
我们希望本文能帮助您了解如何从WordPress中的帖子标题链接到外部链接。您可能还希望查看有关如何在WordPress网站上添加外部链接图标的指南。
原文:宁波网站开发设计