filtering neighborhoods in widget logic
This topic contains 13 replies, has 3 voices, and was last updated by Guust 5 years, 4 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: advertising, neighborhoods, widget logic
-
AuthorPosts
-
June 17, 2019 at 11:39 pm #493507
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
June 18, 2019 at 12:38 am #493509That 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.
ThanksJune 18, 2019 at 1:27 am #493512The 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
June 18, 2019 at 1:59 am #493519The 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?
ThanksJune 18, 2019 at 2:16 am #493520You 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.
June 18, 2019 at 4:17 pm #493628url 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
June 20, 2019 at 8:06 pm #494068Not 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
June 21, 2019 at 8:35 am #494134Hi 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
June 21, 2019 at 12:29 pm #494168I 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.June 21, 2019 at 1:46 pm #494185Hi 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) Usegd_widget_logic_post_neighborhood() == 'my-neighborhood-slug'
Kiran
June 21, 2019 at 4:22 pm #494205Thanx 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
June 22, 2019 at 12:27 am #494253Use step 2 in the widget logic settings:
gd_widget_logic_post_neighborhood() == 'center-city-east'
Thanks
June 23, 2019 at 10:27 pm #494361perfect…thanx
June 23, 2019 at 10:30 pm #494363You’re welcome 🙂
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket