Listing Thumbnails – GDF Modern

This topic contains 10 replies, has 3 voices, and was last updated by  directory 8 years, 8 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #139803

    directory
    Expired Member
    Post count: 1502

    How can I display the following on the listing thumbnails on my home page?

    1. Category
    2. City, State
    3. Zip Code

    #139812

    Guust
    Moderator
    Post count: 29970
    #139893

    directory
    Expired Member
    Post count: 1502
    This reply has been marked as private.
    #140098

    Guust
    Moderator
    Post count: 29970

    Might have misled you earlier, this will add the custom field data to the listing, search and location page widgets: https://wpgeodirectory.com/docs/core-place-settings/#show-on-listing-page

    #140219

    directory
    Expired Member
    Post count: 1502

    Hi Guust,

    I am trying to display the listing category that the user chose on the thumbnails. It’s not a custom field.

    #140269

    Paolo
    Site Admin
    Post count: 31206

    Categories are stored in an array as there can be more than 1.

    You will need something like this:

    
    
    
    $post_type = $post->post_type;
    $post_type_data = get_post_type_object( $post_type );
    $post_type_slug = $post_type_data->rewrite['slug'];
    $post_tax = $post_type."category";
    $post_cats = $post->$post_tax;
    $cats_arr = array_filter(explode(",", $post_cats));
    foreach($cats_arr as $cat){
    		$term_arr = get_term( $cat, $post_tax);
    		$term_url = get_term_link( intval($cat), $post_tax );
    		echo '<a href="'.$term_url.'">';
    		echo '<span class="cat-link">'.$term_arr->name.'</span>';
    		echo '</a>';
    

    I haven’t tested it, so I’m not 100% sure it will work. I know for sure this works in detail page.

    Just FYI, for most fields, if you declared the global $post variable, you can get the data like this:

    
    
    
    $post->post_city
    $post->post_region
    $post->post_country

    and so on…

    Let us know how you went,

    Thanks

    #140473

    directory
    Expired Member
    Post count: 1502
    This reply has been marked as private.
    #140500

    Paolo
    Site Admin
    Post count: 31206

    Change this:

    
    
    echo '<a href="'.$term_url.'">';
    		echo '<span class="cat-link">'.$term_arr->name.'</span>';
    		echo '</a>';

    to

    
    
    echo '<div class="cat-links"><a href="'.$term_url.'">';
    		echo '<span class="cat-link">'.$term_arr->name.'</span>';
    		echo '</a></div>';

    Than style with css.

    You can add margin-right to catgeories and add a comma ::after all links except the :last-child.

    Hope it’s enough to point you in the right direction.

    Thanks

    #141422

    directory
    Expired Member
    Post count: 1502
    This reply has been marked as private.
    #141882

    Paolo
    Site Admin
    Post count: 31206
    This reply has been marked as private.
    #141887

    directory
    Expired Member
    Post count: 1502

    I understand. Thanks.

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount