Forum Replies Created
-
AuthorPosts
-
yogidevMember
Hi, I just found this post.
I am fairly new to php, and been searching around for a solution to why my functions stop working when I add the lib/init.php at the top.
For example, this code stops working:
// 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 tried including it within this block but still not working..
// 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' ); }
Any help much appreciated!
yogidevMemberI would really like to know this as well.
One of the reasons I went with Genesis is that I heard the support community was so strong!
This seems like a pretty fundamental thing that should be documented somewhere?What I am actually trying to achieve (that apparently requires adding the lib/init.php line) is implementing sidebars for a blog section within a child theme that does not use sidebars elsewhere.
Any pointers?
yogidevMemberI 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?
yogidevMemberOk 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!
yogidevMemberDefinitely 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' ); }
yogidevMemberThanks 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?
yogidevMemberAh I hadn't realised the description is a hidden option in admin menu area.
I managed to find this code which is working:
// Menu with Description class Menu_With_Description extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_repeat( " ", $depth ) : ''; $class_names = $value = ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ); $class_names = ' class="' . esc_attr( $class_names ) . '"'; $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>'; $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : ''; $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : ''; $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : ''; $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : ''; // get user defined attributes for thumbnail images $attr_defaults = array( 'class' => 'nav_thumb' , 'alt' => esc_attr( $item->attr_title ) , 'title' => esc_attr( $item->attr_title ) ); $attr = isset( $args->thumbnail_attr ) ? $args->thumbnail_attr : ''; $attr = wp_parse_args( $attr , $attr_defaults ); $item_output = $args->before; // thumbnail image output $item_output .= ( isset( $args->thumbnail_link ) && $args->thumbnail_link ) ? '<a' . $attributes . '>' : ''; $item_output .= apply_filters( 'menu_item_thumbnail' , ( isset( $args->thumbnail ) && $args->thumbnail ) ? get_the_post_thumbnail( $item->object_id , ( isset( $args->thumbnail_size ) ) ? $args->thumbnail_size : 'thumbnail' , $attr ) : '' , $item , $args , $depth ); $item_output .= ( isset( $args->thumbnail_link ) && $args->thumbnail_link ) ? '</a>' : ''; // menu link output $item_output .= '<a'. $attributes .'>'; $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after; // menu description output based on depth $item_output .= ( $args->desc_depth >= $depth ) ? '<br /><span class="sub">' . $item->description . '</span>' : ''; // close menu link anchor $item_output .= '</a>'; $item_output .= $args->after; $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } } add_filter( 'wp_nav_menu_args' , 'my_add_menu_descriptions' ); function my_add_menu_descriptions( $args ) { $args['walker'] = new Menu_With_Description; $args['desc_depth'] = 0; $args['thumbnail'] = true; $args['thumbnail_link'] = false; $args['thumbnail_size'] = 'nav_thumb'; $args['thumbnail_attr'] = array( 'class' => 'nav_thumb my_thumb' , 'alt' => 'test' , 'title' => 'test' ); return $args; }
yogidevMemberHi, thanks for the reply.
I looked up walker classes and I don't see how that could work.
Here is the site in development:
http://sulekhruparell.yanwhite.com/about/
Each item needs to have this kind of content:
<li><a> <em>About</em> <span>A bit about me</span> </a></li>
Is there a way to do that? It seems an extra field would need to appear in the admin menu area, which is why I just hardcoded it.
-
AuthorPosts