0

I am able to show repeater metabox on index and single post .Now I want to show this using

add_filter( 'the_content', 'theme_slug_filter_the_content' );

My code to get meta value

<?php
$data = get_post_meta($post->ID,"repeatable_fields",true);
echo '<ul>';
if (count($data) > 0){
    foreach((array)$data as $p ){
        if (isset($p['name']) || isset($p['select'])|| isset($p['url'])){
            echo '<li>Number: '.$p['name'].' Description: '.$p['select'].' Price: '.$p['url'].'</li>';
        }
    }
}
echo '</ul>';
?>

I guess My code will be

function theme_slug_filter_the_content( $content ) {
$custom_content = 'YOUR CONTENT GOES HERE';
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'theme_slug_filter_the_content' );
0

Did you try this ?Hope this will work.

add_filter( 'the_content', 'cd_display_quote' );
function cd_display_quote( $content )
{   
// We only want this on single posts, bail if we're not in a single post
// if( !is_single() ) return $content;

// We're in the loop, so we can grab the $post variable
global $post;


$data = get_post_meta($post->ID,"repeatable_fields",true);
echo '<ul>';
if (count($data) > 0){
    foreach((array)$data as $p ){
        if (isset($p['name']) || isset($p['select'])|| isset($p['url'])){
            echo '<li>Number: '.$p['name'].' Description: '.$p['select'].' Price: '.$p['url'].'</li>';
        }
    }
}
echo '</ul>';

// Return the values: quote first, then the content
return $content;
 }

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.