0

Not able run the shortcode. Created to show custom post type pages inside Tabs created by a plugin. I have attached the image for the same with this post.

enter image description here

Here is code I have created.

<?php 
 function casino_bros() {    
     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
     $args=array(
       'post_type'=>casino,              
       'posts_per_page' => 5,
       'orderby' => 'date',
       'paged'=>$paged
    );

    $wp_query = new WP_Query($args);

    /* PageNavi at Top */

    if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();   

    /* DO STUFF IN THE LOOP */
    ?>
            /*  Post Loop   */

    <?php
    endwhile; endif;
    wp_reset_query(); ?> 

<?php } 

add_shortcode( 'livecasinoss', 'casino_bros' );  
function some_func()
{
    $data=('[livecasinoss]');    
    return do_shortcode($data); 
} 
add_shortcode( 'livecasinos', 'some_func' );?>
  • 2
    What created the tabs? How do the tabs work? You will need to post the relevant code. – s_ha_dum Dec 28 '15 at 21:21
  • 3
    Possible duplicate of shortcode inside another shortcode – Howdy_McGee Dec 28 '15 at 21:28
  • tabs are created by a plugin , but the inner short-codes are my own created . I need content in all tabs through my short code – Sanj2cool Dec 29 '15 at 14:43
  • Above black border content need to be inside the tab .. but it's appearing before tab. – Sanj2cool Dec 29 '15 at 14:44
  • I am not a expert in programming but can create some basic codes:- – Sanj2cool Dec 29 '15 at 14:45
0

As the article shows, ob_start and ob_get_clean can capture typical loop output and return as a variable. When you're in the loop you might want to make sure the_content renders it's shortcode as well.

function do_livecasinoss_shortcode($atts, $content = "") {

    // start the buffer
    ob_start();

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
        'post_type'      => 'casino',
        'posts_per_page' => 5,
        'orderby'        => 'date',
        'paged'          => $paged,
    );

    $wp_query = new WP_Query($args);

    /* PageNavi at Top */

    if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post();

        /* DO STUFF IN THE LOOP */

        // run any shortcode items inside the_content
        echo apply_filters('the_content', get_the_content());

        ?>/*  Post Loop   */<?php

    endwhile; endif;

    wp_reset_query();

    // stop the buffer / capture and return the output
    return obj_get_clean();
}

add_shortcode('livecasinoss', 'do_livecasinoss_shortcode');


// Wrapper for livecasinoss shortcode
function do_livecasinos_shortcode($atts, $content = "") {

    // return rendered shortcode
    return do_shortcode('[livecasinoss]');
}

add_shortcode('livecasinos', 'do_livecasinos_shortcode');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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