Call listing category

This topic contains 7 replies, has 2 voices, and was last updated by  Giri 6 years, 11 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #379828

    Falk Meyer-Plate
    Free User
    Post count: 14

    Hey,

    i would like to call the listing category right behind the title on the details page.

    Here is my snippet i worked out so far, but i cant find the right hook to get the category displayed.

    
    
    remove_action( 'geodir_detail_sidebar', 'geodir_action_details_sidebar', 10 );
    remove_action('geodir_details_main_content', 'geodir_action_details_taxonomies', 40);
    add_action( 'geodir_details_main_content', 'custom_details', 45 );
    function custom_details() {
    global $post; 
    global $wp_query;
    
    $postid = $wp_query->post->ID;
    
    $current_posttype = geodir_get_current_posttype();
    $taxonomies = geodir_get_taxonomies($current_posttype,true);
    	$customtitle= geodir_get_post_meta($postid,'post_title',true); //title
    	$customaddress= geodir_get_post_meta($postid,'post_address',true); //address
    	$customcity= geodir_get_post_meta($postid,'post_city',true); //city
      	$customzip= geodir_get_post_meta($postid,'post_zip',true); //zip
    	$customphone= geodir_get_post_meta($postid,'geodir_contact',true); //phone
    	$customwebsite=geodir_get_post_meta($postid,'geodir_website',true); //website
    	$customemail=geodir_get_post_meta($postid,'geodir_email',true); //email
      	$customlogo=geodir_get_post_meta($postid,'geodir_partner_details_logo',true); //logo
      $custombeschr=geodir_get_post_meta($postid,'geodir_partner_beschr',true); //beschreibung
      
      	$find_in_phone = array(" ","-","(",")","/","\\");
      	$find_in_website = array("www.", "http", "https", "://");
      
    echo '<div class="row">';
      	echo '<h3 style="padding:0px 15px 15px 15px;margin-top:-15px;">'.$customtitle.'<small> '.$taxonomies[0].'</small></h3>';
      	 
      
    	echo '<div class="ccr_details_page_logo col-md-2">';
      		echo '<span style="background-image:url('.$customlogo.')" class="img-responsive partner_logo">';
       		
      	echo '</div>';
      	echo '<div class="ccr_details_page_adress col-md-3">';
    		echo '<p class="clearfix">'.$customaddress.'</p>';
      		echo '<p class="clearfix">'.$customzip.'</p>';
      		echo '<p><a class="clearfix" href="tel:'.str_replace($find_in_phone, "", $customphone).'">☎ '.$customphone.'</a></p>';
    	echo '</div>';
      	echo '<div class="ccr_details_page_adress_2 col-md-5">';
      		if(strlen($customemail) != 0){
      			echo '<p><a class="clearfix" href=mailto:'.$customemail.'>✉ E-Mail</a></p>';
    		};
    		echo '<p><a class="clearfix" href='.$customwebsite.'>'.str_replace($find_in_website, "", $customwebsite).'</a></p>';
    	echo '</div>';
     	echo '<div class="ccr_details_page_social col-md-2">';
     	echo '</div>';
      echo '</div>';
        echo '<hr>';
      echo '<div class="ccr_details_page_beschreibung col-md-12">';
      echo '<p class="partner_beschr">'. $custombeschr.'</p>';
       echo '</div>';
       echo '<hr>';
    //do_action( 'geodir_sidebar_detail_top', 'geodir_action_geodir_sidebar_detail_top','' );
    	do_action( 'geodir_action_details_slider');
    }

    can you give me a hint what i am missing?

    greetings
    Falk

    #379830

    Giri
    Expired Member
    Post count: 3155

    You mean below title of the detail page?

    Can you post your site url too? So I can see your current layout

    #379832

    Falk Meyer-Plate
    Free User
    Post count: 14

    Hey Giri,
    I can give you this screenshot. Where it says gd_place_tags i want the category to be displayed. Basicly i just need the right variable to call the category of the listing.

    #379834

    Giri
    Expired Member
    Post count: 3155

    I hope you are talking about the listings page that looks like /places/

    If thats the case you can use this hook to target only the listings page.

    https://github.com/mistergiri/geodirectory/blob/master/geodirectory-templates/geodir-listing.php#L29

    As for the category you can use the shortcode to call.

    https://wpgeodirectory.com/docs/core-shortcodes/#ctp-cats

    The whole category output code can be found in geodir_cpt_categories_output function.

    https://github.com/mistergiri/geodirectory/blob/master/geodirectory-widgets/geodirectory_cpt_categories_widget.php#L315

    Hope that helps

    #380468

    Falk Meyer-Plate
    Free User
    Post count: 14

    Hey,

    I tried various things, but still things don’t work out. In my code above is this one line where it says:

    echo '<h3 style="padding:0px 15px 15px 15px;margin-top:-15px;">'.$customtitle.'<small> '.$taxonomies.'</small></h3>';

    so now I need to know what do I have to put behind the $taxonomies to get my current category on the details page.

    As you can see at the screenshot i am definitly talking about the details page and not the listings page ( /places/ ).

    My snippet works fine so far except the fact I am not able to get my current category displayed.

    Falk

    #380591

    Giri
    Expired Member
    Post count: 3155

    Detail page category and tags are coming from this function.

    geodir_action_details_taxonomies

    https://github.com/mistergiri/geodirectory/blob/master/geodirectory_template_actions.php#L1099

    You have to either call that function or create custom code by yourself.

    I would go with calling that function. Just place that function where you need those categories. It would print them. Keep in mind it will also print the tags. You may have to use CSS to hide the tags if you don’t need them.

    Thanks

    #383730

    Falk Meyer-Plate
    Free User
    Post count: 14

    Hey hey,

    this kinda worked for me, but can you guys hook me up how i can ether change or remove the “Place-Category:” before the actual category.

    Greetings
    Falk

    #383837

    Giri
    Expired Member
    Post count: 3155
    
    
    add_filter('geodir_details_taxonomies_output', 'geodir_details_taxonomies_output_custom', 10, 3);
    function geodir_details_taxonomies_output_custom($taxonomies, $post_type, $listing_label) {
    	$new_tax = array();
    	foreach ($taxonomies as $key => $tax) {
    		$label = geodir_ucwords($listing_label);
    		$tax = str_replace("$label Category:", "", $tax);
    		//$tax = str_replace("$label Tags:", "", $tax);
    		$new_tax[$key] = $tax;
    	}
    	return $new_tax;
    }
Viewing 8 posts - 1 through 8 (of 8 total)

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

Open Support Ticket