I have a website with the custom post type sammenligne, along with some custom fields made using Advanced Custom Fields (ACF). I have modified an archive site (archive-sammenligne.php) which displays the data the way I want it, however when I try to extract the data using a WP query on a page, I get no output. If I use the standard WordPress titles, I get output. I assume there is something with the link to the custom fields; but they work on the archive page.
I need to run the query on a WordPress page, not an archive, as I would like to have post content above the loop. The code below is saved as a page template.
I run Genesis Metro Pro and WordPress.
Thanks in advance.
<?php
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
function sk_display_custom_fields() {
/*Custom fields/*
$navn = get_field( 'navn' );
$type = get_field( 'type' );
$fordeler = get_field( 'fordeler' );
/*Wordpress loop*/
$arg = array(
'post_type' => 'sammenligne',
'posts_per_page' => 10,
'order' => 'DESC',
'post_status' => 'publish'
);
$query = new WP_Query($arg);
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
echo '<h2>' . $navn . '</h2>';
endwhile;
endif;
wp_reset_query();
}
add_action( 'genesis_entry_header', 'sk_display_custom_fields' );
genesis();