我已经创建了一个很好的主页,其中的帖子被组织成两个专栏。仅在某种程度上,在创建这个页面时,我必须删除实际代码,该代码告诉post链接到相应的post。所以现在,所有的帖子都出现在主页上,但是没有办法去张贴--帖子预览和实际的帖子没有链接。
我首先环顾四周,认为这可能是一个常见的问题,但我还没有找到答案。如果有人能帮忙,我会非常感激的!
这个网站在内部公司/城堡。这是一个二十二个儿童主题。
下面是我在content.php中的代码
<?php
/**
* The default template for displaying content. Used for both single and index/archive/search.
*
* @package WordPress
* @subpackage Twenty_Twelve
* @since Twenty Twelve 1.0
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
<div class="featured-post">
<?php _e( 'Featured post', 'twentytwelve' ); ?>
</div>
<?php endif; ?>
<header class="entry-header">
<?php the_post_thumbnail(); ?>
<?php if ( is_single() ) : ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php else : ?>
<h1 class="entry-title">
</a> <h1 class="entry-title"><?php the_title(); ?><br><small class="time"><?php the_date('F j, Y'); ?></small></h1>
</h1>
<?php endif; // is_single() ?>
</header><!-- .entry-header -->
<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
<?php if ( is_singular() && get_the_author_meta( 'description' ) && is_multi_author() ) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?>
<div class="author-info">
<div class="author-avatar">
<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentytwelve_author_bio_avatar_size', 68 ) ); ?>
</div><!-- .author-avatar -->
<div class="author-description">
<h2><?php printf( __( 'About %s', 'twentytwelve' ), get_the_author() ); ?></h2>
<p><?php the_author_meta( 'description' ); ?></p>
<div class="author-link">
<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
<?php printf( __( 'View all posts by %s <span class="meta-nav">→</span>', 'twentytwelve' ), get_the_author() ); ?>
</a>
</div><!-- .author-link -->
</div><!-- .author-description -->
</div><!-- .author-info -->
<?php endif; ?>
</article><!-- #post -->发布于 2013-07-29 15:00:54
如果希望功能图像是可单击的,请替换:
<?php the_post_thumbnail(); ?>使用
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php <?php the_post_thumbnail(); ?></a>标题和日期改为:
<h1 class="entry-title"><?php the_title(); ?><br><small class="time"><?php the_date('F j, Y'); ?></small></h1>打中这个:
<a href="<?php the_permalink(); ?>" rel="bookmark"><h1 class="entry-title"><?php the_title(); ?><br><small class="time"><?php the_date('F j, Y'); ?></small></h1></a>删除行开头的</a>是无用的。
发布于 2013-07-29 14:30:41
我不知道在没有看到您的代码的情况下,这是100%的答案,但是在TwentyTwelve链接至少在一个地方中,如下所示:
<h1 class="entry-title">
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
</h1>关键功能是the_permalink(),其中echos的链接URL。其余的是标准HTML。
编辑:
现在您已经发布了您的代码,我可以看到发生了什么。您只是没有锚标签(虽然您有虚假的</a>)围绕您的标题。
<?php if ( is_single() ) : ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php else : ?>
<h1 class="entry-title">
</a> <h1 class="entry-title"><?php the_title(); ?><br><small class="time"><?php the_date('F j, Y'); ?></small></h1>
</h1>
<?php endif; // is_single() ?>你需要的是:
if ( is_single() ) { ?>
<h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
} else { ?>
<h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a><br><small class="time"><?php the_date('F j, Y'); ?></small></h1><?php
} // is_single() ?>唯一重要的改变是在<h1行上,但是您有嵌套的<h1>,所以我更正了它,并将替代语法-- if (...) : endif;--转换为方括号,因为我发现这种替代语法不可能被读取,而且很容易出错--可能是因为它似乎鼓励了缩进的代码,但是如果您愿意的话,您可以保持很难读到容易出错的语法。:)
https://wordpress.stackexchange.com/questions/108215
复制相似问题