Home.php vs template.php: shortcode help

Community Forums Forums General Discussion Home.php vs template.php: shortcode help

This topic is: not resolved

This topic contains 8 replies, has 3 voices, and was last updated by  jjaycallejas 1 year, 1 month ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #20428

    jjaycallejas
    Participant
    Post count: 15

    Hello,

    Does anyone know why the following code doesn’t work on my home.php? http://hope-amundson.com/

    <code>

    <?php
    /* Layout
    ———————————————————— */
    // Remove the post info function
    remove_action( ‘genesis_before_post_content’, ‘genesis_post_info’ );

    // Remove the post meta function
    remove_action( ‘genesis_after_post_content’, ‘genesis_post_meta’ );

    // Remove the content area
    remove_action( ‘genesis_post_content’, ‘genesis_do_post_content’ );

    // Remove Post Title
    remove_action (‘genesis_post_title’,'genesis_do_post_title’);

    // Custom Loop
    remove_action(‘genesis_loop’, ‘genesis_do_loop’);
    add_action( ‘genesis_loop’, ‘custom_do_loop’ , 5 );
    function custom_do_loop() {
    echo do_shortcode(‘[new_royalslider id="1"]‘);
    }
    genesis();
    ?>

    </code>

    I tested it out on a template (portfolio.php) for the sample page and it seems fine http://hope-amundson.com/sample-page/

    <code>

    <?php
    /*
    Template Name: Portfolio
    */

    /* Layout
    ———————————————————— */
    // Remove the post info function
    remove_action( ‘genesis_before_post_content’, ‘genesis_post_info’ );

    // Remove the post meta function
    remove_action( ‘genesis_after_post_content’, ‘genesis_post_meta’ );

    // Remove the content area
    remove_action( ‘genesis_post_content’, ‘genesis_do_post_content’ );

    // Remove Post Title
    remove_action (‘genesis_post_title’,'genesis_do_post_title’);

    // Custom Loop
    remove_action(‘genesis_loop’, ‘genesis_do_loop’);
    add_action( ‘genesis_loop’, ‘custom_do_loop’ , 5 );
    function custom_do_loop() {
    echo do_shortcode(‘[new_royalslider id="1"]‘);
    }
    genesis();
    ?>

    </code>

    #21451

    cehwitham
    Participant
    Post count: 396

    Are you sure the home.php template is actually being used? This will only be used if Settings > Reading is set for the home page to display your latest posts.

    Try renaming home.php to front-page.php and see if it works then.


    Twitter: cehwitham Web: cehwitham.com

    #21498

    jjaycallejas
    Participant
    Post count: 15

    Thanks. I guess I didn’t really state my issue. Sorry about that. The page loads correctly, except that shortcode I echoed doesn’t work on the home.php/front-page.php. Not sure what I’m doing wrong there. The shortcode works fine when I use it in the page editor (hence it working in the template named: Portfolio.

     

    Any other ideas?

    #21529

    cehwitham
    Participant
    Post count: 396

    Could you add the shortcode to a text widget and then add it into a widget area on the homepage?

    This article shows you how to use shortcodes in text widgets by filtering them.

    http://digwp.com/2010/03/shortcodes-in-widgets/


    Twitter: cehwitham Web: cehwitham.com

    #23094

    jjaycallejas
    Participant
    Post count: 15

    Thanks but that didn’t work out either. I get the same non-effect. I believe the jquery isn’t being called correctly. I’m using a shortcode for a slider gallery. I know that the shortcode “works” since it’s not printing the words [new_royalslider id="1"] onto the page but merely showing links to the images within the slider.

    Does anyone know how to get the slider part to work? It’s grabbing the images correctly but not showing the slider itself

    #23150

    jjaycallejas
    Participant
    Post count: 15

    This is a really odd situation. I haven’t resolved the initial issue of the shortcode not working but have had success in another way. For some reason, the shortcode only works when it’s placed in the_content().

     

    I guess if anyone has anything to chime in, feel free.

    #23183

    surefirewebserv
    Participant
    Post count: 67

    Looks like this line of code is on the inside page and not the home page:

    If it’s a plugin, I would double check the settings.


    SureFireWebServices.com | Genesis Tuts and More
    Genesis Theme Starter Kit | It’s Free

    #23188

    jjaycallejas
    Participant
    Post count: 15

    Thanks but I’m not sure what you mean by It’s on the inside page? I actually changed my read settings to static homepage and selected a page. However I’d rather have the shortcode on a front-page.php instead of pulling in the_content() of a page.

    Do you have any idea how to get the shortcode to work outside of the_content() or genesis_post_content()? the echo_shortcode simply outputs the image link instead of a slider.

    I know the plugin works because the shortcode functions properly inside the_content() or genesis_post_content() but not outside of it.

    #23198

    jjaycallejas
    Participant
    Post count: 15

    Well, this was stupid. Haha. Thanks surefirewebserv. It was in the settings the whole time! For some odd reason, there’s options to only display on pots, homepage, or all pages. This was probably the most time I’ve spent on a non-issue ever!

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.