【发布时间】:2016-03-24 20:01:23
【问题描述】:
我是堆栈溢出的新手。 首先感谢所有社区接受我的订阅。 我正在构建的网站有一点问题:
http://gianfabiopezzolla.com/centocelleonline.it
在首页我有一个 Mansory 用于显示特色图片和标题的楦帖。
我想为每个特色图片设置一个自定义链接到不同的页面(例如,第一个特色图片 -> 联系页面)。
我已经尝试使用下面的代码,但似乎不起作用:
<article id="post-<?php the_ID(the_id_of_post); ?>" <?php post_class(); ?>>
<div class="item-sizer">
<?php if ( has_post_thumbnail() && ( get_theme_mod( 'index_feat_image' ) != 1 ) ) : ?>
<div class="entry-thumb">
<a href="<?php the_permalink(the_id_of_page); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('oria-small-thumb'); ?></a>
</div>
<?php endif; ?>
<header class="entry-header blog-entry-header">
<?php the_title( sprintf( '<h1 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink(the_id_of_page) ) ), '</a></h1>' ); ?>
</header><!-- .entry-header -->
</div>
</article><!-- #post-## -->
有人可以帮帮我吗?
【问题讨论】:
-
嗨,试试
get_permalink($Id)或get_page_link($id)instedthe_permalink() -
您好,感谢您的建议,但似乎不起作用。如果我替换 get_page_link($id) 或 get_permalink($id) 链接返回主页而不是我要显示的页面。
-
参数
the_id_of_page应该是你要展示的页面的ID,而不是首页的ID。 -
是的,你是对的。事实上,在括号内我已经写了页面 id(在我的例子中是“2”),但代码仍然无法正常工作。链接默认返回首页。但是,我会为每个显示的特色图像设置一个不同的自定义链接,该链接会出现在不同的页面上。我希望我解释得很好。再次感谢