Community Forums › Forums › Archived Forums › Design Tips and Tricks › Modern Portfolio "About" widget
Tagged: widget
- This topic has 20 replies, 3 voices, and was last updated 11 years, 6 months ago by
IamRob.
-
AuthorPosts
-
July 19, 2013 at 3:18 am #51411
IamRob
MemberHi all,
I'd like to add the "about" widget inside the other page of this template. Anyone can help me with it?Thank you,
RobJuly 19, 2013 at 8:54 am #51433Brad Dalton
ParticipantPlease clarify.
inside the other page of this template
Do you want to add a widget inside a page you create for your about page rather than the home page?
July 21, 2013 at 4:46 am #51687IamRob
MemberExactly! I'd like to have the same widget even inside a page I've created, not only in the home page.
July 21, 2013 at 11:34 am #51709Brad Dalton
ParticipantTry this: You can change the name of the page slug or use the page i.d rather than the page slug in the code.
if ( is_page('007') && is_active_sidebar('page-widget' ) ) {
This example uses contact-page in the conditional tag.
if ( is_page('about-page') && is_active_sidebar( 'page-widget' ) ) {
Please copy this code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++.
https://gist.github.com/braddalton/6049246
July 21, 2013 at 1:00 pm #51717IamRob
MemberI tried but it doesn't works. The widget doesn't appear inside the page.
July 21, 2013 at 1:25 pm #51719Brad Dalton
ParticipantYou can change the hook.
Try the genesis_after_post_title hook
So change this line:
add_action( 'genesis_before_content_sidebar_wrap', 'wpsites_page_widget', 5 );
To this:
add_action( 'genesis_after_post_title', 'wpsites_page_widget', 5 );
If you where wanting a widget in the middle of the content area, you would need to use a plugin like, widgets on pages. or shortcode any widget.
July 21, 2013 at 1:39 pm #51722IamRob
MemberYes, I did.
This is the website: http://www.italianluxuryweddings.com/wordpress/
I'd like to have in every page the same header. The header with the logo and the image is the widget "ABOUT" of the Modern Portfolio Child Theme. I simply putted the logo inside the widget and changed the background of the #about section inside the style.css
This is the code I added to the function.php page, but it doesn't works.
genesis_register_sidebar( array(
'id' => 'page-widget',
'name' => __( 'Page Widget', 'wpsitesdotnet' ),
'description' => __( 'Contact page widget.', 'wpsitesdotnet' )
) );
/**
* @author Brad Dalton - WP Sites
* @example http://wp.me/p1lTu0-9Jr
*/
add_action( 'genesis_after_header', 'wpsites_page_widget', 5 );
function wpsites_page_widget() {
if ( is_page('about-me') && is_active_sidebar( 'page-widget' ) ) {
echo '<div class="widget">';
dynamic_sidebar( 'page-widget' );
echo '</div><!-- end .page-widget -->';}
}July 21, 2013 at 1:46 pm #51724ModernMuse
MemberRob,
What is the page name? That could be the problem. In Brad's example, it's /about-me/.
Double-check this line in the functions file and edit with your own page name:
if ( is_page('about-page') && is_active_sidebar( 'page-widget' ) ) {
July 21, 2013 at 1:49 pm #51726ModernMuse
MemberSorry, Brad's example is actually /about-page/. Hopefully you understand what I meant... 😉
July 21, 2013 at 1:50 pm #51727IamRob
MemberThe page is: http://www.italianluxuryweddings.com/wordpress/about-me
I think I wrote the right name inside the code.
July 21, 2013 at 2:06 pm #51731ModernMuse
MemberNot sure why your code doesn't work.
The code below (with your page name of /about-me/) should add a custom widget directly below the header / above the nav bar:
Link: https://gist.github.com/ModernMuse/f4a3c3ac4d5494a85518
July 21, 2013 at 2:06 pm #51732Brad Dalton
ParticipantYou are right Rob. My bad. The WordPress Codex is wrong (Proof) and i should have tested the code.
Please remove the single quotes/apostrophes from the page slug and it will work. Tested locally on your theme.
Otherwise, please use the page i.d for your about me page. Its a bit sensitive to page names and slugs however i'd's always seem to work.
Sincere apologies and love your site. Amazing images.
if ( is_page(about-me) && is_active_sidebar( 'page-widget') ) {
Or this:
if ( is_page('278') && is_active_sidebar( 'page-widget' ) ) {
Might also need to try this with and without the single quotes/apostrophes.
July 21, 2013 at 2:11 pm #51733IamRob
Membermmm there's something wrong:
"Parse error: syntax error, unexpected T_STRING in /web/htdocs/www.italianluxuryweddings.com/home/wordpress/wp-content/themes/modern-portfolio/functions.php on line 81"
I can test online, this theme it's just an example. When it will works I'll replace the theme in my real domain 🙂
Thank you 🙂
July 21, 2013 at 2:13 pm #51734ModernMuse
MemberAh...see, I learned something too. I was wondering why the original code didn't work since everything looked fine.
When I tested Rob's code, I got a bunch of syntax errors. Now I know why.
Hope you got it all fixed, Rob! Brad, you're a rock star. 🙂
July 21, 2013 at 2:29 pm #51739Brad Dalton
ParticipantIts probably just the apostrophes gave turned around when you copy from embedded code. Always copy using the view raw link and paste at the end of the functions.php file using a text editor like Notepad++.
I did notice that this causes errors when copying from within the Gist and pasting here using the shortcodes for PHP.
The code is tested and works so i'm sure you'll fix it very easily.
Thanks @ModernMuseNV
July 21, 2013 at 2:32 pm #51741IamRob
MemberYes, I fixed the error but I'm probably did something wrong cause I can't see the widget in the about page (id page 278). If the code works as you said I should see the widget I thought.
July 21, 2013 at 2:40 pm #51745Brad Dalton
ParticipantJuly 21, 2013 at 2:47 pm #51748IamRob
MemberJuly 21, 2013 at 2:47 pm #51749Brad Dalton
ParticipantTo use the same header on every page, you can install a plugin or use this CSS code:
.page-template-default #header { background: url("images/header-page.png") no-repeat scroll 0 0 transparent; }
July 21, 2013 at 2:50 pm #51752Brad Dalton
ParticipantPlease mark this as resolved and start another post for your question. This way it will get resolved quicker.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.