I'm asking for help after a day of no luck in finding the solution.
I have shortcodes inside my active plugin and they are working fine on pages but don't work on single post pages (single.php). By not working I mean completely not loading in final frontend source (no desired code and not even the shortcode snippet itself).
I'm using a fresh install of _underscores generated theme.
NOTE: I know it's the theme that's obstructing the shortcodes somehow because when I change the theme to twentyfifteen the shortcodes work.
I tried about 30 solutions (using debug on, installing what the file ... no errors, no warnings)
I would truly appreciate some help or suggestions on how to find the bug in my theme.
Here is my setup: my single.php and content.php
single.php
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package MyTheme
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_type() );
the_post_navigation();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();
content.php
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( sprintf( '<h3 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' ); ?>
<?php if ( 'post' == get_post_type() ) : ?>
<div class="post-details">
<div class="post-details-left">
<i class="fa fa-user-circle"></i> <?php the_author(); ?>
<i class="fa fa-history"></i> <time><?php the_date(); ?></time>
<i class="fa fa-sticky-note"></i> <?php the_category(', '); ?>
<i class="fa fa-tags"></i><?php the_tags('', ', ', ''); ?>
<?php edit_post_link( 'Edit', '<i class="fa fa-pencil"></i>', '' ); ?>
</div>
<div class="post-details-right">
<div class="post-comments-badge">
<a class="post-comments-badge-link" href="<?php comments_link(); ?>"><i class="fa fa-comments"></i> <?php comments_number( 0, 1, '%'); ?></a>
</div>
</div>
</div>
<?php endif; ?>
</header>
<?php if ( has_post_thumbnail() ) { ?>
<div class="post-image">
<div class="post-image-hvr">
<?php the_post_thumbnail(); ?>
</div>
</div>
<?php } ?>
<div class="post-excerpt">
<?php the_excerpt(); ?>
</div>
</article>
Again, any suggestions are very welcome!
You're not actually outputting the page content (e.g. the_content()
); just an excerpt (the_excerpt()
).
Did you write the shortcode code that's having the problem? Did you add a filter for the excerpt?