簡體   English   中英

如何在自定義帖子類型中創建自定義字段?

[英]How can I create Custom Fields in a Custom Post Type?

我有一個自定義帖子類型頁面,這是我使用的代碼:

<?php
 get_header();
 get_sidebar();
 the_meta();
?>

<ul class="event">
  <?php $args = array( 'post_type' => 'event-netzwerk', 'posts_per_page' => 30, 'orderby' => 'rand' );
  $loop = new WP_Query( $args );
  while ( $loop->have_posts() ) : $loop->the_post();
    echo '<li>';
    the_title('<h3>', '</h3>');
    the_content();
    echo '</li>';
  endwhile; ?>
</ul> 


<?php

 get_footer();
?>

有人知道如何在其中添加AFC嗎?

要在主題中顯示ACF,請使用the_field()

<h1><?php the_field('custom_title'); ?></h1>

您可以使用the_field函數。

the_field("your_custom_field");

https://wordpress.org/plugins/advanced-custom-fields/screenshots/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM