有人知道如何在高级自定义字段中将静态标签替换为PDF附件的标题吗?
<?php if( get_field('other_reports') ): ?>
<p><strong><a href="<?php the_field('other_reports'); ?>">Disclosure Reports</a></strong></p>
<?php endif; ?>
我想用PDF附件的产权财产(例如111 Main Street)代替"披露报告"。
提前感谢您的指导。
这取决于如何设置字段。如果选择"File Array"返回值,则可以使用get_field()
获取PDF URL之外的详细信息。(假设您选择"文件"作为字段类型。)
以下是名称为pdf_stuff
:的字段的示例
<?php
while( have_posts() ) : the_post();
$pdf = get_field( 'pdf_stuff' );
$pdf_title = $pdf[ 'title' ]; // eg, "Balance_Sheet"
$pdf_filename = $pdf[ 'filename' ]; // eg, "Balance_Sheet.pdf"
$pdf_url = $pdf[ 'url' ]; // URL to file
endwhile;
?>
您可以通过将阵列打印到屏幕上来查看可用内容:
<?php
while( have_posts() ) : the_post();
$pdf = get_field( 'pdf_stuff' );
echo '<pre>';
print_r( $pdf );
echo '</pre>';
endwhile;
?>