- This topic has 3 replies, 2 voices, and was last updated 11 years ago by Sanjip Shah.
-
AuthorPosts
-
November 12, 2013 at 8:54 am #5083PetrichorParticipant
I have Attitude Pro 1.2 with a Child Theme here: http://injestfestival.com/
I’ve added your code to the child’s functions.php to have post titles in the breadcrumbs bar and to add the child_services widget, so that the services widgets’ titles are clickable. I’ve included that code below. But first, this is the type of error I get when navigating around dashboard, which makes editing impossible unless I temporarily disable the child’s functions.php file (I’ve replaced text with “xxx” in case it’s sensitive info.)Warning: Cannot modify header information – headers already sent by (output started at /home/xxx/public_html/injestfestival.com/wp-content/themes/attitude-pro-child/functions.php:117) in /home/xxx/public_html/injestfestival.com/wp-login.php on line 409
Warning: Cannot modify header information – headers already sent by (output started at /home/xxx/public_html/injestfestival.com/wp-content/themes/attitude-pro-child/functions.php:117) in /home/xxx/public_html/injestfestival.com/wp-login.php on line 421
Warning: Cannot modify header information – headers already sent by (output started at /home/xxx/public_html/injestfestival.com/wp-content/themes/attitude-pro-child/functions.php:117) in /home/xxx/public_html/injestfestival.com/wp-includes/pluggable.php on line 698
etc.
——————————————-
<?php add_action( 'widgets_init', 'attitude_child_widgets_init'); /** * Function to register the widget areas(sidebar) and widgets. */ function attitude_child_widgets_init() { // Registering widgets register_widget( "attitude_child_service_widget" ); } /** * Widget for business layout that shows selected page content,title and featured image. * Construct the widget. * i.e. Name, description and control options. */ class attitude_child_service_widget extends WP_Widget { function attitude_child_service_widget() { $widget_ops = array( 'classname' => 'widget_service', 'description' => __( 'Display Services( Business Layout )', 'attitude' ) ); $control_ops = array( 'width' => 200, 'height' =>250 ); parent::WP_Widget( false, $name = __( 'Theme Horse: Services_Child', 'attitude' ), $widget_ops, $control_ops); } function form( $instance ) { for ( $i=0; $i<6; $i++ ) { $var = 'page_id'.$i; $defaults[$var] = ''; } $instance = wp_parse_args( (array) $instance, $defaults ); for ( $i=0; $i<6; $i++ ) { $var = 'page_id'.$i; $var = absint( $instance[ $var ] ); } ?> <?php for( $i=0; $i<6; $i++) { ?> <p> <label for="<?php echo $this->get_field_id( key($defaults) ); ?>"><?php _e( 'Page', 'attitude' ); ?>:</label> <?php wp_dropdown_pages( array( 'show_option_none' =>' ','name' => $this->get_field_name( key($defaults) ), 'selected' => $instance[key($defaults)] ) ); ?> </p> <?php next( $defaults );// forwards the key of $defaults array } } function update( $new_instance, $old_instance ) { $instance = $old_instance; for( $i=0; $i<6; $i++ ) { $var = 'page_id'.$i; $instance[ $var] = absint( $new_instance[ $var ] ); } return $instance; } function widget( $args, $instance ) { extract( $args ); extract( $instance ); global $post; $page_array = array(); for( $i=0; $i<6; $i++ ) { $var = 'page_id'.$i; $page_id = isset( $instance[ $var ] ) ? $instance[ $var ] : ''; if( !empty( $page_id ) ) array_push( $page_array, $page_id );// Push the page id in the array } $get_featured_pages = new WP_Query( array( 'posts_per_page' => -1, 'post_type' => array( 'page' ), 'post__in' => $page_array, 'orderby' => 'post__in' ) ); echo $before_widget; ?> <div class="column clearfix"> <?php $j = 1; while( $get_featured_pages->have_posts() ):$get_featured_pages->the_post(); $page_title = get_the_title(); if( $j % 2 == 1 && $j > 1 ) { $service_class = "one-third clearfix-half"; } elseif ( $j % 3 == 1 && $j > 1 ) { $service_class = "one-third clearfix-third"; } else { $service_class = "one-third"; } ?> <div class="<?php echo $service_class; ?>"> <div class="service-item clearfix"> <?php if ( has_post_thumbnail() ) { echo'<div class="service-icon">'.get_the_post_thumbnail( $post->ID, 'icon' ).'</div>'; } ?> <h3 class="service-title"><a style="color: #555;" title="<?php the_title_attribute(); ?>" href="<?php the_permalink(); ?>"><?php echo $page_title; ?></a></h3> </div><!-- .service-item --> <article> <?php the_excerpt(); ?> </article> <a class="more-link" title="<?php the_title_attribute(); ?>" href="<?php the_permalink(); ?>"><?php _e( 'Read more','attitude' ); ?></a> </div><!-- .one-third --> <?php $j++; ?> <?php endwhile; // Reset Post Data wp_reset_query(); ?> </div><!-- .column --> <?php echo $after_widget; } } ?> <?php function attitude_header_title() { if( is_archive() ) { $attitude_header_title = single_cat_title( '', FALSE ); } elseif( is_404() ) { $attitude_header_title = __( 'Page NOT Found', 'attitude' ); } elseif( is_search() ) { $attitude_header_title = __( 'Search Results', 'attitude' ); } elseif( is_page_template() ) { $attitude_header_title = get_the_title(); } elseif( is_page() ) { $attitude_header_title = get_the_title(); } else { $attitude_header_title = ''; } return $attitude_header_title; } function attitude_theloop_for_page() { global $post; if( have_posts() ) { while( have_posts() ) { the_post(); do_action( 'attitude_before_post' ); ?> <section id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <article> <?php do_action( 'attitude_before_post_header' ); ?> <?php do_action( 'attitude_after_post_header' ); ?> <?php do_action( 'attitude_before_post_content' ); ?> <div class="entry-content clearfix"> <?php the_content(); ?> <?php wp_link_pages( array( 'before' => '<div style="clear: both;"></div><div class="pagination clearfix">'.__( 'Pages:', 'attitude' ), 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>', 'pagelink' => '%', 'echo' => 1 ) ); ?> </div> <?php do_action( 'attitude_after_post_content' ); do_action( 'attitude_before_comments_template' ); comments_template(); do_action ( 'attitude_after_comments_template' ); ?> </article> </section> <?php do_action( 'attitude_after_post' ); } } else { ?> <h1 class="entry-title"><?php _e( 'No Posts Found.', 'attitude' ); ?></h1> <?php } } ?>
November 16, 2013 at 4:16 am #5181Sanjip ShahParticipant@Petrichor This can be caused due to many possible things. Please go through links in this search and see if any helps you
https://www.google.com.np/search?q=cannot+modify+header+information+on+child+theme&ie=utf-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&gws_rd=cr&ei=O_CGUoeiMcqnrgffi4GwAgNovember 17, 2013 at 8:47 am #5200PetrichorParticipantThanks!
I ended up switching the order of functions in my child’s functions.php, and now it all works without the error.
Here’s the code I use in child’s functions.php to put page titles in the breadcrumbs bar and to create a services_child widget that allows the titles of the services to be clickable:<?php function attitude_header_title() { if( is_archive() ) { $attitude_header_title = single_cat_title( '', FALSE ); } elseif( is_404() ) { $attitude_header_title = __( 'Page NOT Found', 'attitude' ); } elseif( is_search() ) { $attitude_header_title = __( 'Search Results', 'attitude' ); } elseif( is_page_template() ) { $attitude_header_title = get_the_title(); } elseif( is_page() ) { $attitude_header_title = get_the_title(); } else { $attitude_header_title = ''; } return $attitude_header_title; } function attitude_theloop_for_page() { global $post; if( have_posts() ) { while( have_posts() ) { the_post(); do_action( 'attitude_before_post' ); ?> <section id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <article> <?php do_action( 'attitude_before_post_header' ); ?> <?php do_action( 'attitude_after_post_header' ); ?> <?php do_action( 'attitude_before_post_content' ); ?> <div class="entry-content clearfix"> <?php the_content(); ?> <?php wp_link_pages( array( 'before' => '<div style="clear: both;"></div><div class="pagination clearfix">'.__( 'Pages:', 'attitude' ), 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>', 'pagelink' => '%', 'echo' => 1 ) ); ?> </div> <?php do_action( 'attitude_after_post_content' ); do_action( 'attitude_before_comments_template' ); comments_template(); do_action ( 'attitude_after_comments_template' ); ?> </article> </section> <?php do_action( 'attitude_after_post' ); } } else { ?> <h1 class="entry-title"><?php _e( 'No Posts Found.', 'attitude' ); ?></h1> <?php } } ?>
November 18, 2013 at 2:37 pm #5222Sanjip ShahParticipant@Petrichor Okay. Great and thanks for sharing.
-
AuthorPosts
- You must be logged in to reply to this topic.