How can I create Custom Fields in a Custom Post Type?

82 Views Asked by At

I got a Custom Post Type Page, this is the code I use:

<?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();
?>

Does anybody knows how I can add an AFC there?

2

There are 2 best solutions below

4
Dinesh On

To display ACF in your theme use the_field()

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

You can use the_field function.

the_field("your_custom_field");

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