I am developing a theme and I am applying shortcodes
, but in the pages and in the entries, it shows me the literal text instead of what the shortcode
returns.
I'm using the code that comes out in the API.
//[foobar]
function foobar_func( $atts ){
return "foo and bar";
}
add_shortcode( 'foobar', 'foobar_func' );
When I put the text [foobar]
in my post or on a page, it shows me that literal text.
I do not know what happens, I do not know if I'm skipping a configuration, if it's my environment, or something that escapes me.
Try the following code
add_shortcode( 'foobar', function( $atts ){
return "foo and bar";
});
and neither.
single.php
<?php
get_header(); ?>
<div class="container-fluid">
<div class="row justify-content-center mt-4">
<div class="col-md-8">
<?php if ( have_posts() ): while ( have_posts() ): the_post(); ?>
<article class="card">
<div class="card-body">
<h2 class="card-title"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2>
<p class="lead"><?php echo get_the_content() ?></p>
</div>
</article>
<?php endwhile; endif ?>
</div>
</div>
</div>
<?php get_footer();