Calling shortcodes in new php file
This topic contains 13 replies, has 3 voices, and was last updated by David Sirius 7 years, 1 month ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
January 7, 2018 at 1:20 pm #411814
Hi All,
Quick basic question on using shortcodes: I understand that geodir shortcodes can be used by including them in wordpress pages. However, how do use them when building new pages from scratch?
I have created a new php file from scratch that I want to use as my start page. I have saved it under C:\MAMP\htdocs\wordpresswebsite\wp-content\themes\supreme-directory and used the following code in the html code where I want the shortcode to call the search:
<div> <?php echo do_shortcode(‘[gd_advanced_search]’); ?> </div>
but it doesnt do anything, the output is basically just blank. When I use just the shortcode
[gd_advanced_search]
then the php file will just return this as text output.
Does the file need to be moved in a specific folder or the code to be amended?
Would be great if someone could briefly help on how to use the shortcodes.
Many thanks in advance!
Best,
DavidJanuary 7, 2018 at 5:19 pm #411827Hello!
The support forums are for issues related to the installation or configuration of plugins, not customization of template files or plugin function.
As per our support policy
We provide GeoDirectory and its addons as are. We don’t provide customization services for them nor we support any 3rd Party customizations of our products. For customization we intend any html/css/php/js work that changes the way GeoDirectory and its addons look or function, in relation to the way we made GeoDirectory and its addons available to you.
https://wpgeodirectory.com/support-policy/
Related links:
https://wpgeodirectory.com/docs/customizing-geodirectory-templates/January 8, 2018 at 9:37 pm #411983Shortcodes are a general feature of WP, so would have expected there to be a solution how to use them in files (outside the WP pages). I did quite some research and typically the php shortcode I posted should work to call shortcodes but not for geodir. I dont think its practical to limit usage of the shortcodes to pages only created in the wordpress dashboard itself. Anyone serious in using the geodir plugin will build its own complementing pages from scratch. Anyway, I understand I wont get support on this here.
January 9, 2018 at 6:16 am #412021Hi David,
I’d like to chime in here. I’ve spoken with a developer and he mentioned that the code you’re using should work. However, could you please make sure that you’ve used the single “qoute” in the code correctly? Try the code below and see if it works.
<div> <?php echo do_shortcode('[gd_advanced_search]'); ?> </div>
Thanks!
January 9, 2018 at 9:45 pm #412124Hi Kor,
Really appreciate you chiming in and having liaised with a developer.
Yes, I corrected that afterwards and ended up trying this code after seeking advice outside the forum:
<?php define( 'WP_USE_THEMES', false ); require( './wp-load.php' ); echo do_shortcode('[gd_advanced_search]'); ?>
Unfortunately that didnt work either (and neither yours). I have also tested the file with a simple Hello World php code, which works, so it truly is somehow the shortcodes that cant be called.
If you have no further solution idea (?), I’d suggest I’ll provide you login details when my site is online and we’ll pick it up then. For the moment I have a (cumbersome) work around, whereby I create the code in Atom, then copy paste it in Thrive Architect (a website builder and installed plugin in my wordpress) and save it as a page.
January 10, 2018 at 6:03 am #412154Hi David,
Yes, it would be great if you could allow me to test the code directly on your site. We would need WP admin and FTP access. Please post the details here using the private reply option below.
January 16, 2018 at 9:46 pm #413029This reply has been marked as private.January 17, 2018 at 4:59 am #413077This reply has been marked as private.January 17, 2018 at 8:03 am #413089This reply has been marked as private.January 17, 2018 at 9:20 am #413094This reply has been marked as private.January 17, 2018 at 5:08 pm #413162This reply has been marked as private.January 17, 2018 at 9:59 pm #413201Hello!
The support forums are for issues related to the installation or configuration of plugins, not customization of template files or plugin function.
As per our support policy
We provide GeoDirectory and its addons as are. We don’t provide customization services for them nor we support any 3rd Party customizations of our products. For customization we intend any html/css/php/js work that changes the way GeoDirectory and its addons look or function, in relation to the way we made GeoDirectory and its addons available to you.
https://wpgeodirectory.com/support-policy/
Your question is related to general WordPress functionality which we do not support. If you are looking for code examples, you can find the use of shortcodes in templates within the Supreme Directory child theme home page and listings pages.
Related links:
https://wpgeodirectory.com/docs/customizing-geodirectory-templates/January 19, 2018 at 11:00 am #413440This reply has been marked as private.February 2, 2018 at 2:40 pm #415640I spoke to a developer who fixed it for me. The shortcode needs to be wrapped in a PHP code.
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket