• Resolved ginnywills

    (@ginnywills)


    I have tried so hard to follow the directions for adding custom fields. I am using the default template and only have basic contact details per member, but I have added a field called “Spouse Name”. It has shown on the back-end, but I can’t get it to show on the front end. The only thing that shows is the word ARRAY.

    I don’t know PHP so I am sure it’s just a comma or something. This is what I have added to the card.php file that I created:

    <div>
    <?php
    $text = $entry->getMeta(
    array(
    ‘id’ => ‘spouse_id’, // This should match exactly the field id used when registering the custom field.
    ‘single’ => TRUE // Do not change this.
    )
    );

    if ( ! empty( $text ) ) echo ” . esc_html( $text ) . ”;
    ?>
    </div>

Viewing 11 replies - 16 through 26 (of 26 total)
  • Plugin Author Steven

    (@shazahm1hotmailcom)

    Change this bit echo '' to echo 'Spouse Name: '.

    Thread Starter ginnywills

    (@ginnywills)

    Yes!!! Thank you for your help.

    Plugin Author Steven

    (@shazahm1hotmailcom)

    Glad to help!

    If you have a moment, I would truly appreciate a review as they really do make a difference.

    https://wordpress.org/plugins/connections/#reviews

    Thanks in advance for your time!

    Thread Starter ginnywills

    (@ginnywills)

    HI there

    I thought we were good but I just noticed a formatting issue with the custom field I added. When an image is added to the card, the spouse name (which is the custom field) gets moved up and is squished in with the title. I want to show you a screenshot rather than give you access to the directory I am working on (due to confidential information) – hopefully this link will work: screenshot

    Thread Starter ginnywills

    (@ginnywills)

    Wait try this link: Screenshot2

    Plugin Author Steven

    (@shazahm1hotmailcom)

    Add div or p tags or any other HTML you want to the code, here’s just one example:

    if ( ! empty( $text ) ) echo '<div>' . esc_html( $text ) . '</div>';

    Thread Starter ginnywills

    (@ginnywills)

    That did not work for me. But I don’t know PHP at all. Is this correct? This is my custom field.

    <div>
    <?php
    $text = $entry->getMeta(
    		array(
    			'key'    => 'spouse_id', // This should match exactly the field id used when registering the custom field.
    			'single' => TRUE        // Do not change this.
    		)
    	);
    
    if ( ! empty( $text ) ) echo '<div>Spouse Name: ' . esc_html( $text ) . '</div>';
    ?>
    
    </div>
    
    Plugin Author Steven

    (@shazahm1hotmailcom)

    Looks fine to me. It’s not possible for me to give any advice beyond what I’ve given because it is not possible for me to tell the reason from a screenshot.

    A wild guess, perhaps it needs to be right aligned like the phone email and addresses. Use CSS to do this. Whether or not that it needs right aligned would depend on where it is in the template.

    Thread Starter ginnywills

    (@ginnywills)

    Is it possible for you to look at the actual page then? This is the link:https://thefairfieldgardenclub.org/members-area/member-directory-2020/

    I have removed the password so you can see it.

    If you look at Candace Wagner or Kimberly Cooper, you will see when an image is added the Spouse Name seems to move to the top or start a new column or something.

    I really appreciate your help.

    Plugin Author Steven

    (@shazahm1hotmailcom)

    Put your code after <div style="clear:both"></div> in the template.

    Thread Starter ginnywills

    (@ginnywills)

    Yes! Thank you!!!

Viewing 11 replies - 16 through 26 (of 26 total)
  • The topic ‘Displaying Custom Fields’ is closed to new replies.