• Resolved Houdini

    (@romariokg)


    Hello, how can I display the first and last name separately in the “Seller Information” block on the ad page?

    In the file “seller-info.php” PHP code: <?php $listing->the_author(); ?> displays the first and last names together. How can I display them separately?

    I need to make it so that the full name is displayed, and only the first letter of the last name is displayed. For example: If the username is Ali Akbar, I need the output to appear as: Ali A.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    As by default, you can not show in this way. You have to customize code to display in this way.

    What you can do –

    1. Create user object.
    2. Then retrieve first name and last name from object
    3. Then modify last name as your requirements.
    $authorData  = get_user_by( 'id', $listing->get_author_id() );
    $firstName = $authorData->first_name;
    $lastName = $authorData->last_name;
    $first_character = substr($lastName, 0, 1);

    Thank you

    Thread Starter Houdini

    (@romariokg)

    Hello, friend! It didn’t work, or I’m doing something wrong! Could you give me a ready-made code that I can paste into the seller-info.php file?

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.