Archived topic
About do_shortcode in custom page template
3 replies · Started by James on November 25, 2015
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 '
';
}
if ($business->don_twitter) {
$shortcode = '[fts twitter search='.$business->twitter.']';
echo '
';
} */
}
?>
<?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 endif; ?>
<?php endwhile; // end of the loop. ?>
<?php do_action('generate_after_main_content'); ?>
</main><!-- #main -->
<!-- #primary -->
<?php
do_action('generate_sidebars');
get_footer();
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.
Tom,
Thanks for your answer. I think I almost catch the cause of the problem.
Thank you so much.
James
You're welcome :)
