Skip to content

Missing css/js on custom theme frontpage #1337

Closed

Description

@joey-kwl

Description:

I'm loading a page with get_post() combined with apply_filters() into my frontpage of a custom theme, but when I load Otter's slider block all of the images are underneath eachother.

How to reproduce:

  1. Make page with a slider from Otter
  2. Load page in frontpage with get_post

Expected behaviour:

A slider like in the gutenberg

Current behaviour:

All of the images are shown underneath eachother

Reference:

Technical info

  • WordPress version: 6.1.1
  • Plugin version: 2.1.3

I tried adding this to my frontpage (index.php):

use ThemeIsle\GutenbergBlocks\CSS as OtterBlockCSS;
$css = new OtterBlockCSS\Block_Frontend();
$css->enqueue_styles("18", true)

Found here: https://wordpress.org/support/topic/otter-block-styles-on-other-page/
but enqueue_styles return NULL

Edit:
It seems like it went inside this part of class-block-frontend.php:

if ( ! has_blocks( $post_id ) ) {
	return;
}

Activity

  1. joey-kwl commented on Nov 19, 2022

    @joey-kwl
    Author

    I found a workaround. Create a Post (not a page but a post) with a slider and you can publish it as private. The plugin will load all the css/js.

  2. HardeepAsrani commented on Nov 25, 2022

    @HardeepAsrani
    Member

    Hey @chineseouchie,

    Could you send us the custom theme that you've made so we could reproduce on it? Thank you!

  3. joey-kwl commented on Nov 25, 2022

    @joey-kwl
    Author

    @HardeepAsrani I have added you to a temporary repo. If you go into the /dist folder you will see a zip and instructions file

  4. HardeepAsrani commented on Dec 1, 2022

    @HardeepAsrani
    Member

    Hey @chineseouchie,

    In the index.php file, I used the get_posts function to make a loop like:

    <div>
    	<?php
    	global $post;
    
    	$myposts = get_posts( array(
    		'posts_per_page' => 5
    	) );
    
    	if ( $myposts ) {
    		foreach ( $myposts as $post ) : 
    			setup_postdata( $post ); ?>
    			<?php the_content(); ?>
    		<?php
    		endforeach;
    		wp_reset_postdata();
    	}
    	?>
    </div>
    

    And it seems to work properly with the slider. Am I missing something you are doing?

  5. locked and limited conversation to collaborators on Dec 1, 2022
  6. converted this issue into a discussion #1359 on Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions