Change Title Text for Category links on Detail page

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

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

Open Support Ticket
  • Author
    Posts
  • #19013

    mykidsdayout
    Free User
    Post count: 36

    Hi,

    I currently have a detail page that shows the categories of the Solicitor at the top of the page – at the moment, it reads “Solicitor Category” then shows all the linked categories (see attached screenshot)

    I want to change this text to read “Areas of Law” – can you tell me how to do this?

    Many thanks,
    Wes

    #19040

    Simone
    Expired Member
    Post count: 3515

    Hi Wes, what you can do, for the moment, is to edit the geodirectory_template_actions.php which in the geodirectory folder.
    Found this block of code:

    
    
    		if(!isset($listing_label)){$listing_label='';}
                            $taxonomies[$post_taxonomy] = wp_sprintf('%s: %l', ucwords($listing_label.' '. __('Category' , GEODIRECTORY_TEXTDOMAIN)), $links, (object)$terms);

    and change it to

    
    
    	if(!isset($listing_label)){$listing_label='';}
                            $taxonomies[$post_taxonomy] = wp_sprintf('%s: %l', ucwords( __('Areas of Law' , GEODIRECTORY_TEXTDOMAIN)), $links, (object)$terms);

    this,obviously, is a temporary fix.
    I think a function can be created, I will check this as soon as I will be home

    #19094

    mykidsdayout
    Free User
    Post count: 36

    Thanks Simone, that’s great, I can also add HTML to it to bold it to stand out.

    Cheers,
    Wes

    #19133

    Simone
    Expired Member
    Post count: 3515

    Ok, put this code inside the functions.php in your child theme and you will preserve your modifications in the future releases

    
    
    remove_action('geodir_details_main_content' , 'geodir_details_taxonomies', 10);
    									 
    									  add_action( 'geodir_details_main_content', 'geodir_category_custom',10 );
    									  function geodir_category_custom() {
    global $preview,$post;?>
    <p class="geodir_post_taxomomies clearfix">  
    <?php
    
    $taxonomies = array();
    //print_r($post) ;
    
    if($preview)
    {
    	$post_type = $post->listing_type;
    	$post_taxonomy  = 	$post_type.'category' ;
    	$post->$post_taxonomy = $post->post_category[$post_taxonomy ] ;
    }
    else
    {
    	$post_type = $post->post_type;
    	$post_taxonomy  = 	$post_type.'category' ;
    }
    //{	
    $post_type_info = get_post_type_object( $post_type );
    $listing_label = $post_type_info->labels->singular_name;
    
                        if(!empty($post->post_tags))
    					{
                           
                            if(taxonomy_exists($post_type.'_tags')):
                                $links = array();
                                $terms = array();
    							// to limit post tags
    							$post_tags = trim($post->post_tags,",");
    							$post_id = isset($post->ID) ? $post->ID : '';
    							$post_tags = apply_filters('geodir_action_details_post_tags', $post_tags, $post_id);
                               
    						    $post->post_tags = $post_tags;
    							$post_tags = explode(",",trim($post->post_tags,","));
                            	
    							foreach($post_tags as $post_term){
            						
    								/*
    								$post_term = trim($post_term);
    							   
    							    if($insert_term = term_exists( $post_term, $post_type.'_tags' )){
                                        $term = get_term_by( 'name', $post_term, $post_type.'_tags'); 
                                    }else{
                                        $insert_term = wp_insert_term($post_term, $post_type.'_tags');
                                         $term = get_term_by( 'name', $post_term, $post_type.'_tags');
                                    }	
                                    
                                    if(! is_wp_error( $term ))
                                    {	
                                        //$links[] = "<a href='" . esc_attr( get_tag_link($term->term_id) ) . "'>$term->name</a>";
    									// fix tag link on detail page
    									$links[] = "<a href='" . esc_attr( get_term_link($term->term_id, $term->taxonomy) ) . "'>$term->name</a>";
    									$terms[] = $term;
                                    }
    								*/
    								// fix slug creation order for tags & location
    								$post_term = trim($post_term);
    							   	
    								$priority_location = false;
    								if($insert_term = term_exists( $post_term, $post_type.'_tags' )){
                                        $term = get_term_by( 'name', $post_term, $post_type.'_tags'); 
                                    }else{
                                        $post_country = isset($_REQUEST['post_country']) && $_REQUEST['post_country']!='' ? $_REQUEST['post_country'] : NULL;
    									$post_region = isset($_REQUEST['post_region']) && $_REQUEST['post_region']!='' ? $_REQUEST['post_region'] : NULL;
    									$post_city = isset($_REQUEST['post_city']) && $_REQUEST['post_city']!='' ? $_REQUEST['post_city'] : NULL;
    									$match_country = $post_country && sanitize_title($post_term) == sanitize_title($post_country) ? true : false;
    									$match_region = $post_region && sanitize_title($post_term) == sanitize_title($post_region) ? true : false;
    									$match_city = $post_city && sanitize_title($post_term) == sanitize_title($post_city) ? true : false;
    								    if ($match_country || $match_region || $match_city) {
    										$priority_location = true;
    										$term = get_term_by( 'name', $post_term, $post_type.'_tags');
    									} else {
    								    	$insert_term = wp_insert_term($post_term, $post_type.'_tags');
                                        	$term = get_term_by( 'name', $post_term, $post_type.'_tags');
    									}
                                    }	
                                    
                                    if(! is_wp_error( $term ))
                                    {	
                                        //$links[] = "<a href='" . esc_attr( get_tag_link($term->term_id) ) . "'>$term->name</a>";
    									// fix tag link on detail page
    									if ($priority_location) {
    										$links[] = "<a href=''>$post_term</a>";
    									} else {
    										$links[] = "<a href='" . esc_attr( get_term_link($term->term_id, $term->taxonomy) ) . "'>$term->name</a>";
    									}
    									$terms[] = $term;
                                    }
    								//
                                }
                            	if(!isset($listing_label)){$listing_label='';}
                                $taxonomies[$post_type.'_tags'] = wp_sprintf('%s: %l', ucwords($listing_label.' '. __('Tags' , GEODIRECTORY_TEXTDOMAIN) ), $links, (object)$terms);
                            endif;	
                            
                        }
                        
    					if(!empty($post->$post_taxonomy))
    					{
    					
    						$links = array();
                            $terms = array();
    						$post_term = explode(",",trim($post->$post_taxonomy,","));
    						
    						$post_term = array_unique($post_term);
    						if(!empty($post_term)){
    							foreach($post_term as $post_term){
    								$post_term = trim($post_term);
    								
    								if($post_term != ''):	
    									$term = get_term_by( 'id', $post_term, $post_taxonomy); 
    								  
    									$links[] = "<a href='".esc_attr( get_term_link($term,$post_taxonomy) ) . "'>$term->name</a>";
    									$terms[] = $term;
    								endif;
    							}
    						}
    						
    						if(!isset($listing_label)){$listing_label='';}
                            $taxonomies[$post_taxonomy] = wp_sprintf('%s: %l', ucwords( __('Area of Laws' , GEODIRECTORY_TEXTDOMAIN)), $links, (object)$terms);
                            
                        }
                        
                        
                        if(isset($taxonomies[$post_taxonomy])){ echo '<span class="geodir-category">' . $taxonomies[$post_taxonomy] . '</span>';	}	
    										
    										if(isset($taxonomies[$post_type.'_tags']))		
                        echo '<span class="geodir-tags">' . $taxonomies[$post_type.'_tags'] . '</span>';	
    
    ?> </p> <?php } 
    
    #19134

    Simone
    Expired Member
    Post count: 3515

    for your convenience, I’ve just added a file

    #19184

    mykidsdayout
    Free User
    Post count: 36

    Cheers Simone!! 🙂

    #51963

    Paolo
    Site Admin
    Post count: 31206

    There is tiny mistake in the code above.

    Please find correct code below for future refernces:

    
    
    remove_action('geodir_details_main_content', 'geodir_action_details_taxonomies', 40);
    
    									 
    									  add_action( 'geodir_details_main_content', 'geodir_category_custom',40 );
    									  function geodir_category_custom() {
    global $preview,$post;?>
    <p class="geodir_post_taxomomies clearfix">  
    <?php
    
    $taxonomies = array();
    //print_r($post) ;
    
    if($preview)
    {
    	$post_type = $post->listing_type;
    	$post_taxonomy  = 	$post_type.'category' ;
    	$post->$post_taxonomy = $post->post_category[$post_taxonomy ] ;
    }
    else
    {
    	$post_type = $post->post_type;
    	$post_taxonomy  = 	$post_type.'category' ;
    }
    //{	
    $post_type_info = get_post_type_object( $post_type );
    $listing_label = $post_type_info->labels->singular_name;
    
                        if(!empty($post->post_tags))
    					{
                           
                            if(taxonomy_exists($post_type.'_tags')):
                                $links = array();
                                $terms = array();
    							// to limit post tags
    							$post_tags = trim($post->post_tags,",");
    							$post_id = isset($post->ID) ? $post->ID : '';
    							$post_tags = apply_filters('geodir_action_details_post_tags', $post_tags, $post_id);
                               
    						    $post->post_tags = $post_tags;
    							$post_tags = explode(",",trim($post->post_tags,","));
                            	
    							foreach($post_tags as $post_term){
            						
    								/*
    								$post_term = trim($post_term);
    							   
    							    if($insert_term = term_exists( $post_term, $post_type.'_tags' )){
                                        $term = get_term_by( 'name', $post_term, $post_type.'_tags'); 
                                    }else{
                                        $insert_term = wp_insert_term($post_term, $post_type.'_tags');
                                         $term = get_term_by( 'name', $post_term, $post_type.'_tags');
                                    }	
                                    
                                    if(! is_wp_error( $term ))
                                    {	
                                        //$links[] = "<a href='" . esc_attr( get_tag_link($term->term_id) ) . "'>$term->name</a>";
    									// fix tag link on detail page
    									$links[] = "<a href='" . esc_attr( get_term_link($term->term_id, $term->taxonomy) ) . "'>$term->name</a>";
    									$terms[] = $term;
                                    }
    								*/
    								// fix slug creation order for tags & location
    								$post_term = trim($post_term);
    							   	
    								$priority_location = false;
    								if($insert_term = term_exists( $post_term, $post_type.'_tags' )){
                                        $term = get_term_by( 'name', $post_term, $post_type.'_tags'); 
                                    }else{
                                        $post_country = isset($_REQUEST['post_country']) && $_REQUEST['post_country']!='' ? $_REQUEST['post_country'] : NULL;
    									$post_region = isset($_REQUEST['post_region']) && $_REQUEST['post_region']!='' ? $_REQUEST['post_region'] : NULL;
    									$post_city = isset($_REQUEST['post_city']) && $_REQUEST['post_city']!='' ? $_REQUEST['post_city'] : NULL;
    									$match_country = $post_country && sanitize_title($post_term) == sanitize_title($post_country) ? true : false;
    									$match_region = $post_region && sanitize_title($post_term) == sanitize_title($post_region) ? true : false;
    									$match_city = $post_city && sanitize_title($post_term) == sanitize_title($post_city) ? true : false;
    								    if ($match_country || $match_region || $match_city) {
    										$priority_location = true;
    										$term = get_term_by( 'name', $post_term, $post_type.'_tags');
    									} else {
    								    	$insert_term = wp_insert_term($post_term, $post_type.'_tags');
                                        	$term = get_term_by( 'name', $post_term, $post_type.'_tags');
    									}
                                    }	
                                    
                                    if(! is_wp_error( $term ))
                                    {	
                                        //$links[] = "<a href='" . esc_attr( get_tag_link($term->term_id) ) . "'>$term->name</a>";
    									// fix tag link on detail page
    									if ($priority_location) {
    										$links[] = "<a href=''>$post_term</a>";
    									} else {
    										$links[] = "<a href='" . esc_attr( get_term_link($term->term_id, $term->taxonomy) ) . "'>$term->name</a>";
    									}
    									$terms[] = $term;
                                    }
    								//
                                }
                            	if(!isset($listing_label)){$listing_label='';}
                                $taxonomies[$post_type.'_tags'] = wp_sprintf('%s: %l', ucwords($listing_label.' '. __('Tags' , GEODIRECTORY_TEXTDOMAIN) ), $links, (object)$terms);
                            endif;	
                            
                        }
                        
    					if(!empty($post->$post_taxonomy))
    					{
    					
    						$links = array();
                            $terms = array();
    						$post_term = explode(",",trim($post->$post_taxonomy,","));
    						
    						$post_term = array_unique($post_term);
    						if(!empty($post_term)){
    							foreach($post_term as $post_term){
    								$post_term = trim($post_term);
    								
    								if($post_term != ''):	
    									$term = get_term_by( 'id', $post_term, $post_taxonomy); 
    								  
    									$links[] = "<a href='".esc_attr( get_term_link($term,$post_taxonomy) ) . "'>$term->name</a>";
    									$terms[] = $term;
    								endif;
    							}
    						}
    						
    						if(!isset($listing_label)){$listing_label='';}
                            $taxonomies[$post_taxonomy] = wp_sprintf('%s: %l', ucwords( __('Area of Laws' , GEODIRECTORY_TEXTDOMAIN)), $links, (object)$terms);
                            
                        }
                        
                        
                        if(isset($taxonomies[$post_taxonomy])){ echo '<span class="geodir-category">' . $taxonomies[$post_taxonomy] . '</span>';	}	
    										
    										if(isset($taxonomies[$post_type.'_tags']))		
                        echo '<span class="geodir-tags">' . $taxonomies[$post_type.'_tags'] . '</span>';	
    
    ?> </p> <?php } 
    

    Thank you

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

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

Open Support Ticket