• Hi Simon,

    I would like to show “Author” when intended, but show “Agent” or something similar when showing listings by a particular agent. Here is an example of an agent archive, but notice the text “Author” before the agent’s name:

    https://rwd.yourweblayout.com/realty/author/fitzwilliam-darcy/?listings=1

    I tried copying archive.php into a wpcasa subfolder in my theme but the only way I can remove the text “Author” before the agent’s name is to edit the archive.php file in my custom theme. This wouldn’t be an issue, except what if the site has both real estate listings and a blog? I tried writing a conditional to check for listing_agent, but that resulted in a blank page, so either that isn’t supported, or there was some error in my conditional.

    Thanks!
    Christi

    https://www.ads-software.com/plugins/wpcasa/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author WPSight

    (@wpsight)

    Hi Christi,

    You can use the function wpsight_is_listing_agent_archive() to check if the author template shows listings or posts.

    For example:

    <?php if( wpsight_is_listing_agent_archive() ) : ?>
    	<p>Show text for listings</p>
    <?php else : ?>
    	<p>Show text for posts</p>
    <?php endif; ?>

    Hope this helps.

    Best regards,
    Simon [WPCasa]

    Thread Starter Christi Nickerson

    (@christini)

    Hi Simon,

    Sorry for the delay in my response. I’m having trouble figuring this out. Should this go in the archives.php file of my theme, or one of the WPCasa templates? I tried adding it to archives.php, but nothing changed. Here’s a link to Pastebin with my archive.php code:

    https://pastebin.com/JA6p32uZ

    Likely I’m doing something wrong, as I am no PHP expert, so I would appreciate your help getting this to work.

    Thanks!

    Plugin Author WPSight

    (@wpsight)

    Hi Christi,

    You will need to make an extra if construct under the is_author() condition:

    elseif ( is_author() ) :
    
    	if ( ! wpsight_is_listing_agent_archive() ) {
        	printf( __( 'Author: %s', 'yourweblayout' ), '<span class="vcard">' . get_the_author() . '</span>' );
        } else {
        	printf( __( 'Agent: %s', 'yourweblayout' ), '<span class="vcard">' . get_the_author() . '</span>' );
        }
    
    elseif ( is_day() ) :
    	printf( __( 'Day: %s', 'yourweblayout' ), '<span>' . get_the_date() . '</span>' );

    Or place the agent condition before the author condition to make sure the code first checks if you’re on a listing archive or not.

    Best regards,
    Simon [WPCasa]

    Thread Starter Christi Nickerson

    (@christini)

    Hi Simon,

    I tried that, still no joy. I have started over with fresh copies of everything to rule out any lingering chaff from old versions of the plugin or theme, but still no joy. I did notice that when I’m viewing the listing page, there is no additional body class added, so how would the check for wpsight_is_listing_agent_archive() work? I noticed this with not only my custom theme, but TwentyTwelve on my site and your demo site as well.

    Here are the new links to a single listing page and the agent/author archive you reach after clicking on the My Listing link at the bottom of the single listing page. Please don’t mind the styling if the site looks a bit messy right now ??

    https://rwd.yourweblayout.com/realty/listing/unique-villa-with-private-beach/

    https://rwd.yourweblayout.com/realty/author/rwdreal/?listings=1

    Thread Starter Christi Nickerson

    (@christini)

    Hi Simon,

    I don’t what I did wrong previously, but I finally got this working!!!

    Thanks!

    Thread Starter Christi Nickerson

    (@christini)

    The only thing that would make it better would be if it didn’t break the author archive if WPCasa is disabled.

    I know, I just keep asking for more ??

    Plugin Author WPSight

    (@wpsight)

    Hi Christi,

    It’s the ?listings=1 that tells WPCasa that we are on a listing agent archive page.

    The only thing that would make it better would be if it didn’t break the author archive if WPCasa is disabled.

    Yeah well, if you use the function, it would make sense to use WPCasa too ?? If you want to avoid any errors, however, check out the PHP function function_exists() to go the safe way.

    Cheers,
    Simon [WPCasa]

    Thread Starter Christi Nickerson

    (@christini)

    Simon, you are determined to make me learn PHP aren’t you ??

    Plugin Author WPSight

    (@wpsight)

    Get one of our themes and you won’t need to mess around with PHP ??

    Thread Starter Christi Nickerson

    (@christini)

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Author text before agent name on agent listing page’ is closed to new replies.