Community Forums › Forums › Archived Forums › General Discussion › Home.php vs template.php: shortcode help
Tagged: Custom Post Type
- This topic has 8 replies, 3 voices, and was last updated 11 years, 11 months ago by
jjaycallejas.
-
AuthorPosts
-
February 14, 2013 at 6:18 pm #20428
jjaycallejas
MemberHello,
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>
February 19, 2013 at 3:05 pm #21451cehwitham
MemberAre 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
February 19, 2013 at 5:18 pm #21498jjaycallejas
MemberThanks. 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?
February 19, 2013 at 6:48 pm #21529cehwitham
MemberCould 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
February 27, 2013 at 9:13 am #23094jjaycallejas
MemberThanks 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
February 27, 2013 at 1:50 pm #23150jjaycallejas
MemberThis 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.
February 27, 2013 at 3:34 pm #23183surefirewebserv
MemberLooks 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 FreeFebruary 27, 2013 at 3:46 pm #23188jjaycallejas
MemberThanks 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.
February 27, 2013 at 4:28 pm #23198jjaycallejas
MemberWell, 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!
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.