在我的循环中,我试图有一个链接显示,但它不会我不知道为什么
代码如下:
<?php the_title(\'<h2 class="wow"><a href="<?php the_permalink(); ?>"\', \'</a></h2>\'); ?>
我知道这可能是因为\'\'
引用而不是""
, 但是,我如何仅使用PHP而不是包装来实现这一常规功能呢the_title();
在a标记中。在我的循环中,我试图有一个链接显示,但它不会我不知道为什么
代码如下:
<?php the_title(\'<h2 class="wow"><a href="<?php the_permalink(); ?>"\', \'</a></h2>\'); ?>
我知道这可能是因为\'\'
引用而不是""
, 但是,我如何仅使用PHP而不是包装来实现这一常规功能呢the_title();
在a标记中。因为the_title()
需要的字符串$before
和$after
args,您需要在字符串串联中使用permalink的字符串版本;
<?php the_title(\'<h2 class="wow"><a href="\'.get_permalink().\'">\', \'</a></h2>\'); ?>
>
.https://developer.wordpress.org/reference/functions/get_permalink/
不能嵌套这些函数。将代码更改为
<h2 class="wow"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
晚了23秒。
我认为问题是你有一个双重的开放/关闭声明。
在没有看到代码的情况下,我建议您将代码行编辑为
<h2 class="wow"><a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></h2>
我正在构建一个以“theretailer”为基础的网站,但我不知道在哪里放置代码来让循环为自定义帖子类型“News”工作?主题使用的循环是 //$wp_query->query(\'posts_per_page=1\'.\'&paged=\'.$paged); $wp_query->query(\'posts_per_page=\'.get_option(\'posts_per_page\').\'&