Short code in single.php not working
-
I’m using
<?php echo do_shortcode('[wp_biographia]'); ?>
But it shows nothing at all.Any ideas?
-
Happy to help, but I’m not a mind reader; please read the sticky thread on the plugin’s forum (it’s there right at the top – https://www.ads-software.com/support/topic/wp-biographia-problem-or-question-please-read-this-first?replies=1) first so I can try and duplicate what you’re seeing, or rather not seeing.
-Gary
I’m not seeing anything at all. It’s as if I didn’t put the php code at all.
I’ve already gone through the FAQ.
I told you exactly what I’m doing. Putting the above mentioned PHP in single.php . It displays nothing at all. I’m just trying to get the biography to show exactly where I want it. Here’s a larger section of the code
<div class="entry"> <?php the_content(); ?> </div> <!-- entry --> <center><span class="CSSButton"><?php // In case there is opening and closing shortcode. echo do_shortcode('[subscribe2]'); ?></span> <?php echo do_shortcode('[wp_biographia]'); ?></center> <div class="post-tags"> <?php the_tags(); ?> </div>
The subscribe2 is showing just fine. But biographia not showing anything. It does show when selecting ‘show on posts’ in settings. I need to place it via shortcode though at the end of each post.
It does show when putting the shortcode directly in the post. Just not showing when put in the template with the php do_shortcode.
It’s great that you’ve read the FAQ … a lot of people don’t. But I still don’t know all the other stuff that the plugin forum’s sticky thread asks for. Such as your WordPress version, the plugin version, your theme and so on.
I can’t seem to replicate this on my local testing install, so it might be a theme or other plugin not playing nicely with WP Biographia.
One thought does spring to mind though; the plugin supports adding the biography box to a single post out of the box. Is there any reason why this doesn’t do what you want it to do when using the single post template?
-Gary
I want it to show underneath my subscriber box and underneath related posts. The theme is silverorchid. The site is gizbeat. WP version is always the most recent. It works fine via the settings and when a shortcode is placed in a post. I just can’t get it to work in the single.php
I’ve downloaded the Silver Orchid theme and tried this out on my local install.
The bad news is that I can’t seem to get the short code working. Which means you’ve probably found a bug. I need to do some more digging into the plugin’s code to see what’s going on here.
The good news is that rather than have the overhead of getting WordPress to parse the short code, you can use one of the plugin’s template tags instead and this works just fine. This is actually the preferred way to get the placement of the Biography Box just as you want it in a theme’s template.
The following code snippet is working in the theme’s
single.php
. Based on your earlier post, I’ve added the Biography Box in-between theentry
div and thepost-tags
div.<div class="entry"> <?php the_content(); ?> </div> <!-- entry --> <?php if (function_exists('wpb_the_biography_box')) { wpb_the_biography_box(); } ?> <div class="post-tags"> <?php the_tags(); ?> </div>
… give this a try and let me know how you get on.
-Gary
Yes, I tried the template tag previously (I did read the FAQ :). I just tried it again now, and no luck.
I don’t know where the problem lies.
The code looks like this now:
<div class="post-nav"> <div class="previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . __( '←', 'Previous post link', 'silverorchid' ) . '</span> %title' ); ?></div> <div class="next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . __( '→', 'Next post link', 'silverorchid' ) . '</span>' ); ?></div> </div><!-- /page links --> <?php if (function_exists('wpb_the_biography_box')) { wpb_the_biography_box(); } ?>
(I wanted it under nav). It just shows nothing. Is there some setting I need to make in settings to enable the template tag to work?
Well, no stress man. Let me know if you figure it out.
Can you post the entirety of your
single.php
template on something like PasteBin so I can take a look at where you’ve placed the template tag in context? It looks like you’ve modified this template a bit and I want to ensure I’m trying to duplicate your set up as much as I can.-Gary
I’ve not done much with single.php. Really nothing other than adding the shortcode for subscribe2 and adding my G+
Just tried your
single.php
and the template tag is working perfectly for me. That’s kind of ruled out an issue with the theme and the plugin not playing well together. All of which suggests there might be a problem with another plugin … have you tried deactivating all of the others and seeing if this problem continues?
- The topic ‘Short code in single.php not working’ is closed to new replies.