• Hello,

    I’m working in local environment.
    WP 5.9.2 / GeneratePress 3.1.3 / Generate Blocks 7.2.0
    I’m using a child theme.

    I created posts in category named “portfolio”.
    I added specfic archive files for this category in order to display only post content of each post in the archive page of category “portfolio”.
    Other archive pages (as blog) are displaying posts as configured in customizer using standard GP files (featured image + title + excerpt + terms…).

    Here are 2 screenshots :
    1) What I have done https://ibb.co/vJYdxbR
    2) What I want https://ibb.co/vVQg4tQ

    Details
    1) This page is archive page of posts category “portfolio” and displays posts from this category
    I create following files in child theme :
    – file category-portfolio.php (copy of archive.php) where I changed
    generate_do_template_part( ‘archive’ );
    to get_template_part( ‘content’, ‘portfolio’ );

    – file content-portfolio.php (copy of content-single.php) where I removed header to display only post content

    As you can see in first commented screenshot, the first post is displayed as expected (GB css for this post has been automatically printed in header).
    The second post is not displyed has expected (see screenshot 2 to understand what I want). GB css of this post hasn’t be printed in header.

    2) This is a test page to show you what I’m looking for. I copied the contents from the 2 different posts.

    Do you nedd more info ?

    Thank you for your help.
    Best regards.
    Joffrey

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Joffrey Nicoloff

    (@agent3w)

    I found an ugly way to achieve what I want : inside the loop I’m doing this before printing each post content : GenerateBlocks_Enqueue_CSS::get_instance()->print_inline_css();

    BUT this is not a good solution because it is generating a lot of inline css inside several <style id="generateblocks-css">...</style> (with same id) in the body.

    Plugin Support Leo

    (@leohsiang)

    Thread Starter Joffrey Nicoloff

    (@agent3w)

    Hello Leo,

    thanks but it doesn’t work.

    I tried :
    -> using the suggested filter,
    -> adapting the code in template file,
    -> loading css in init hook like this,

    add_action( 'init', function() {
    	if ( is_archive() && is_category( ['portfolio'] ) ) {
    		while ( have_posts() ) {
    			the_post();
    			GenerateBlocks_Enqueue_CSS::get_instance()->enqueue_assets();
    		}
    	}
    }, 12 );

    GB is loading only the css for the current post_ID.

    If you try this :

    add_action( 'wp_head', function() {
    	if ( is_archive() && is_category( ['portfolio'] ) ) {
    		while ( have_posts() ) {
    			the_post();
    		}
    	}
    } );

    GB loads css for only the last post.

    I’m facing another issue, I will open new topic : GB is loading css only in inline style instead of external file (as I required in GB settings).
    https://ww.wp.xz.cn/support/topic/gb-print-inline-css-instead-of-external-file/

    How sould I ask GB to load css for every posts in current WP_Query in category archive page ?

    Plugin Author Tom

    (@edge22)

    Hi there,

    Our CSS system isn’t built for loops at the moment. It scans the content of the first post and builds CSS based on it.

    We’re looking at ways to improve this without affecting performance.

    Thread Starter Joffrey Nicoloff

    (@agent3w)

    Hi Tom,

    Ok thank you.

    Have a nice day.
    Best regards.
    Joffrey

    Plugin Author Tom

    (@edge22)

    Thanks, you too! 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Post css not loading in archive page’ is closed to new replies.