Shortcode or Hook for the Tag Filter in GD Listings?

This topic contains 4 replies, has 3 voices, and was last updated by  gaz36f 3 years, 12 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #541068

    gaz36f
    Expired Member
    Post count: 54

    I have a lot of articles based on food. In the sidebar, I have geodirectory listings relevant to the food item using the tag filter.

    However, I want to move to global sidebars (in Avada), so I want just one global sidebar for all food articles. Is it possible when filtering GD Listings to use some form of shortcode to extract the page title (i.e. in my case, the name of the food), and place it in the tag filter field.

    For example, at the moment I have a page entitled ‘Satay’. In the GD Listings, I use the Tag Filter ‘Satay’. It all works great! But, if I use a global sidebar, I need the Tag Filter to use whatever the article title is. I have tried %%page_title%% and [gd_post_title] in the Tag field, but neither work.

    I know this might not be possible, but if it is, could you please point me in the right direction.

    Best wishes, Gary

    #541072

    Guust
    Moderator
    Post count: 29970

    That would require your own customization. I’ll get the developers to have a look at your question too in case they have some pointers for you.

    Thanks

    #541075

    gaz36f
    Expired Member
    Post count: 54

    I suspected that but thought it was worth checking first. Thanks Guust. Best wishes, Gary

    #541330

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Gary,

    There is no option for this but u can use this filter to edit the query
    geodir_widget_listings_query_args

    Not tested but it might look something like this:

    
    
    add_filter('geodir_widget_listings_query_args','_my_tags_filter',10,2);
    	    function _my_tags_filter($query_args, $instance){
    
    		    if(!empty($query_args['post_type']) && is_singular('post') ){
    			    $tags = array('tag1','tag2','tag3');
    			    $tag_query = array(
    				    'taxonomy' => $query_args['post_type'] . '_tags',
    				    'field' => 'name',
    				    'terms' => $tags
    			    );
    			    $query_args['tax_query'] = array( $tag_query );
    		    }
    		    
    		    return $query_args;
    	    }

    In the above example, you would need to set the tags yourself, you could split the post title into an array of elements but it might be better to use the post tags?

    Stiofan

    #541572

    gaz36f
    Expired Member
    Post count: 54

    Thanks very much for this Stiofan. I gave it a go (and I included the tags in the array string) but couldn’t get it to work.

    No problem, I’ll just use the standard setting for each individual page. The only reason I wanted to be able to put this in a gloabl sidebar is to give myself options in the future for redesign/new customisations etc. Having individual pages (that will grow substantially over time) will be a pain to edit, but it’s not a huge problem.

    Thanks for trying. It would be nice if in the future we can use tags such as %%post_title%% in other areas of the site like we can in the address field for GD-Post Address.

    Best wishes, Gary

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

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

Open Support Ticket