任何人都知道如何在高级自定义字段中将静态标签替换为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)。
提前感谢您的任何指导。
答案 0 :(得分:0)
这取决于您如何设置字段。如果选择“文件阵列”返回值,则可以使用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;
?>