【发布时间】:2017-07-29 17:11:24
【问题描述】:
我想将 svg 箭头图像作为 WordPress 后分页循环的 prev_text 和 next_text 传递。目前,我有硬编码的 localhost url。我想设置它,所以这些使用 get_template_directory_uri() 或类似的。
当前代码:
<?php
$big = 999999999;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'next_text' => ('<img class="next-arrow" src="http://localhost:8888/mockingbird/wp-content/themes/mockingbird/images/arrow.svg" alt="next posts"/>'),
'prev_text' => ('<img class="prev-arrow" src="http://localhost:8888/mockingbird/wp-content/themes/mockingbird/images/arrow.svg" alt="previous posts"/>'),
'total' => $query->max_num_pages
) );
?>
我想要的伪代码如下:
'next_text' => ('<img class="next-arrow" src="<?php echo get_template_directory_uri(); ?>/images/arrow.svg" alt="next posts"/>'),
'prev_text' => ('<img class="prev-arrow" src="<?php echo get_template_directory_uri(); ?>/images/arrow.svg" alt="previous posts"/>'),
所以我的问题是,是否可以在数组的字符串中传入 php?
如果不是,如何在我的网址中不进行硬编码的情况下实现这一目标?
【问题讨论】:
标签: php wordpress svg pagination