I don’t think that I use hard coded parts. But code is below. The main problem seems to be that WP somehow does not recognize that the CPT has posts.
<main id="main" class="site-main">
<?php
$currlang = apply_filters( 'wpml_current_language', NULL );
if ( $currlang === 'en' ){
echo do_shortcode( '[searchandfilter id="802"]' ) . '<div id="filter-toggle-wrap"><a id="filter-toggle-button" href="#">Filters <i class="fas fa-angle-down"></i></a></div>';
} else {
echo do_shortcode( '[searchandfilter id="79"]' ) . '<div id="filter-toggle-wrap"><a id="filter-toggle-button" href="#">Sz?r?k <i class="fas fa-angle-down"></i></a></div>'; } ?>
<?php if ( have_posts() ) : // WE DON'T HAVE POSTS? ?>
<div class="sza_wrapper">
<?php if ( function_exists( 'wp_pagenavi' ) )
wp_pagenavi();
else
get_template_part( 'includes/navigation', 'index' ); ?>
<?php
while ( have_posts() ) : the_post();
$tags = get_the_terms( get_the_ID(), 'post_tag' );
$output_tags ='';
foreach ( $tags as $tag){
if ( $currlang === 'en' ){
$output_tags .= '<a class="sza_tag" href="/en/resources/?_sft_post_tag=' . $tag->slug . '">' . $tag->name . '</a>';
} else {
$output_tags .= '<a class="sza_tag" href="/hu/szakmai-anyagok/?_sft_post_tag=' . $tag->slug . '">' . $tag->name . '</a>';
}
}
$orig_ID = apply_filters( 'wpml_object_id', $post->ID, 'szakmai_anyagok', FALSE, 'hu' );
global $wpdb;
$results = $wpdb->get_results("SELECT m2.meta_value FROM ral_postmeta m1 JOIN ral_postmeta m2 ON m2.post_id = m1.meta_value and m2.meta_key = '_wp_attached_file' WHERE m1.post_id = " . (int)$orig_ID . " and m1.meta_key = 'dfile'"); // Hack to get the dfile field value
$file_link = '/wp-content/uploads/' . $results[0]->meta_value;
?>
<article class="sza_loop-item">
<div class="sza_icon">
<a href="<?php echo $file_link; ?>" target="_blank"><img src="/wp-content/uploads/2020/03/sza_pdf.svg"></a>
</div>
<div class="sza_content">
<?php if ( $post->authors ) {
echo __( 'Authors: ', 'rogerstheme' ) . get_post_meta( get_the_ID(), 'authors', true ) . '<br>';
} ?>
<span class="sza_post-title"><?php echo '<a href="' . $file_link . '"'; ?> target="_blank"><?php the_title() ?></a></span><span class="sza_lang-icon"><img height="16px" width="16px" src=<?php echo '"/wp-content/themes/rogerstheme/flags/' . esc_html( get_post_meta( get_the_ID(), 'language', true ) ) . '.svg"'; ?> alt=""></span><br><?php echo get_the_date( 'Y' ); ?> |<?php echo $output_tags; ?>
</div>
</article>
<?php endwhile;
if ( function_exists( 'wp_pagenavi' ) )
wp_pagenavi();
else
get_template_part( 'includes/navigation', 'index' ); ?>
</div><!-- .sza_wrapper -->
<?php else : ?>
<?php echo '<div class="sza_wrapper"><p class="sza_error">' . __( 'There are no documents that match your filter criteria.', 'rogerstheme' ) . '</p></div>'; ?>
<?php endif; ?>
</main><!-- #main -->
Any insights?
Best regards
Champdor