Home › Forums › Calendar Products › Events Calendar PRO › Issues placing widget PHP code on homepage
- This topic has 12 replies, 3 voices, and was last updated 11 years, 7 months ago by
Barry.
-
AuthorPosts
-
September 4, 2014 at 1:29 pm #722541
jcoen
ParticipantI’m trying to get what is normally the sidebar widget to appear as part of the homepage of my site (http://bneiakivala.org/). You’ll see it in the bottom left of the page. Or at least you should. It kind of works but the issue is instead of displaying events from the calendar, it’s displaying content from the photo gallery section. Must be something regarding the code which I just grabbed from the views–>widgets–>list-widget.php file and placed it into my themes index.php. How can I get to make this work?
September 4, 2014 at 4:56 pm #722974Barry
MemberHi!
I’m not completely clear on the setup you are using:
Must be something regarding the code which I just grabbed from the views–>widgets–>list-widget.php file and placed it into my themes index.php.
So this isn’t actually an issue with our widget as such but rather the result of some code you stripped out and embedded elsewhere? If so, would it be possible to use the widget itself instead?
September 8, 2014 at 9:21 am #730926jcoen
ParticipantWell, that’s what I want to do. Just simply place the widget inside of the homepage inside of the index.php template. Not a sidebar. So could I use the widget on the homepage that way?
September 8, 2014 at 9:26 am #730939Barry
MemberYes, you definitely can.
One approach is to set up a new sidebar area and use it only within your homepage (please see codex.wordpress.org/Function_Reference/register_sidebar for details), another would be to make use of the_widget() function:
the_widget( 'TribeEventsAdvancedListWidget' );Does that help?
September 8, 2014 at 6:46 pm #731907jcoen
ParticipantI tried the_widget approach but nothing appeared on my page.
September 9, 2014 at 6:50 am #733057Barry
MemberHow about adding a new sidebar region and embedding the widget that way?
September 9, 2014 at 7:26 am #733142crowesnestcreative
ParticipantI’m trying to build the sidebar, and here’s my code so far that I put in my widgets.php file:
function theme_slug_widgets_init() {
register_sidebar($upcomingevents = array(
‘name’ => __( ‘Upcoming-Events’, ‘upcoming-events’ ),
‘id’ => ‘upcoming-events-sidebar’,
‘description’ => __( ‘This is where all the upcoming events will be displayed.’),
‘before_title’ => ‘<h1>’,
‘after_title’ => ‘</h1>’,
) );
}
add_action( ‘widgets_init’, ‘theme_slug_widgets_init’ );I added the new sidebar to my homepage using this: <?php register_sidebar( $upcomingevents ); ?>
Any idea as to what I’m doing wrong? Here’s my site: http://behmsauction.crowesnestcreative.com
September 9, 2014 at 7:47 am #733177Barry
MemberHi!
Please do bear in mind that, while we can point you in the right direction, building out customizations such as adding extra sidebars to your theme is, ultimately, something you need to drive forward.
It is also greatly appreciated if wherever possible you create a new thread of your own rather than entering someone else’s, even if it covers something that seems very similar in nature to your own problem 🙂
Do check out the documentation for WordPress’s dynamic_sidebar() function, though.
Good luck!
September 9, 2014 at 8:26 am #733312jcoen
ParticipantWell, I was king of hoping to avoid the need to do that with one line of PHP code.
September 9, 2014 at 11:18 am #733625jcoen
ParticipantSo I tried the sidebar approach as well. No difference. Nothing appears. I did create the new sidebar in functions.php and it did show up under Appearance–>Widgets in my wp-admin. So I know that worked. It just won’t show up on the homepage. Here’s the code I’m using. The sidebar is called Tribe Sidebar:
<?php $args = array(
‘name’ => __( ‘Tribe Sidebar’, ‘theme-slug’ ),
‘id’ => ‘tribe-events’,
‘description’ => ‘Widgets in this area will be shown on the homepage for the Tribe Events Calendar Pro.’,
‘class’ => ‘tribe-events’,
‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘‘,
‘before_title’ => ‘<h2 class=”widgettitle”>’,
‘after_title’ => ‘</h2>’ ); ?>September 9, 2014 at 11:53 am #733678Barry
MemberOK – unfortunately the forum does not currently do a great job handling code (sometimes it even strips bits and pieces out) so it’s best to share snippets via Gist, Pastebin or some other similar service 🙂
Within the code you did share I think I’m looking at a set of args used when the sidebar is registered – can you share the code from your actual theme template where you are embedding this?
September 10, 2014 at 9:39 am #735680jcoen
ParticipantYes, I can. Here’s the PasteBin with the entire index.php file:
http://pastebin.com/GjB2L8E5September 10, 2014 at 10:23 am #735823Barry
MemberHi jcoen,
So on lines 30-38 you define an array called $args but best I can tell you’re not actually doing anything with your new array:
<?php $args = array( 'name' => __( 'Tribe Sidebar', 'theme-slug' ), 'id' => 'tribe-events', 'description' => 'Widgets in this area will be shown on the homepage for the Tribe Events Calendar Pro.', 'class' => 'tribe-events', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>' ); ?>What I’d recommend here is reviewing the above linked resources (which I’ve repeated here) which can guide you through various ways to achieve your goals:
If you’re unfamiliar with PHP or still encounter difficulties I think the best approach may be to approach either your theme vendor for further support or perhaps even consider engaging a suitable designer/developer to assist – and we can certainly provide you with a list of folks we recommend if you email us at pro (at) tri (dot) be – but really I think you require a little more support than we can realistically offer here on the forums.
Since we can’t do a lot more on this occasion I will go ahead and close this thread, but if there are any other issues we can help with please do create a new thread and one of the team will be more than happy to do what they can.
Thanks again – and good luck 🙂
-
AuthorPosts
- The topic ‘Issues placing widget PHP code on homepage’ is closed to new replies.
