Wordpress-每个特色图片都有不同的自定义链接


Wordpress - different custom link per each featured image

我是堆栈溢出的新手。首先感谢所有社区接受我的订阅。我有一个小问题,我正在建设的网站:

http://gianfabiopezzolla.com/centocelleonline.it

在首页,我有一个Mansory for last的帖子,显示了受伤的图像和标题。

我想为每个特色图片设置一个到不同页面的自定义链接(例如,第一个特色图片->联系页面)。

我尝试过下面的代码,但似乎不起作用:

<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_permink,它会进行

$link = get_the_permalink($page_id); 
<div class="entry-thumb">
<a href="<?php echo $link; ?>"> title="<?php the_title(); ?>"><?php the_post_thumbnail('oria-small-thumb'); ?></a>        
</div>

其中$page_id是所需页面的id这是因为the_permalink();直接回声而

get_permink();

将返回一个必须手动回显的值。这就是为什么你的链接没有打印出来的原因。

希望有帮助,请尝试一下。