Banner on top
This topic contains 12 replies, has 5 voices, and was last updated by Paolo 6 years ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
November 21, 2018 at 2:48 pm #455383
Thanks for the great support so far!
Here is something we are trying to achieve:
– suppose there are regular “places” in the system
– another custom post type for “banners” where the user can upload his banner together with his company infoBoth places and banners have the same categories (corresponding to each other, they are not the same as the system doesn’t allow that)
We would like to display said banners (one on the top, rotating) for specific categories of places (i.e. if there are entries with banner for that category we will display a random one). My questions are:
– what is the best approach to inset a banner (or anything) on the top of all possible listings (like GD Home, search results, etc) – is it by adding a shortcode defined by us (but I don’t see a page for “All Places” may be this is just an interna template?) or os there a hook that would allow us to insert HTML before every listing (home, search, locations etc)?
– what is geodir_ function to get the current category for the search result currently displaying
– what is geodir_ function to retrieve all entries for specific post type and for specific category?
Thank you in advance.
November 21, 2018 at 6:36 pm #455420Hi,
there is no way to do something similar without some custom code.
I asked to the developers to have a look at your question and point you in the right direction.
Thanks for your patience.
November 21, 2018 at 7:19 pm #455422It would definitely require some custom code.
In GDv1 you could use hooks to insert it, in GDv2 you could use a shortcode if you make one.Stiofan
November 21, 2018 at 9:18 pm #455435Thanks but can you point me to the right:
– the hook to insert above the search results for v2
– the two functions we need a) to retrieve all data for specific custom type and category and b) to catch the current category for the current page where the code is running. It’s kind of hard to locate these in the docs as they are pretty big (if one doesn’t know the exact function names it’s hard to guess what they should be)Is it OK to install v2 in a production site – is it stable enough?
November 24, 2018 at 7:29 pm #455786Any advice on my question above?
November 25, 2018 at 11:03 am #455836We don’t do customization in the forums but your post has been flagged for the developers who will try to point you in the right direction, but at this time the focus is on making all the addons compatible for release.
November 26, 2018 at 5:18 am #455904Hello,
– the hook to insert above the search results for v2
There are two hooks, that you can use to insert content before searched results.
1)
do_action('geodir_before_listing_listview')
will add content before
<ul>
tag.
20
do_action( 'geodir_before_listing_post_listview' )
will add content in
<ul>
tag before
<li>
loop.
a) to retrieve all data for specific custom type and category
You can get help from this on how to retrieve custom post types posts using taxonomy filter https://wordpress.stackexchange.com/questions/66219/list-all-posts-in-custom-post-type-by-taxonomy
b) to catch the current category for the current page where the code is running.
You can use function
get_queried_object()
to retrieve all the searched vars for current page.
Kiran
December 4, 2018 at 5:38 pm #457113Thanks geodir_before_listing_listview() may be will work with one exception – you are using it absolutely the same way in
– geodirectory-templates/listing-listview.php
– geodirectory-templates/widget-listing-listview.phpwhich means if we add something using that action it will appear where we would like and at the sime time at the sidebar where for example “Latest Places” appear. I don’t see an easy way to distinguish the two calls so to show something only at the page body.. any ideas?
Is there an action to add content only in the page body before the listings (preferably even BEFORE the dropdown to chose the view type – list/grid 2/grid 3 etc).
Do you have some kind of documentation/reference for the useful actions (I saw the full list of all functions in the php files which is not very useful). Thank you in advance for you help
December 5, 2018 at 8:24 am #457178Hello,
I don’t see an easy way to distinguish the two calls so to show something only at the page body.. any ideas?
Use any one of following conditions to distinguish
if ( isset( $widget_listings ) ) { // geodirectory-templates/widget-listing-listview.php } else { // geodirectory-templates/listing-listview.php }
OR
global $geodir_is_widget_listing; if ( $geodir_is_widget_listing ) { // geodirectory-templates/widget-listing-listview.php } else { // geodirectory-templates/listing-listview.php }
Is there an action to add content only in the page body before the listings (preferably even BEFORE the dropdown to chose the view type – list/grid 2/grid 3 etc).
Use hook do_action( ‘geodir_before_listing’ ); and use priority 99. Ex: add_action( ‘geodir_before_listing’, ‘gd_snippet_before_list_view_select’, 99 );
Do you have some kind of documentation/reference for the useful actions (I saw the full list of all functions in the php files which is not very useful).
Please check this: https://wpgeodirectory.com/codex/codex/
Thanks,
KiranDecember 5, 2018 at 3:05 pm #457213Thanks, but..
I already tried to use $widget_listings but it seems it is not a global variable – when used in functions.php it is not available which means it can’t be used to distinguish the cases. Is there any way to access it trough another global variable or object?
Thanks for the geodir_before_listing() suggestion. Which comes to the doc – I already know the provided link but this was the doc I mentioned in my previous question – havint 850 functions in a paginated format is really useless to find out something that we are looking for, unless we browse manually trough all the pages and click on every function to see what it does…..
December 5, 2018 at 4:10 pm #457225Hi Alex,
did you try Kiran’s second suggestion?
global $geodir_is_widget_listing; if ( $geodir_is_widget_listing ) { // geodirectory-templates/widget-listing-listview.php } else { // geodirectory-templates/listing-listview.php }
I’m sorry, but we don’t provide detailed documentation about actions and filters. That’s part of customizing the plugin.
Thanks
December 5, 2018 at 4:50 pm #457234Yes $geodir_is_widget_listing is working OK, thanks.
One last question – while geodir_before_listing() works well and inserts before the “view type” dropdown, it works for searches, but this actions is not executed at the main page (gd_home). Is there a different action for that page or there is no action to insert before everything there? Thanks
December 5, 2018 at 4:53 pm #457235Hi Alex,
in geodirectory/geodirectory-templates
you will find all templates and you just need to open them to read the code and find the actions.
Customization is beyond support.
Thanks
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket