Reply To: Adding Portfolio Inside Custom Post

Homepage Community Forums Epik Theme Support Adding Portfolio Inside Custom Post Reply To: Adding Portfolio Inside Custom Post

#15440
hoolamonster
Customer

    So I have it working correctly I just need to work the styling. If anyone see’s a way to improve this please let me know.

    <?php
    
    // Template Name: My Lander
    
    function my_custom_field() {
    // Image container
    	echo '<div class="feature-container"><div class="wrap"><div class="feature-image-container-1">';
    		$test = get_post_meta( get_the_ID(), 'main_title', true );
    			if( $test ) {
    				echo '<div class="wrap"><div class="feature-title">';
    					$content = get_post_meta( get_the_ID(), 'main_title' , true );			
    					echo '<h1>' . ( $content ) . '</h1>';
    				}
    					echo '</div></div>';
    	echo '</div></div></div>';
    // END Image container
    // Nav Container
    	echo '<div class="s-nav-wrap">';
    		$test = get_post_meta( get_the_ID(), 'sticky_nav', true );
    			if( $test ) {
    					$content = get_post_meta( get_the_ID(), 'sticky_nav' , true );			
    					echo '<ul id="s-nav">' . ( $content ) . '</ul>';
    				}
    	echo '</div>';
    // END Nav Container		
    // Image container
    	echo '<div class="feature-container"><div class="wrap"><div class="feature-image-container-2">';
    		$test = get_post_meta( get_the_ID(), 'main_title', true );
    			if( $test ) {
    				echo '<div class="wrap"><div class="feature-title-2">';
    					$content = get_post_meta( get_the_ID(), 'main_title' , true );			
    					echo '<h1>' . ( $content ) . '</h1>';
    				}
    					echo '</div></div>';
    	echo '</div></div></div>';
    // END Image container
    }
    add_action( 'my_custom_fields_area', 'my_custom_field' );
    
    //Adds Page Content
    add_action( 'genesis_before_loop', 'epik_do_portfolio_content' );
    function epik_do_portfolio_content() {
        echo '<div class="entry-content entry-portfolio" itemprop="text">' . get_post()->post_content . '</div>';
    }
    
    // Loads prettyPhoto scripts
    add_action( 'get_header', 'prettyPhoto_scripts' );
    function prettyPhoto_scripts() {	
        wp_enqueue_script( 'prettyPhoto-min', CHILD_URL.'/lib/prettyPhoto/js/jquery-1.6.1.min.js' );
        wp_enqueue_style( 'prettyPhoto-css', CHILD_URL.'/lib/prettyPhoto/css/prettyPhoto.css' );
        wp_enqueue_script( 'prettyPhoto-js', CHILD_URL.'/lib/prettyPhoto/js/jquery.prettyPhoto.js' );
    }
    
    // Adds javascript below footer
    add_action( 'genesis_after_footer', 'prettyPhoto_javascript' );
    function prettyPhoto_javascript() { ?>
    	<script type="text/javascript" charset="utf-8">
    	  $(document).ready(function(){
    	    $("a[rel^='prettyPhoto']").prettyPhoto();
    	  });
    	</script>
    <?php
    }
    		
    // Force layout to full-width-content
    add_filter( 'genesis_site_layout', '__genesis_return_full_width_content' );
    
    // Adds "portfolio" and "gallery clearfix" classes to every post
    add_filter( 'post_class', 'portfolio_post_class' );
    function portfolio_post_class( $classes ) {
        $classes[] = 'portfolio';
        $classes[] = 'gallery clearfix';
        return $classes;
    }
    
    add_filter( 'excerpt_more', 'portfolio_read_more_link' );
    add_filter( 'get_the_content_more_link', 'portfolio_read_more_link' );
    add_filter( 'the_content_more_link', 'portfolio_read_more_link' );
    /**
     * Custom Read More link.
     */
    	function portfolio_read_more_link() {
    		return '<a class="more-link" href="' . get_permalink() . '" rel="nofollow">Read More</a>';
    }
    
    // Remove post info and meta info
    remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
    remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
    
    /**
     * Adds Featured Image and links it to the Post
     */
    function epik_portfolio_do_post_image() { 
    	$img = genesis_get_image( array( 'format' => 'html', 'size' => 'portfolio-thumbnail', 'attr' => array( 'class' => 'alignnone post-image' ) ) ); printf( '<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), $img ); 
    }	
    add_action( 'genesis_entry_header', 'epik_portfolio_do_post_image' ); 
    
    // Move title below post image
    remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    add_action( 'genesis_entry_content', 'genesis_do_post_title', 9 );
    
    // Add Content for the Portfolio posts in this Page Template
    function epik_portfolio_do_post_content() {
        
        if ( genesis_get_option( 'epik_portfolio_content' ) == 'excerpts' ) {
            the_excerpt();
        
        } else {
            if ( genesis_get_option( 'epik_portfolio_content_archive_limit' ) )
                the_content_limit( (int)genesis_get_option( 'epik_portfolio_content_archive_limit' ), __( 'Read More', 'epik' ) );
            else
                the_content(__( 'Read More', 'epik' ));
        }
    }
    add_action( 'my_content_area', 'epik_portfolio_do_post_content' );
    
    // Clear float using genesis_custom_loop() $loop_counter variable
    // Outputs clearing div after every 4 posts
    // $loop_counter is incremented after this function is run
    function portfolio_after_post() {
        global $loop_counter;
        
        if ( $loop_counter == 3 ) {
            $loop_counter = -1;
            echo '<div class="clear"></div>';
        }
    }
    add_action( 'genesis_entry_footer', 'portfolio_after_post' );
    
    // Add custom loop
    function portfolio_loop() {
        $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
        
        $include = genesis_get_option( 'epik_portfolio_cat' );
        $exclude = genesis_get_option( 'epik_portfolio_cat_exclude' ) ? explode(',', str_replace(' ', '', genesis_get_option( 'epik_portfolio_cat_exclude' ))) : '';
            
        $cf = genesis_get_custom_field( 'query_args' ); // Easter Egg
        $args = array( 'cat' => $include, 'category__not_in' => $exclude, 'showposts' => genesis_get_option( 'epik_portfolio_cat_num' ), 'paged' => $paged);
        $query_args = wp_parse_args($cf, $args);
        
        genesis_custom_loop( $query_args );
    }
    add_action( 'my_service_loop', 'portfolio_loop' );
    
    // Remove 'site-inner' from structural wrap
    add_theme_support( 'genesis-structural-wraps', array( 'header', 'footer-widgets', 'footer' ) );
    
    // Build the page
    get_header();
    do_action( 'my_custom_fields_area' );
    do_action( 'my_service_loop' );
    do_action( 'my_content_area' );
    get_footer();