- This topic has 21 replies, 3 voices, and was last updated 5 years, 1 month ago by
Tom.
-
AuthorPosts
-
September 23, 2020 at 10:12 am #1455798
Tom
Lead DeveloperLead DeveloperHard to tell without seeing the page. Does each featured image on the page have a
featured-image page-header-imageclass?September 23, 2020 at 11:17 am #1455877Eroan
Yes, that’s it.
I cannot succeed in making posts render as in categories whatever I try.
September 23, 2020 at 3:36 pm #1456127Tom
Lead DeveloperLead DeveloperPerhaps we need to take a step back – can you explain the desired end result? I assume you’re trying to build a home page that has a mix of static content and posts? What about you doing with categories, exactly?
September 24, 2020 at 12:03 am #1456416Eroan
The idea is to display a page using front-page.php template.
In the first part, I display the page text in the classic way.
Then, under it I display the last posts links with the GeneratePress template in columns (same as categories, taxonomies…).
Not more than that. But so hard to achieve ^^
September 24, 2020 at 10:26 am #1457381Tom
Lead DeveloperLead DeveloperDisplaying static content and post loops together on one page in WordPress is definitely difficult.
How much static content are you wanting to add above the posts? How are you building that content? Trying to think if there’s a better way to do this.
September 24, 2020 at 11:06 am #1457420Eroan
I have one line of text.
The whole front-page.php template looks like this :
<?php /** * The template for displaying all pages. * * This is the template that displays all pages by default. * Please note that this is the WordPress construct of pages * and that other 'pages' on your WordPress site will use a * different template. * * @package GeneratePress */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } get_header(); ?> <div id="primary" <?php generate_do_element_classes( 'content' ); ?>> <main id="main" <?php generate_do_element_classes( 'main' ); ?>> <?php /** * generate_before_main_content hook. * * @since 0.1 */ do_action( 'generate_before_main_content' ); while ( have_posts() ) : the_post(); echo '<header class="page-header"><h1>Bienvenue sur '.get_bloginfo('name').'</h1>'; the_content(); echo '</header>'; endwhile; ?> <div class="page-header"><h2 class="actus">News</h2></div> <?php // The Query $query_options = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 6, 'order' => 'DESC', 'orderby' => 'date' ); $the_query = new WP_Query( $query_options ); // The Loop if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query -> the_post(); get_template_part('content'); endwhile; ?> <?php endif; ?> <?php /** * generate_after_main_content hook. * * @since 0.1 */ do_action( 'generate_after_main_content' ); ?> </main><!-- #main --> </div><!-- #primary --> <?php /** * generate_after_primary_content_area hook. * * @since 2.0 */ do_action( 'generate_after_primary_content_area' ); generate_construct_sidebars(); ?> <?php get_footer();I tried wp_reset_postdata() and wp_reset_query() after main content loop but it didn’t help.
September 24, 2020 at 5:18 pm #1457761Tom
Lead DeveloperLead DeveloperIn that case, what about using the standard blog template as your front page, and then hooking a Block Element with your text onto the front page using Block Elements?: https://docs.generatepress.com/article/block-element-overview/
This way you’re using the core GP blog template without forcing it to do something it wasn’t built to do, and you can add whatever text you want up above the posts.
Let me know 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.