Modern Portfolio

Community Forums Forums General Discussion Modern Portfolio

This topic is: resolved

This topic contains 5 replies, has 2 voices, and was last updated by  SimplyAA 1 year ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #67424

    SimplyAA
    Participant
    Post count: 67

    I am using the Modern Portfolio theme. I wanted each page to have a unique “About” widget so I created a new widget. For example on this page: http://angelaandrews.me/dolphins/ I am using the dolphin template I created. The widget works great but I now want to display the page content after and can’t seem to figure it out.

    I’m sure this is something simple but whatever I try doesn’t work. I have this:

    <?php
    /**
     * Controls the dolphin page output.
     */
    
    /*Template Name: Dolphin Page*/
    
    add_action( 'wp_enqueue_scripts', 'mp_enqueue_scripts' );
    /**
     * Enqueue Scripts
     */
    function mp_enqueue_scripts() {
    
    	if ( is_active_sidebar( 'about-dolphins' ) ) {
    		wp_enqueue_script( 'scrollTo', get_stylesheet_directory_uri() . '/js/jquery.scrollTo.min.js', array( 'jquery' ), '1.4.5-beta', true );
    		wp_enqueue_script( 'localScroll', get_stylesheet_directory_uri() . '/js/jquery.localScroll.min.js', array( 'scrollTo' ), '1.2.8b', true );
    		wp_enqueue_script( 'scroll', get_stylesheet_directory_uri() . '/js/scroll.js', array( 'localScroll' ), '', true );
    	}
    }
    
    add_action( 'genesis_meta', 'mp_home_genesis_meta' );
    /**
     * Add widget support for homepage. If no widgets active, display the default loop.
     *
     */
    function mp_home_genesis_meta() {
    
    	if ( is_active_sidebar( 'about-dolphins' )  ) {
    
    		// Force content-sidebar layout setting
    		add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
    
    		// Add mp-home body class
    		add_filter( 'body_class', 'mp_body_class' );
    		function mp_body_class( $classes ) {
    			$classes[] = 'mp-home';
    			return $classes;
    		}
    
    		// Remove the navigation menus
    		remove_action( 'genesis_after_header', 'genesis_do_nav' );
    		remove_action( 'genesis_after_header', 'genesis_do_subnav' );
    
    		// Remove the default Genesis loop
    		remove_action( 'genesis_loop', 'genesis_do_loop' );
    
    		// Add homepage widgets
    		add_action( 'genesis_loop', 'mp_homepage_widgets' );
    
    	}
    
    }
    
    function mp_homepage_widgets() {
    
    	genesis_widget_area( 'about-dolphins', array(
    		'before' => '<div id="about-dolphins"><div class="wrap">',
    		'after' => '</div></div>',
    	) );
    
    }
    
    genesis();
    ?>

    I tried taking out the “remove default genesis loop” section above but all I get is the content of the page, not styled, and no “About” widget.

    Would appreciate any help. Thank you


    http://http//www.angelaanadrews.me
    #67597

    Sridhar Katakam
    Participant
    Post count: 1049

    Do you want to add a widget section above content sidebar wrap on static Pages?


    #67677

    SimplyAA
    Participant
    Post count: 67

    If that would be easiest. How can I lit the widget to a specific page?


    #67822

    Sridhar Katakam
    Participant
    Post count: 1049

    Add this in functions.php:

    genesis_register_sidebar( array(
    	'id'				=> 'pages_about',
    	'name'			=> __( 'Pages About', 'mp' ),
    	'description'	=> __( 'This is the About section for Pages', 'mp' ),
    ) );
    
    add_action ( 'genesis_before_content_sidebar_wrap', 'sk_pages_about_section' );
    function sk_pages_about_section() {
    
    	if ( is_page() ) {
    
    		genesis_widget_area( 'pages_about', array(
    			'before' => '<div id="pages-about"><div class="wrap">',
    			'after' => '</div></div>',
    		) );
    
    	}
    
    }

    and this in style.css:

    #pages-about {
    	margin-bottom: 3rem;
    	line-height: 1.625;
    }

    Now drag widgets into ‘Pages About’ sidebar. You can limit what widget appears on what Page using a plugin like Widget Logic.


    #67903

    SimplyAA
    Participant
    Post count: 67

    I’ve added a widget (different than above)

    // Register About Page Intro widget
    genesis_register_sidebar( array(
    'id'	=> 'about-intro',
    'name'	=> __( 'About Intro', 'mp' ),
    'description'	=> __( 'This is the intro section of about page.', 'mp' ),
    ) );
     
    // Hook about intro to about page only
    add_action( 'genesis_before_content_sidebar_wrap', 'about_intro', 9 );
    function about_intro() {
    if ( is_page('about-angela') && is_active_sidebar( 'about-intro' ) ) {
    echo '<div class="about-intro"><div class="wrap">';
    dynamic_sidebar( 'about-intro' );
    echo '</div></div>';
    }
    }

    It seems to work okay except it’s not going all the way across the page like I want it. It should look like the home page one here: http://angelaandrews.me/. Do you know how I can get to go across full length of the page?


    #67905

    SimplyAA
    Participant
    Post count: 67

    I just figured it out: I needed to change my hook from:

    genesis_before_content_sidebar_wrap

    to:
    genesis_after_header

    Thanks for your help.


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.