Looking for a little help in setting a Global Block in a CPT template

As demonstrated here, https://theme.co/apex/forum/t/adding-cornerstone-content-in-php

I would like to do this but just add the GB shortcode or PHP to a CPT custom template or insert it via the functions.php as demonstrated here, just not for the shop page. My custom template is called single-client.php.

Your help is greatly appreciated.

Hi There,

May we know the full code of single-client.php file?

You just need to add this code to the end of content in your single client file:

echo do_shortcode('[cs_gb id=179]');

You should replace the 179 number with your global block ID.

Hope it helps :slight_smile:

>     Here's my code. No idea where to insert it. 

>     // =============================================================================
>     // VIEWS/INTEGRITY/WP-SINGLE.PHP
>     // -----------------------------------------------------------------------------
>     // Single post output for Integrity.
>     // =============================================================================

>     $fullwidth = get_post_meta( get_the_ID(), '_x_post_layout', true );

>     get_header();

>     ?>

>       <div class="x-container max width offset">
>         <div class="<?php x_main_content_class(); ?>" role="main">

>           <?php while ( have_posts() ) : the_post(); ?>
>             <?php x_get_view( 'integrity', 'content', get_post_format() ); ?>

>           <?php endwhile; ?>

>         </div>


>         <?php if ( $fullwidth != 'on' ) : ?>
>           <?php get_sidebar(); ?>
>         <?php endif; ?>

>       </div>

>     <?php get_footer(); ?>

Hi Eric,

You can add it before or after this block,

          <?php while ( have_posts() ) : the_post(); ?>
            <?php x_get_view( 'integrity', 'content', get_post_format() ); ?>

          <?php endwhile; ?>

Examples,

<?php echo do_shortcode('[cs_gb id=179]'); ?>
          <?php while ( have_posts() ) : the_post(); ?>
            <?php x_get_view( 'integrity', 'content', get_post_format() ); ?>

          <?php endwhile; ?>
          <?php while ( have_posts() ) : the_post(); ?>
            <?php x_get_view( 'integrity', 'content', get_post_format() ); ?>

          <?php endwhile; ?>
<?php echo do_shortcode('[cs_gb id=179]'); ?>

Hope this helps.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.