在我的博客主页上,作者和日期元(作者姓名和日期)采用链接形式。我想只在文字中显示它们。当我尝试删除链接时,文本也会被删除。请帮我删除链接。 display.php的代码是
if (!function_exists('swift_meta_generator')):
/**
* Generate post meta.
*
* Prints the post meta information based on the options set in theme options page.
* Called around post titles on home page and single pages.
*
* @param array $meta post meta order set in options page.
* @param string $classes html classes for the post meta wrapper.
*
*/
function swift_meta_generator($meta, $classes)
{
$data = '<div class="entry-meta ' . $classes . '">';
$size = count($meta);
for ($i = 0; $i < $size; $i++) {
switch ($meta[$i]) {
case 'text' :
if ((current_time('timestamp', 1) - get_the_date('U')) < 86400)
$meta[$i + 1] = preg_replace('(on)', '', $meta[$i + 1]);
$data .= $meta[$i + 1];
$i++;
break;
case 'author' :
$data .= '<span class="vcard author fa-user"><a class="" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '" rel="author"><span class="fn">' . esc_attr(get_the_author()) . '</span></a></span> ';
break;
case 'author_avatar' :
$data .= get_avatar( get_the_author_meta('ID'), 16 );
$data .= ' <span class="vcard author"><a class="" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '" rel="author"><span class="fn">' . esc_attr(get_the_author()) . '</span></a></span> ';
break;
case 'date' :
if ((current_time('timestamp', 1) - get_the_date('U')) < 86400)
$date = human_time_diff(get_the_time('U'), current_time('timestamp')) . ' '.__('ago','swift');
else
$date = get_the_date();
$data .= '<span class="date updated fa-clock-o"><a class="" href="' . esc_url(get_permalink()) . '" title="' . esc_attr(get_the_time()) . '" rel="bookmark">';
$data .= '<time class="entry-date" datetime="' . esc_attr(get_the_date('c')) . '">' . esc_html($date) . '</time></a></span> ';
break;
case 'updated_on' :
if ((current_time('timestamp', 1) - get_the_modified_date('U')) < 86400)
$date = human_time_diff(get_post_modified_time('U'), current_time('timestamp')) . ' '.__('ago','swift');
else
$date = get_the_modified_date();
$data .= '<span class="date updated fa-clock-o"><a href="' . esc_url(get_permalink()) . '" title="' . esc_attr(get_post_modified_time()) . '" rel="bookmark">';
$data .= '<time class="entry-date" datetime="' . esc_attr(get_the_modified_date('c')) . '">' . esc_html($date) . '</time></a></span> ';
答案 0 :(得分:-2)
将此代码替换为您的代码
if (!function_exists('swift_meta_generator')):
/**
* Generate post meta.
*
* Prints the post meta information based on the options set in theme options page.
* Called around post titles on home page and single pages.
*
* @param array $meta post meta order set in options page.
* @param string $classes html classes for the post meta wrapper.
*
*/
function swift_meta_generator($meta, $classes)
{
$data = '<div class="entry-meta ' . $classes . '">';
$size = count($meta);
for ($i = 0; $i < $size; $i++) {
switch ($meta[$i]) {
case 'text' :
if ((current_time('timestamp', 1) - get_the_date('U')) < 86400)
$meta[$i + 1] = preg_replace('(on)', '', $meta[$i + 1]);
$data .= $meta[$i + 1];
$i++;
break;
case 'author' :
$data .= '<span class="vcard author fa-user"><span class="fn">' . esc_attr(get_the_author()) . '</span></span> ';
break;
case 'author_avatar' :
$data .= get_avatar( get_the_author_meta('ID'), 16 );
$data .= ' <span class="vcard author"><a class="" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '" rel="author"><span class="fn">' . esc_attr(get_the_author()) . '</span></a></span> ';
break;
case 'date' :
if ((current_time('timestamp', 1) - get_the_date('U')) < 86400)
$date = human_time_diff(get_the_time('U'), current_time('timestamp')) . ' '.__('ago','swift');
else
$date = get_the_date();
$data .= '<span class="date updated fa-clock-o">' . esc_attr(get_the_time()) . '</span>';
$data .= '<time class="entry-date" datetime="' . esc_attr(get_the_date('c')) . '">' . esc_html($date) . '</time></span> ';
break;
case 'updated_on' :
if ((current_time('timestamp', 1) - get_the_modified_date('U')) < 86400)
$date = human_time_diff(get_post_modified_time('U'), current_time('timestamp')) . ' '.__('ago','swift');
else
$date = get_the_modified_date();
$data .= '<span class="date updated fa-clock-o"><a href="' . esc_url(get_permalink()) . '" title="' . esc_attr(get_post_modified_time()) . '" rel="bookmark">';
$data .= '<time class="entry-date" datetime="' . esc_attr(get_the_modified_date('c')) . '">' . esc_html($date) . '</time></a></span> ';
此代码删除了您作者和日期的链接....希望对您有用。