customizer-repeater
customizer-repeater copied to clipboard
Social repeater is not working as expected
I have copied and paste the default customizer control and setting in customizer field. It has no problem in backend options. Customizer control and setting code :
`
$wp_customize->add_setting( 'customizer_repeater_example', array(
'sanitize_callback' => 'my_theme_sanitize_repeater',
));
`
`
$wp_customize->add_control( new My_Theme_Repeater_Control( $wp_customize,
'customizer_repeater_example', array(
'label' => esc_html__('My Repeater','customizer-repeater'),
'section' => 'my_theme_repeater',
'priority' => 1,
'customizer_repeater_image_control' => true,
'customizer_repeater_icon_control' => true,
'customizer_repeater_title_control' => true,
'customizer_repeater_subtitle_control' => true,
'customizer_repeater_text_control' => true,
'customizer_repeater_link_control' => true,
'customizer_repeater_shortcode_control' => true,
'customizer_repeater_repeater_control' => true
) ) );
`
I also copied and paste the defualt code to display in frontend. All options are working fine but social repeater is not displaying its social icons and links. Code for frontend : `//Repeater
$customizer_repeater_example = get_theme_mod('customizer_repeater_example', json_encode( array(/*The content from your default parameter or delete this argument if you don't want a default*/)) );
$customizer_repeater_example_decoded = json_decode($customizer_repeater_example);
if( !empty( $customizer_repeater_example_decoded ) ) {
foreach($customizer_repeater_example_decoded as $repeater_item ) {
echo $repeater_item->icon_value . '<br>';
echo $repeater_item->text . '<br>';
echo $repeater_item->link . '<br>';
echo $repeater_item->image_url . '<br>';
echo $repeater_item->choice . '<br>';
echo $repeater_item->title . '<br>';
echo $repeater_item->subtitle . '<br>';
echo $repeater_item->shortcode . '<br>';
$social_repeater_item = $repeater_item->social_repeater;
echo '<pre>';
var_dump( $social_repeater_item );
echo '</pre>';
/*Social repeater is also a repeater so we need to decode it*/
$social_repeater_decoded = json_decode($social_repeater_item);
if( !empty( $social_repeater_decoded ) ) {
foreach($social_repeater_decoded as $social_repeater ) {
echo '<pre>';
var_dump( $social_repeater );
echo '</pre>';
echo $social_repeater->link;
echo $social_repeater->icon;
}
}
}
}`
When i did var_dump to $social_repeater_item, then result is :
//var_dump string(371) "[{"icon":"fa-facebook","link":"https://www.facebook1.com","id":"customizer-repeater-social-repeater-5d582bca1a034"},{"icon":"fa-linkedin","link":"https://www.linkedin1.com","id":"customizer-repeater-social-repeater-5d582e760d3ea"}]"
But, when i var_dump to $social_repeater, nothing shows. I don't know why it is happening to me. I hope, you may sort out soon.
Waiting for your response as soon as possible.
I had a similar problem this solved it for me -
$social_repeater = json_decode( html_entity_decode( $repeater_item->social_repeater ) ); foreach( $social_repeater as $social_repeater ) { echo $social_repeater->link; echo $social_repeater->icon; }
I will try what you did. Thanks for response @jjs2484