Support

Account

Home Forums Front-end Issues Display field in array

Solved

Display field in array

  • Hello I have coauthors plus and I want to show a title text from the users profile. Ive done this with Toolset Types and it worked great. But i have decided to only use ACF and I cannot get it to work. The code below is from the array i want to put my field in

    
    	$args = array(
    		'before_html' => '',
    		'href' => get_author_posts_url( $author->ID, $author->user_nicename ),
    		'rel' => 'author',
    		'title' => sprintf( __( 'Posts by %s', 'co-authors-plus' ), apply_filters( 'the_author', $author->display_name ) ),
    		'class' => 'author url fn',
    		'text' => apply_filters( 'the_author', $author->display_name ),
    		'after_html' => ', ' ,
    		'title' => get_field('title', 'user_'. $array['ID'] ) ,
    	);

    This is the part I cannot fix: ‘title’ => get_field(‘title’, ‘user_’. $array[‘ID’] ) ,. It doesnt display anything. In Types I used this: ‘title’ => types_render_usermeta( ‘title’, array(‘user_id’ => $author->ID,)) ,

    Thanks

  • what is in $array? I dont’t see this in your code

    try using get_field('title', 'user_'.$author->ID);

  • Nice! I thought I tried that code but apparently I didnt. This worked:

    ‘title’ => get_field(‘titel’, ‘user_’.$author->ID) ,

    There is nothing in $array. This code is from coauthors plugin. I just added an extra line for it to display a title after the authors name.

    Thank you! I have now uninstalled Types!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Display field in array’ is closed to new replies.