Html to php var + parsing + WordPress -> get_the_excerpt()

I guess this is a problem of parsing but couldn’t figure it out after few hours on it. I am close to the solution but stuck and starting to drive me crazy!

The issue: I can’t get my excerpt (description) dynamically as it looks like my variable $my_id is returning null when I am pushing it into the function get_the_excerpt()

<?php ob_start(); ?>
    {{ data[ index ].option_id }}
<?php $my_id = ob_get_clean(); ?>

<?php $product_description = get_the_excerpt($my_id); ?>
<span class="radio_button_desc"><?php echo apply_filters( 'woocommerce_composited_product_excerpt', wpautop( do_shortcode( wp_kses_post( $product_description ) ) ), $product_id, $component_id, $composite ); ?></span>    

I have already tried to push the id directly like the following:

<?php $product_description = get_the_excerpt(123456); ?> 

And guess what? It’s working.

I also tried to parse $my_id to an (int). My gettype() is returning it as an int but my variable return “0” in that case.

echo $my_id is returning the right numbers (id) so I can’t get why it doesn’t work when I push it through my variable inside get_the_excerpt($my_id);

Any clue on it?


Read more here: Html to php var + parsing + WordPress -> get_the_excerpt()

Leave a Reply

Your email address will not be published. Required fields are marked *