Forum Replies Created
-
AuthorPosts
-
April 8, 2015 at 10:00 pm in reply to: Problems creating custom page with custom right sidebar #23880shawnhoffmanParticipant
Well – one “solution” was to use either the “Easy Custom Sidebars” or the “Custom Sidebars” plugins (the 2nd one being a bit more powerful). That is enough to “solve” my issue, but I would still like to know how to do it manually and think that it MUST be possible since a plugin is only doing the manual work automatically.
So, I guess there is no ‘hurry’ on this, but if anyone feels like answering me just for the sake of learning, that would be awesome and I will give you a virtual high five and wink.
-Shawn
shawnhoffmanParticipantYes, of course. I put that code in the child theme’s functions.php. Glad to know it’s a good solution and I hope it helps someone else.
shawnhoffmanParticipantI had the same problem and figured out a solution with this:
// Remove old copyright text add_action( 'init' , 'mh_remove_copy' , 15 ); function mh_remove_copy() { remove_action( 'attitude_footer', 'attitude_footer_info', 30 ); } // Add my own copyright text add_action( 'attitude_footer' , 'mh_footer_info' , 30 ); function mh_footer_info() { $output = '<div class="copyright">'.'Copyright © '.attitude_the_year().' ' .attitude_site_link().''.'</div><!-- .copyright -->'; echo do_shortcode( $output ); }
So really you only have to change
[the-year] [site-link]
into
'.attitude_the_year().' ' .attitude_site_link().'
And it works for me — but the pros can tell me if that is a good way or not, maybe there is some flaw to it?
shawnhoffmanParticipantI’m sorry- which part do I need to remove? — I remove it from the above code?
It looks like the code in content-extensions.php
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' ); ?> <header class="entry-header"> <h2 class="entry-title"> <?php the_title(); ?> </h2><!-- .entry-title --> </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 } } endif;
So I just paste that code into functions.php of the child theme and remove:
<header class="entry-header"> <h2 class="entry-title"> <?php the_title(); ?> </h2><!-- .entry-title --> </header>
I think? Do I need to remove more? less? Or do I need to even include all of that code?
shawnhoffmanParticipantOf the child theme- that is the best place to do it, right?
Now I just want to eliminate the old title, and only have the new one in the grey area.
shawnhoffmanParticipantOkay- So I put this in functions.php
if ( ! function_exists( 'attitude_header_title' ) ) : /** * Show the title in header * * @since Attitude 1.0 */ 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; } endif;
Was that more work that needed?
Also – can I take out the title now where it was previously? I want it only in the grey area, and not where it was previously. Now it is in both places.
August 23, 2013 at 12:14 am in reply to: Possible to have a second business page (with different widget pages)?? #3506shawnhoffmanParticipantWow that was such a long process of trying, failing, changing and repeating, but with almost no experience with php and never having used functions.php or anything with child themes I think I finally figured it out. Please let me know if I “overcorrected” or did something wrong or still need to do something. Seems to be functioning at this point.
For the page_template_business2.php, it was sufficient to only put it in the child theme directory.
For the other two, I created functions.php in the child theme and added the necessary code below. My questions that remain:
1) Was it necessary to remove the action, and add a new one, or could I have added to the existing action? From what I read, it was necessary to delete the old stuff, but then copy them into the new action in order to maintain the other native widgets.
2) Was it necessary to name the function _child or could I have not done that?
3) Was there any use for that require_once line?? Cause I deleted it and don’t see where it would be necessary.
Here’s the code from functions.php and I obviously deleted all the other junk from my previous posts.
<?php remove_action( 'widgets_init', 'attitude_widgets_init' ); function attitude_child_widgets_init() { // Registering main left sidebar register_sidebar( array( 'name' => __( 'Left Sidebar', 'attitude' ), 'id' => 'attitude_left_sidebar', 'description' => __( 'Shows widgets at Left side.', 'attitude' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) ); // Registering main right sidebar register_sidebar( array( 'name' => __( 'Right Sidebar', 'attitude' ), 'id' => 'attitude_right_sidebar', 'description' => __( 'Shows widgets at Right side.', 'attitude' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) ); // Registering Business Page template sidebar register_sidebar( array( 'name' => __( 'Business Page Sidebar', 'attitude' ), 'id' => 'attitude_business_page_sidebar', 'description' => __( 'Shows widgets on Business Page Template. Sutiable widget: Theme Horse: Featured widget, Theme Horse: Testimonial, Theme Horse: Services', 'attitude' ), 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h1 class="widget-title">', 'after_title' => '</h1>' ) ); // Registering Business2 Page template sidebar register_sidebar( array( 'name' => __( 'Business2 Page Sidebar', 'attitude' ), 'id' => 'attitude_business2_page_sidebar', 'description' => __( 'Shows widgets on Business2 Page Template. Sutiable widget: Theme Horse: Featured widget, Theme Horse: Testimonial, Theme Horse: Services', 'attitude' ), 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h1 class="widget-title">', 'after_title' => '</h1>' ) ); // Registering contact Page sidebar register_sidebar( array( 'name' => __( 'Contact Page Sidebar', 'attitude' ), 'id' => 'attitude_contact_page_sidebar', 'description' => __( 'Shows widgets on Contact Page Template.', 'attitude' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) ); // Registering footer sidebar register_sidebar( array( 'name' => __( 'Footer Sidebar', 'attitude' ), 'id' => 'attitude_footer_sidebar', 'description' => __( 'Shows widgets at footer.', 'attitude' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) ); // Registering widgets register_widget( "attitude_custom_tag_widget" ); register_widget( "attitude_service_widget" ); register_widget( "attitude_recent_work_widget" ); register_widget( "attitude_Widget_Testimonial" ); } add_action( 'widgets_init', 'attitude_child_widgets_init' ); add_action( 'attitude_business2_template_content', 'attitude_business2_template_widgetized_content', 10 ); /** * Displays the widget as contents */ function attitude_business2_template_widgetized_content() { ?> <div id="content"> <?php if( is_active_sidebar( 'attitude_business2_page_sidebar' ) ) { // Calling the footer sidebar if it exists. if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( 'attitude_business2_page_sidebar' ) ): endif; } ?> </div><!-- #content --> <?php } ?>
August 22, 2013 at 10:33 pm in reply to: Possible to have a second business page (with different widget pages)?? #3505shawnhoffmanParticipantWell, I think that require line doesn’t go in the style.css file – but rather is php … but I still don’t know where/how to do it 🙁
August 22, 2013 at 9:10 pm in reply to: Possible to have a second business page (with different widget pages)?? #3503shawnhoffmanParticipantUfff now I am having problems…
You can see what it looks like now at the same site…
I put the files in their respective folders, which seems right…
However, I am not sure if the files
a) need to be edited more to reflect “attitude-child” and not “attitude”
b) need to be the whole file with my additions, or only the new additionsHELP?!?! Thank you!!
August 22, 2013 at 8:07 pm in reply to: Possible to have a second business page (with different widget pages)?? #3501shawnhoffmanParticipantSo, I am learning about child themes – and I See to add:
require_once( get_stylesheet_directory() . '/my_included_file.php' );
To the style.css of the child theme.
In this case, it will be page-template-business2.php, attitude_widgets.php, & content-extensions.php
Do I need to put them in the corresponding subdirectories, or just into the theme directory.
i.e. do the files need to be/attitude-child/page-template-business2.php
/attitude-child/library/widgets/attitude_widgets.php
/attitude-child/library/structure/content-extensions.phpor simply
/attitude-child/page-template-business2.php
/attitude-child/attitude_widgets.php
/attitude-child/content-extensions.phpThanks!
August 22, 2013 at 7:34 pm in reply to: Possible to have a second business page (with different widget pages)?? #3499shawnhoffmanParticipantCool! Thanks!
shawnhoffmanParticipantOkay – thanks. I suppose that goes for any edits to the theme css…
Will that be the same for editing other files in the theme as well, like in my other recent post about a 2nd business page?
(Still learning WP). Thanks.shawnhoffmanParticipantAlso solved!
in styles.css I changed:
.slogan-wrap .slogan { font-size: 24px; line-height: 30px; color: #fff; <strong>width: 75%;</strong> float: left;
From 80 to 75. Probably because of the length of my slogan… Fixed now! Hope it helps somebody else.
August 21, 2013 at 3:15 am in reply to: Possible to have a second business page (with different widget pages)?? #3441shawnhoffmanParticipantWell – I think I figured it out. I will describe how I did it, and others can comment if that sounds right, if I am going to run into problems, etc…
- Copy of page-template-business.php and change file name to page-template-business2.php
- Copy code in attitude_widgets.php relative to ‘Registering Business Page template sidebar’
- Same thing with content-extensions.php
–> Change all instances of ‘business’ – to ‘business2’
–> Change all instances of ‘business’ – to ‘business2’ in the copied section
Seems to be working (http://shawn.mcctraduccion.com).
You can see that if you click on ‘What ShawnCanDo’ > ‘Student Visa Processes’ you are taken to a page where you see the 3 services (NIE/TIE, NIE renewal, autorizacion…). Which is from the 2nd widget, and different from the services on the home page.
If anybody can see why this would be a problem, or if there are any other files that I would need to edit, PLEASE TELL ME! If not, I hope this is useful for somebody else!
-Shawn
shawnhoffmanParticipantSorry forgot the site – its http://shawn.mcctraduccion.com
-
AuthorPosts