Issue Pulling Formatted Content from Static Page onto Custom Category Template
-
Hello,
I’m trying to pull formatted/styled content from a static page created in Gutenberg onto a custom category template, and am running into issues pulling the formatting/styling. We are using GerenatePress Pro (GP) with no page builder. The static page is built with GenerateBlocks. All plugins and PHP are the latest version.
I’ve created a custom category template in GP’s child theme and have the following code in it to pull the content from the aforementioned static page.
$page = get_page_by_title( 'Wedding Venues in Costa Rica' ); $content = apply_filters('the_content', $page->post_content); echo $content;
The above code does pull the content from the static page, but it does not pull the formatting/styling.
A developer at GP recommended I replace
echo $content;
withecho do_blocks( $content );
, to pull the formatting/styling from said static page (resulting in the following code).$page = get_page_by_title( 'Wedding Venues in Costa Rica' ); $content = apply_filters('the_content', $page->post_content); echo do_blocks( $content );
This did not pull any of the the formatting/styling.
According to the same developer at GP, “this method may not be compatible with Gutenberg as it is right now, unfortunately.”
I was hoping you could help resolve this issue as the lead developer at GP is inclined to think the issue due to something with Gutenberg.
This is the full code in the custom category template onto which I want to pull the formatted content from the static page, for reference, if it helps.
<?php /** * The template for displaying Archive pages. * * @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 */ $page = get_page_by_title( 'Wedding Venues in Costa Rica' ); $content = apply_filters('the_content', $page >post_content); echo do_blocks( $content ); /** * 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(); get_footer();
Thank you for your time and have a good day!
- The topic ‘Issue Pulling Formatted Content from Static Page onto Custom Category Template’ is closed to new replies.