Community Forums › Forums › Archived Forums › General Discussion › Trouble registering sidebar
Tagged: Sidebar
- This topic has 8 replies, 3 voices, and was last updated 9 years, 9 months ago by
yogidev.
-
AuthorPosts
-
March 12, 2015 at 7:05 am #144154
yogidev
MemberHi I am trying to register a sidebar and getting this error message:
Fatal error: Call to undefined function genesis_register_sidebar()
I've tried code from 3 different places and it happens with all of them.
Here is one example of code I tried:
genesis_register_sidebar( array( 'id' => 'custom-sidebar',//name this whatever makes sense 'name' => 'Custom Sidebar', 'description' => 'This is a custom sidebar that were adding to Genesis', ) ); add_action( 'get_header', 'child_sidebar_swap' ); function child_sidebar_swap() { if( is_single() ) { remove_action( 'genesis_after_content', 'genesis_get_sidebar' ); add_action( 'genesis_after_content', 'child_get_single_sidebar' ); } } function child_get_single_sidebar() { get_sidebar( 'custom-sidebar' ); }
What I actually want to do is have a sidebar appear on my blog page and individual posts.
I also tried 3 different plugins and none of them worked either.
I am expecting to be able to add a few lines of code in my child theme's functions.php that shows primary sidebar only on that 1 page and all posts.
March 12, 2015 at 7:27 am #144156DTHkelly
MemberThe code from this tutorial works.
March 12, 2015 at 7:29 am #144157DTHkelly
MemberMore reference:
http://carlomanf.id.au/run-unique-sidebars/March 12, 2015 at 8:11 am #144161yogidev
MemberThanks Kelly.
I pasted:
/** Register widget areas */ genesis_register_sidebar( array( 'id' => 'cta-1', 'name' => __( 'Call to Action #1', 'mp' ), 'description' => __( 'This is the call to action section.', 'mp' ), ) ); genesis_register_sidebar( array( 'id' => 'cta-2', 'name' => __( 'Call to Action #2', 'mp' ), 'description' => __( 'This is the call to action section.', 'mp' ), ) ); genesis_register_sidebar( array( 'id' => 'cta-3', 'name' => __( 'Call to Action #3', 'mp' ), 'description' => __( 'This is the call to action section.', 'mp' ), ) ); genesis_register_sidebar( array( 'id' => 'cta-4', 'name' => __( 'Call to Action #4', 'mp' ), 'description' => __( 'This is the call to action section.', 'mp' ), ) );
followed by:
/** * Add CTA widget support for site. If widget not active, don't display * */ function mp_cta_genesis() { // Don't display the CTA on the home page, since it's built into the MP theme if ( is_home() ) { return; } // If it's the About page, display CTA #1 elseif ( is_page( 'about' ) ) { genesis_widget_area( 'cta-1', array( 'before' => '<div id="cta"><div class="wrap">', 'after' => '</div></div>', ) ); } // If it's a page with ID 101 or 102 or any page within my Portfolio CPT // Display CTA #2 elseif ( is_page( array(101,102) ) || ('portfolio' == get_post_type() ) ) { genesis_widget_area( 'cta-2', array( 'before' => '<div id="cta"><div class="wrap">', 'after' => '</div></div>', ) ); } // If it's the Contact page, display CTA #3 elseif ( is_page('contact') ) { genesis_widget_area( 'cta-3', array( 'before' => '<div id="cta"><div class="wrap">', 'after' => '</div></div>', ) ); } // If all else fails and none of the above conditions are met, display CTA #4 else { genesis_widget_area( 'cta-4', array( 'before' => '<div id="cta"><div id="enews" class="wrap">', 'after' => '</div></div>', ) ); } }
in functions.php
I get Fatal error: Call to undefined function genesis_register_sidebar()
This code:
http://carlomanf.id.au/run-unique-sidebars/didnt generate any errors but it didnt output a sidebar either (after I added some widgets to the new items).
The page source didnt show any sidebar references anywhere either.
What am I missing?
March 12, 2015 at 10:03 am #144196Genesis Developer
MemberAre you included this code at top of your functions.php file?
// Start the engine require_once( get_template_directory() . '/lib/init.php' );
Also you installed the genesis framework? ( It is stupid question but I am asking)
March 12, 2015 at 10:06 am #144197yogidev
MemberDefinitely Genesis yes,
I'm using this:
// Start the engine the other way add_action( 'genesis_setup','genesischild_theme_setup', 15 ); function genesischild_theme_setup() { //Add support for HTML5 markup add_theme_support( 'html5' ); //Add viewport metatag add_theme_support( 'genesis-responsive-viewport' ); //Add 3 footer widgets add_theme_support( 'genesis-footer-widgets', 4 ); //Add support for custom background add_theme_support( 'custom-background' ); }
March 12, 2015 at 10:27 am #144203Genesis Developer
MemberThat's different things. you need to add this line at top
require_once( get_template_directory() . '/lib/init.php' );
March 13, 2015 at 12:32 pm #144312yogidev
MemberOk so I added that and now the page loads but without my custom functions.
For example.
// Remove page titles //* Remove page title for a specific page (requires HTML5 theme support) //* Change '28' to your page id add_action( 'get_header', 'child_remove_page_titles' ); function child_remove_page_titles() { if ( is_page( ) ) { remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); } }
I am now getting page title and my defined h1s output on the page.
Lots of other custom stuff in functions.php is not working.The sidebars still dont appear either!
May 1, 2015 at 3:46 am #149700yogidev
MemberI had to put this on hold for a while working on other projects.
Could you explain why the functions dont work after adding lib/init.php at the top?
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.