0

I'm using a child theme of Pixlex.

The theme has a options panel to let me choose wether I want 2 or 3 columns on the home page and if those columns are to be filled with a post or page.

I have one of the columns is set to be filled with a page that has been created and that page has a shortcode for a button placed in it. (the shortcode is provided by the themes code itself)

My problem is that when the home page is rendered the column that pulls in the page shows the shortcode as not being parsed and I am left with: [bigbutton url="http://somelink.com" color="yellow"]The Button[/bigbutton]

I was hoping someone here might see something that I am not.

Here is the code in the homepage template that is pulling in the 3rd column.

<?php  

if($options['basic_homebox3'] && $options['basic_homebox3']!=2){ 

$args = array('page_id' =>$options['basic_homebox3'], );
$post_h = get_post($options['basic_homebox3']);
$title = $post_h->post_title;
$sjc_excerpt = explode( '<!--more-->', $post_h->post_content); 
$permalink = get_permalink( $options['basic_homebox3'] );
$i=1;
?>

<?php if (have_posts()) : ?>   
<?php while (have_posts()) : the_post(); 
      if($i<2){
      ?>
        <div class="span4">
                <div class="home-threebox lastbox">
                    <h2 class="homepage-title"><?php echo $title; ?></h2>
                    <div class="homepage-excerpt">
                      <?php echo wpautop( $sjc_excerpt[0] ); ?>
                    </div>
                </div> 
        </div>        
        <?php 
          }
         $i++;
         endwhile; ?>
         <?php 
         endif;
         }else{
         ?>
            <div class="span4">
                <div class="home-threebox lastbox">
                    <h2 class="homepage-title">Third box</h2>
                    <div class="homepage-excerpt">
                      <p>Suspendisse nisl.</p>
                    </div>
                <div>
            </div>       
<?php
} ?>

1 Answer 1

1

I found the filter I was looking for:

apply_filters('the_content',$content);

A simple fix I replaced this code:

<?php echo wpautop( $sjc_excerpt[0] ); ?>

with this

<?php echo apply_filters('the_content',$sjc_excerpt[0]); ?>

Now the shortcode is rendered!

1
  • 2
    For those finding this question later, this solution works because the WordPress Core processes shortcodes via a callback to the the_content filter. Pushing the string containing the shortcode through that filter allows the Core mechanisms to operate.
    – s_ha_dum
    May 16, 2014 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.