Shortcodes do not work on my wordpress theme

I’m creating my theme and everything is ok,

But I installed a plugin and it does not work properly when adding shortcodes to the theme. In the page it appears in the console the html tags of the plugin, but it gets a big white space without the slider, in the site before the text of the page appears. I changed the theme to see if the problem was the plugin but in the other theme the plugin worked perfectly. I thought it might be jquery, but with or without the WP-provided jquery (in header or footer) the result is the same.

What am I doing wrong?

function.php

<?php


require_once('inc/redux-framework-master/redux-framework.php');
require_once('inc/office-master-theme-options.php');

add_theme_support( 'post-thumbnails', array( 'post','page' ) );


function enqueue_jquery() {


    wp_deregister_script('jquery' ); 


    wp_register_script( 
         'jquery', 
         get_template_directory_uri() . '/js/jquery.js',
         array(), 
         '1.11.1', 
         false
    );


    wp_enqueue_script( 'jquery');
} 
add_action('wp_enqueue_scripts', 'enqueue_jquery');



function enqueue_styles_scripts() {


    wp_enqueue_style(
        'style-theme',
        get_stylesheet_uri(),
        array('bootstrap-css')
    );


    wp_enqueue_style(
        'bootstrap-css',
        get_template_directory_uri() . '/css/bootstrap.min.css'
    );


    wp_enqueue_style(
        'stylish-portfolio',
        get_template_directory_uri() . '/css/stylish-portfolio.css'
    );


    wp_enqueue_style(
        'font-awesome',
        get_stylesheet_directory_uri() . '/css/font-awesome.css'


    ); 


    wp_enqueue_script(
        'bootstrap-js',
        get_template_directory_uri() . '/js/bootstrap.min.js',null
    );

} 
add_action('wp_enqueue_scripts', 'enqueue_styles_scripts');



function wpse_ie_conditional_scripts() { ?>
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <?php
}
add_action( 'wp_head', 'wpse_ie_conditional_scripts' );


require_once('wp_bootstrap_navwalker.php');
register_nav_menus( array(
     'primary' => __( 'Main Menu', 'THEMENAME' ),
) );




?>

page.php

<?php get_header(); ?>


            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                <div class="article">
                    <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
                    <p><?php echo do_shortcode('[meta_gallery_slider]'); ?></p>
                    <p><?php the_content(); ?></p>
                </div>
            <?php endwhile; else: ?>
                <div class="article">
                    <p>Error 404</p>
                </div>          
            <?php endif; ?>


        <?php get_sidebar(); ?>


<?php get_footer(); ?>

The htmls and src tags of the gallery images appear in the console, but the screen turns white in the location that should display the images

I finally found the problem. I forgot to put <?Php wp_footer(); ?> In the footer.php file

this was somehow causing the error and not showing the shortecodes

1 Like

The wp_footer() provides a hook that many plugins use (including yours, probably).

1 Like

I guess the “Always” should be in bold!

Examples
In twentyten theme
wp-content/themes/twentyten/footer.php:

...
<?php
   /* Always have wp_footer() just before the closing </body>
    * tag of your theme, or you will break many plugins, which
    * generally use this hook to reference JavaScript files.
    */
    wp_footer();
?>
</body>
</html>
1 Like

Great, I’ll always remember, thanks

Thanks, It’s so clear in the documentation, but I’m developing my first theme, probably I’m going to make a lot of mistakes until I have more experience

It would help you to refer to the WordPress Codex often as you develop the theme then. It has a huge section on just that topic, and what is required, or what best practices are.

1 Like

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