Creating a Client Page

Hello,
I am creating a separate Clients Page using the Client Widget and have a few questions:

https://snag.gy/hRu6gC.jpg

  1. Is it possible to remove the text below the Clients heading (A post type for your clients)?
  2. Is it possible to hide the Page Title (company name) if there is a Feature Image (company logo)
  3. I’ve populated the client info / client link with client’s website, but don’t see where the hyperlink is active.

Thank you for your help.

Andy

Hello Adny,

On archive index page of clients, the default link goes to the details page of each post. To enable custom defined link, which is the actual client’s site. Firstly you’d need to add the below PHP code snippet to child theme’s functions. If you aren’t running a child theme, you could use a plugin that does same purpose like Functionality.

    add_action( 'wp_enqueue_scripts', 'talon_child_clients_js', 9999 );
    function talon_child_clients_js() {

      if ( is_post_type_archive('clients') ) {

        $clients_obj = get_posts( array(
          'post_type'       => 'clients',
          'posts_per_page'  => -1,
          'post_status'      => 'publish',
        ));

        $clients = array();
        if( $clients_obj ) {
          foreach ($clients_obj as $client) {
            $clients[$client->post_title] = get_post_meta( $client->ID, 'wpcf-client-link', true );
          }
        }

        wp_localize_script( 'talon-scripts', 'clients', $clients );

      }

    }

Then do the below steps to replace default link and append actual client’s link.

  1. Install and activate the TC Custom JavaScript plugin
  2. Go To Appearance > Custom JavaScript
  3. Paste the following code into the provided box
    jQuery(function($) {

      if( $('.post-type-archive-clients').length ) {

        $.each(clients, function(key,value){

            var title = key;
            var link  = value;

            $('.hentry.clients').each(function(){

              var thumbLink = $(this).children('.entry-thumb').find('a');
              var defaultLink = thumbLink.attr('href');

              if( thumbLink.attr('title') == title ) {
                if( link != '' ) {
                  thumbLink.attr('href', link);
                }else{
                  thumbLink.attr('href', defaultLink);
                }
              }

            });

        });

      }

    });
  1. Update

Run your test, but before doing so, flush any applied cache as it usually blocks new code addition to take effect. https://codex.wordpress.org/I_Make_Changes_and_Nothing_Happens

Have a nice weekend!

Regards,
Kharis

Kharis,
I was able to develop the page as I had envisioned - https://snag.gy/1ClVE4.jpg - with the hyperlinks working.

Two additional questions:

  1. is there any way that when you click on the hyperlink, it opens a new tab, rather than it opening up in the same tab?

  2. is there a way to remove the text of the name of the client below the logo?

Thank you.

Andy

1

In the code above, try replacing this line:

thumbLink.attr('href', link);

with:

thumbLink.attr('href', link).attr('target', '_blank');

2

Add this CSS code to Appearance > Customize > Additional CSS from dashboard.

.post-type-archive-clients .hentry .post-content {
  display: none;
}

Regards,
Kharis