admin管理员组文章数量:1122846
I wrote this code:
<?php
$category_border_color = get_field('category_border_color');
$image = get_field('main_image');
$short_description = get_field('short_description');
$permalink = get_permalink('custom_link');
$more_link_text = get_field('more_link_text');
$event_date_from = get_field('event_date_from');
?>
<?php if ($event_date_from) : ?>
<div class="col-md-6 post-item">
<a href="<?php get_the_permalink(); ?>">
<div class="image-wrap" style="background-image: url(<?php echo $image['sizes']['medium']; ?>);"></div>
<div class="category_name" style="border-color: <?php echo $category_border_color ?>"><?php the_title(); ?></div>
</a>
<div class="short_text">
<?php echo $short_description ?> – <span class="more-link"><a href="<?php get_the_permalink(); ?>"><?php echo $more_link_text ?></a></span>
</div>
</div>
<?php endif; ?>
But the href link isn´t working, in sitecode in frontend it shows: <a href="">Mehr Infos!</a>
So for some reason it doesn´t work the connection to the permalink.
Can someone help please?
Best regards,
Caro
I wrote this code:
<?php
$category_border_color = get_field('category_border_color');
$image = get_field('main_image');
$short_description = get_field('short_description');
$permalink = get_permalink('custom_link');
$more_link_text = get_field('more_link_text');
$event_date_from = get_field('event_date_from');
?>
<?php if ($event_date_from) : ?>
<div class="col-md-6 post-item">
<a href="<?php get_the_permalink(); ?>">
<div class="image-wrap" style="background-image: url(<?php echo $image['sizes']['medium']; ?>);"></div>
<div class="category_name" style="border-color: <?php echo $category_border_color ?>"><?php the_title(); ?></div>
</a>
<div class="short_text">
<?php echo $short_description ?> – <span class="more-link"><a href="<?php get_the_permalink(); ?>"><?php echo $more_link_text ?></a></span>
</div>
</div>
<?php endif; ?>
But the href link isn´t working, in sitecode in frontend it shows: <a href="">Mehr Infos!</a>
So for some reason it doesn´t work the connection to the permalink.
Can someone help please?
Best regards,
Caro
1 Answer
Reset to default 1get_the_permalink() returns the permalink as a string and doesn't echo it. You either need to echo this yourself
<?php echo get_the_permalink(); ?>
as you've got in some of your other <?php
tags, or you can use the helper function the_permalink() which does echo
<?php the_permalink(); ?>
the same pattern as you've used for the_title().
Note that these aren't completely equivalent: the_permalink() applies an extra filter, so it's probably worth using that one in case some other code you've got does use the filter.
本文标签: phpWordpress per ACFpermalink is not working
版权声明:本文标题:php - Wordpress per ACF - permalink is not working 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736297963a1930125.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论