Calling shortcodes in new php file

This topic contains 13 replies, has 3 voices, and was last updated by  David Sirius 6 years, 2 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #411814

    David Sirius
    Expired Member
    Post count: 163

    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,
    David

    #411827

    Alex Rollin
    Moderator
    Post count: 27815

    Hello!

    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/

    #411983

    David Sirius
    Expired Member
    Post count: 163

    Shortcodes 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.

    #412021

    Kor
    Moderator
    Post count: 16516

    Hi 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!

    #412124

    David Sirius
    Expired Member
    Post count: 163

    Hi 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.

    #412154

    Kor
    Moderator
    Post count: 16516

    Hi 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.

    #413029

    David Sirius
    Expired Member
    Post count: 163
    This reply has been marked as private.
    #413077

    Kor
    Moderator
    Post count: 16516
    This reply has been marked as private.
    #413089

    David Sirius
    Expired Member
    Post count: 163
    This reply has been marked as private.
    #413094

    Kor
    Moderator
    Post count: 16516
    This reply has been marked as private.
    #413162

    David Sirius
    Expired Member
    Post count: 163
    This reply has been marked as private.
    #413201

    Alex Rollin
    Moderator
    Post count: 27815

    Hello!

    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/

    #413440

    David Sirius
    Expired Member
    Post count: 163
    This reply has been marked as private.
    #415640

    David Sirius
    Expired Member
    Post count: 163

    I spoke to a developer who fixed it for me. The shortcode needs to be wrapped in a PHP code.

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