filtering neighborhoods in widget logic

This topic contains 13 replies, has 3 voices, and was last updated by  Guust 5 years, 6 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #493507

    joe purcell
    Expired Member
    Post count: 97

    I was told the following:

    This code looks for city or region or country or neighborhood slugs, change “philadelphia” to any part of a location slug:

    So I changed ‘philadelphia’ to ‘center city east’ so it looks like
    in_array(‘center city east’, geodir_get_current_location_terms(‘query_vars’))

    but the widget did not display on a center city east detail page

    Is my widget logic correct??

    Thanx

    #493509

    Guust
    Moderator
    Post count: 29970

    That doesn’t look like the correct part of the URL.
    Navigate to the neighborhood page and copy the part of the URL exactly, including hyphens.
    Thanks

    #493512

    joe purcell
    Expired Member
    Post count: 97

    The neighborhood is only in the listing page url (image) not in the details url (image)
    But I did not have the hyphens in the widget logic, added hyphen but did not change the outcome (image)

    Thanx

    #493519

    Guust
    Moderator
    Post count: 29970

    The widget will only show where that part is in the slug.
    There don’t seem to be any listings in that neighborhood?
    https://greenbaxna.com/location/united-states/pennsylvania/philadelphia/center-city-east/
    Can you give us a URL of a detail page for a listing in that neighborhood?
    Thanks

    #493520

    Guust
    Moderator
    Post count: 29970

    You need to add the neighbourhood to the slug for the detail pages. The widget logic code cannot work if the part of the slug is not there.

    #493628

    joe purcell
    Expired Member
    Post count: 97

    url for cpt – attraction neighborhood – center city east https://greenbaxna.com/attraction/pennsylvania/philadelphia/historic/independence-hall/

    Not sure what or how to add slug to detail page??

    can widget logic filter by zip code??

    Thanx

    #494068

    joe purcell
    Expired Member
    Post count: 97

    Not sure what or how to add slug to detail page?? Does it need to be added to the page in the image attached?? If yes, how do you determine what the slug reference is?? gd_neighborhoods ??

    can widget logic filter by zip code??

    Thanx

    #494134

    Kiran
    Moderator
    Post count: 7069

    Hi Joe,

    Not sure what or how to add slug to detail page??

    If you want to add neighborhood slug to detail page url then it is not possible.
    Let me know if this is not you asked about.

    can widget logic filter by zip code??

    No it is not possible to apply logic filter by zip.

    Kiran

    #494168

    joe purcell
    Expired Member
    Post count: 97

    I am attempting to utilize Neighborhoods in the widget logic and it not working/filtering.

    Guust wrote me:
    The widget will only show where that part is in the slug.
    There don’t seem to be any listings in that neighborhood?
    https://greenbaxna.com/location/united-states/pennsylvania/philadelphia/center-city-east/
    Can you give us a URL of a detail page for a listing in that neighborhood?

    and I replied:
    url for cpt – attraction neighborhood – center city east https://greenbaxna.com/attraction/pennsylvania/philadelphia/historic/independence-hall/

    Guust replied:
    You need to add the neighbourhood to the slug for the detail pages. The widget logic code cannot work if the part of the slug is not there.

    #494185

    Kiran
    Moderator
    Post count: 7069

    Hi Joe,

    Neighborhood slug only applicable to archive pages urls like location, categories etc.

    Use following PHP snippet to achieve what you asked.

    
    
    /**
     * Usage: gd_widget_logic_post_neighborhood() == 'my-neighborhood-slug'
     */
    function gd_widget_logic_post_neighborhood() {
    	global $gd_post;
    
    	$neighborhood = '';
    	if ( ! empty( $gd_post ) && ! empty( $gd_post->neighbourhood ) && ( geodir_is_page( 'detail' ) || geodir_is_page( 'preview' ) ) ) {
    		$neighborhood = $gd_post->neighbourhood;
    	}
    
    	return $neighborhood;
    }

    Steps:
    1) Put above snippet in theme/child theme functions.php file or add via any PHP Snippets plugin
    2) Use

    gd_widget_logic_post_neighborhood() == 'my-neighborhood-slug'

    Kiran

    #494205

    joe purcell
    Expired Member
    Post count: 97

    Thanx Kiran…

    I am attempting to use widget logic to filter which advertisement displays based on the city or neighborhood

    I understand step one completely but step two not so much.

    Where do I use that, in the widget logic of the sidebar widget??

    Thanx

    #494253

    Guust
    Moderator
    Post count: 29970

    Use step 2 in the widget logic settings:

    gd_widget_logic_post_neighborhood() == 'center-city-east'

    Thanks

    #494361

    joe purcell
    Expired Member
    Post count: 97

    perfect…thanx

    #494363

    Guust
    Moderator
    Post count: 29970

    You’re welcome 🙂

Viewing 14 posts - 1 through 14 (of 14 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