Home › Forums › General Issues › Get_field, shortcode, nothing work, just display a word " array "
Hello, im really tired to search in internet a solution for this issue,
using in singlepost.php
<?php echo get_field(‘name_field’); ?>
using in content.php
<?php echo get_field(‘name_field’); ?>
using [acf field="field_name" post_id="123"] in the post always show the simple word ” array ” i test in 2 different sites and display the same ” array ”
please help me
What type of field is it and what settings do you have for that field?
Is posttype, a repeater with 4 subfield of text, nothing complicated, i wanted to test the plugin but is not working in the different sites because display the same
If it’s a repeater with sub fields see this page https://www.advancedcustomfields.com/resources/repeater/ there is example code for displaying repeater sub fields.
i put this in single.php
<?php
// check if the repeater field has rows of data
if( have_rows(‘repeater_field_name’) ):
// loop through the rows of data
while ( have_rows(‘repeater_field_name’) ) : the_row();
// display a sub field value
the_sub_field(‘sub_field_name’);
endwhile;
else :
// no rows found
endif;
?>
but nothing still showing just the word ” array “
Did you put exactly that code? or did you alter it to use your field names? You need to supply some more information. What is the name of your repeater field, what is the name of the sub field you’re trying to display? Is there additional nesting involved? If you’re just testing the plugin maybe you should start with a simple text field and work up from there.
im not a expert in code 🙁 im trying to get this sorry for be a noob
this is the code in single.php
<?php
/**
* The Template for displaying all single posts.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php if( have_rows('repeater_field_name') ): ?>
<ul class="slides">
<?php while( have_rows('repeater_field_name') ): the_row();
// vars
$image = get_sub_field('image');
$content = get_sub_field('content');
$link = get_sub_field('link');
?>
<li class="slide">
<?php if( $link ): ?>
<a href="<?php echo $link; ?>">
<?php endif; ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
<?php if( $link ): ?>
</a>
<?php endif; ?>
<?php echo $content; ?>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php get_template_part( 'content-single', get_post_format() ); ?>
<?php endwhile; // end of the loop. ?>
<?php comments_template( '', true ); ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
Name Field: video_y_chat
Subfield #1 : servidor
Subfield #2 : embed
Subfield #3 : idioma
Subfield #4 : calidad
i did try just text and is working, but i want to creat a good thing using repeater please help me, i will do whatever you say
I’m assuming that the repeater field name is video_y_chat. I changed the related lines in your code
<?php
/**
* The Template for displaying all single posts.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php if( have_rows('video_y_chat') ): ?>
<ul class="slides">
<?php while( have_rows('video_y_chat') ): the_row();
// vars
$image = get_sub_field('image');
$content = get_sub_field('content');
$link = get_sub_field('link');
?>
<li class="slide">
<?php if( $link ): ?>
<a href="<?php echo $link; ?>">
<?php endif; ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
<?php if( $link ): ?>
</a>
<?php endif; ?>
<?php echo $content; ?>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php get_template_part( 'content-single', get_post_format() ); ?>
<?php endwhile; // end of the loop. ?>
<?php comments_template( '', true ); ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
Thanks for you time i will leave this because im not expert in this, thanks again
The topic ‘Get_field, shortcode, nothing work, just display a word " array "’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.