• Hi

    I have installed for a client this theme and it works well.
    Only thing is: in the frontpage section News there are no posts shown.

    When i put the “normal code” for showing recent post in the frontpage-news.php, the posts are shown (but without the right class).

    What do i make wrong?

    Thank you Dani

    https://defcon5.ch

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter dee-net websolutions

    (@omegalita)

    For the moment my solution ist to put another code in there on lin 34:

    <?php
    $recent_posts_query = new WP_Query(array(‘post_type’ => ‘post’, ‘posts_per_page’ => 5));

    while ($recent_posts_query->have_posts())
    {
    $recent_posts_query->the_post();
    ?><div id=”post-<?php the_ID(); ?>” <?php post_class(‘blog_small_wrap’); ?>>
    <h3>“><?php the_title(); ?></h3>
    <p>by <?php the_author(); ?></p>
    <?php
    global $more;
    $more = 0;
    the_content();
    ?>
    </div>
    <?php
    }
    ?>

    Having the same problem with News section. No post are shown.
    Tried and re-tried all instructions and configurations with no success…

    @omegalita
    I was now trying your solution code, but I didn’t find the “frontpage-news.php” file in theme editor. Seems I don’t have it… Is this the file?

    Thanks!

    Thread Starter dee-net websolutions

    (@omegalita)

    Yes. It’s under partials –> companion.

    Here is the complete code from my frontpage-news.php

    <?php if ((nimbus_get_option(‘fp-news-toggle’) == ‘1’) || (nimbus_get_option(‘fp-news-toggle’) == ”)) { ?>
    <?php if ( get_option( ‘show_on_front’ ) == ‘page’ ) { ?>
    <section id=”<?php if (nimbus_get_option(‘fp-news-slug’)==”) {echo “news”;} else {echo esc_attr(nimbus_get_option(‘fp-news-slug’));} ?>” class=”frontpage-news”>
    <div class=”container”>
    <div class=”row”>
    <div class=”col-md-12″>
    <?php if (nimbus_get_option(‘fp-news-title’) != ”) { ?>
    <div class=”news-title h1″><?php echo esc_html(nimbus_get_option(‘fp-news-title’)); ?></div>
    <?php } ?>
    <?php if (nimbus_get_option(‘fp-news-sub-title’) != ”) { ?>
    <div class=”news-sub-title h4″><?php echo esc_html(nimbus_get_option(‘fp-news-sub-title’)); ?></div>
    <?php } ?>
    <?php
    $posts_per_page = 4;
    $posts_per_row = ceil($posts_per_page / 2);
    $i = 1;
    $custom_args = array(‘posts_per_page’ => $posts_per_page);
    $custom_query = new WP_Query( $custom_args );
    if ( $custom_query->have_posts() ) {
    ?>
    <div class=”row”>
    <div class=”col-sm-6 left_blog_column”>
    <?php
    while ( $custom_query->have_posts() ) {
    $custom_query->the_post();
    if ($i == ($posts_per_row + 1)) {
    echo “</div><div class=’col-sm-6 right_blog_column’>”;
    }
    get_template_part( ‘partials/frontpage’,’news-layout’);
    $i++;
    }
    ?>
    </div>
    </div><?php
    $recent_posts_query = new WP_Query(array(‘post_type’ => ‘post’, ‘posts_per_page’ => 5));

    while ($recent_posts_query->have_posts())
    {
    $recent_posts_query->the_post();
    ?><div id=”post-<?php the_ID(); ?>” <?php post_class(‘blog_small_wrap’); ?>>
    <h3>“><?php the_title(); ?></h3>
    <p><?php _e(‘by ‘, ‘venture-lite’ ); the_author_posts_link(); _e(‘ on ‘, ‘venture-lite’ ); the_time(get_option(‘date_format’)); ?></p>
    <?php
    global $more;
    $more = 0;
    the_content();
    ?>
    </div>
    <?php
    }
    ?>
    <br/>
    <br/>
    <center><div class=”action2-link-button” ><h2>» All News</h2></div></center>
    <?php
    } else { ?>
    <p><?php _e(‘No posts found.’, ‘venture-lite’ ); ?></p>
    <?php }
    wp_reset_postdata();
    ?>
    </div>
    </div>
    </div>
    </section>
    <?php } else { ?>
    <section id=”<?php if (nimbus_get_option(‘fp-news-slug’)==”) {echo “news”;} else {echo esc_attr(nimbus_get_option(‘fp-news-slug’));} ?>” class=”frontpage-news”>
    <div class=”container”>
    <div class=”row”>
    <div class=”col-md-12″>
    <?php if (nimbus_get_option(‘fp-news-title’) != ”) { ?>
    <div class=”news-title h1″><?php echo esc_html(nimbus_get_option(‘fp-news-title’)); ?></div>
    <?php } else { ?>
    <div class=”news-title h1″><?php _e(‘Latest Articles’, ‘venture-lite’ ); ?></div>
    <?php } ?>
    <?php if (nimbus_get_option(‘fp-news-sub-title’) != ”) { ?>
    <div class=”news-sub-title h4″><?php echo esc_html(nimbus_get_option(‘fp-news-sub-title’)); ?></div>
    <?php } else { ?>
    <div class=”news-sub-title h4″><?php _e(‘Get up to date with the latest news from our newsroom.’, ‘venture-lite’ ); ?></div>
    <?php } ?>
    <?php
    $posts_per_page = get_option( ‘posts_per_page’ );
    $post_count = $wp_query->post_count;
    if ($posts_per_page > $post_count) {
    $posts_per_page = $post_count;
    }
    $posts_per_row = ceil($posts_per_page / 2);
    $i = 1;
    if (have_posts()) {
    ?>
    <div class=”row”>
    <div class=”col-sm-6 left_blog_column”>
    <?php
    while (have_posts()) {
    the_post();
    if ($i == ($posts_per_row + 1)) {
    echo “</div><div class=’col-sm-6 right_blog_column’>”;
    }
    get_template_part( ‘partials/frontpage’,’news-layout’);
    $i++;
    }
    ?>
    </div>
    </div>
    <div class=”feed_pagination row”>
    <div class=”col-md-6″>
    <?php next_posts_link(__(‘« Older Entries’, ‘venture-lite’)) ?>
    </div>
    <div class=”col-md-6 text-right”>
    <?php previous_posts_link(__(‘Newer Entries »’, ‘venture-lite’)) ?>
    </div>
    </div>
    <?php
    } else { ?>
    <p><?php _e(‘No posts found.’, ‘venture-lite’); ?></p>
    <?php }
    ?>
    </div>
    </div>
    </div>
    </section>
    <?php } ?>
    <?php } else if (nimbus_get_option(‘fp-news-toggle’) == ‘2’) {
    // Don’t do anything
    } ?>

    You can look at my site (had the wrong adress above): https://defcon3.ch

    Thanks @omegalita!
    Found it now!!
    Great code!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘No post shown under News on Frontpage’ is closed to new replies.