- This topic has 3 replies, 2 voices, and was last updated 8 years, 4 months ago by Tom.
-
AuthorPosts
-
November 25, 2015 at 9:29 am #155683James
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();November 25, 2015 at 10:44 am #155711TomLead DeveloperLead DeveloperHi 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.
November 25, 2015 at 10:59 am #155715JamesTom,
Thanks for your answer. I think I almost catch the cause of the problem.
Thank you so much.James
November 25, 2015 at 11:01 am #155716TomLead DeveloperLead DeveloperYou’re welcome 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.