Luca Koch
Luca Koch

Reputation: 1

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

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?

Upvotes: -1

Views: 78

Answers (2)

user3136884
user3136884

Reputation: 161

You can use the_field function.

the_field("your_custom_field");

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

Upvotes: 1

Dinesh
Dinesh

Reputation: 4110

To display ACF in your theme use the_field()

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

Upvotes: 1

Related Questions