Cyber Week Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[Resolved] About do_shortcode in custom page template

Home Forums Support About do_shortcode in custom page template

  • This topic has 3 replies, 2 voices, and was last updated 5 years ago by Tom.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #155683
    James

    I am just wondering about using do_shortcode in my custom page template. I have made the template, and try to use do_shortcode function in order to activate one of my plugins, and could to that. The problem is, CSS is not applied to the result by using do_shortcode. The plugin manager told me that I should type do_shortcode after wp_head(). I did, but it is not working well.. Could you give me some advice about it?

    * I got the following answer from the plugin mmanager:
    https://wordpress.org/support/topic/retrieving-instagram-location

    * This is my custom template:
    <?php
    /**
    * Template Name: something
    *
    * @package GeneratePress
    */

    get_header(); ?>

    >
    <main id=”main” <?php generate_main_class(); ?> itemprop=”mainContentOfPage” role=”main”>
    <?php do_action(‘generate_before_main_content’); ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php wp_head(); ?>
    <?php if(function_exists(‘bcn_display’))
    {
    …something…
    }?>
    <?php
    $businesses = $wpdb->get_results(“SELECT * FROM something WHERE something);

    foreach($businesses as $business) {
    …something…

    if ($business->fb) {
    $shortcode = ‘[fts facebook id=’.$business->facebook.’ posts_displayed=page_only type=page]’;
    echo ‘

    ‘.do_shortcode($shortcode).’

    ‘;
    }
    if ($business->don_twitter) {
    $shortcode = ‘[fts twitter search=’.$business->twitter.’]’;
    echo ‘

    ‘.do_shortcode($shortcode).’

    ‘;
    } */

    }

    ?>

    <?php get_template_part( ‘content’, ‘page’ );?>

    <?php
    // If comments are open or we have at least one comment, load up the comment template
    if ( comments_open() || ‘0’ != get_comments_number() ) : ?>

    <?php comments_template(); ?>

    <?php endif; ?>

    <?php endwhile; // end of the loop. ?>
    <?php do_action(‘generate_after_main_content’); ?>
    </main><!– #main –>

    <!– #primary –>

    <?php
    do_action(‘generate_sidebars’);
    get_footer();

    #155711
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Typically all you need to do is this:

    <?php echo do_shortcode( '[my-shortcode]' ); ?>

    If that doesn’t work, there’s most likely something wrong with the coding of the shortcode.

    #155715
    James

    Tom,
    Thanks for your answer. I think I almost catch the cause of the problem.
    Thank you so much.

    James

    #155716
    Tom
    Lead Developer
    Lead Developer
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.