badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

Problems making slider title and excerpt optional

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12392
    gonzalo.cao
    Participant

    Hi all,

    I’m trying to make title and excerpt optional when slider displays. Not for all slides just for selected.

    The first part at admin section is ready. I’ve modified theme-options.php and added a checkbox “Display title & excerpt” for every featured slider and store the result value in a variable attitude_theme_options[featured_post_slider_title][i]. This works fine!

    http://www.webpagescreenshot.info/i3/53cf931703acf8-59730292Admin section

    However I’m unable to find where to modify the slider behaviour. I edit library/structure/header-extensions.php file (function attitude_featured_post_slider()) with no success. No matter what I do (even comment it all), slider behaviour is allways the same.

    Maybe there is other place where slider behaviour is defined?

    if ( ! function_exists( 'attitude_featured_post_slider' ) ) :
    /**
     * display featured post slider
     *
     * @uses set_transient and delete_transient
     */
    function attitude_featured_post_slider() {	
    	global $post;
    		
    	global $attitude_theme_options_settings;
       $options = $attitude_theme_options_settings;
    	
    	$attitude_featured_post_slider = '';
    	if( ( !$attitude_featured_post_slider = get_transient( 'attitude_featured_post_slider' ) ) && !empty( $options[ 'featured_post_slider' ] ) ) {
    
    		if( 'wide-layout' == $options[ 'site_layout' ] ) {
    			$slider_size = 'slider-wide';
    		}
    		else {
    			$slider_size = 'slider-narrow';
    		}
    		
    		$attitude_featured_post_slider .= '
    		<section class="featured-slider"><div class="slider-cycle">';
    			$get_featured_posts = new WP_Query( array(
    				'posts_per_page' 			=> $options[ 'slider_quantity' ],
    				'post_type'					=> array( 'post', 'page' ),
    				'post__in'		 			=> $options[ 'featured_post_slider' ],
    				'orderby' 		 			=> 'post__in',
    				'ignore_sticky_posts' 	=> 1 						// ignore sticky posts
    			));
    			$i=0; while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
    				$title_attribute = apply_filters( 'the_title', get_the_title( $post->ID ) );
    				$excerpt = get_the_excerpt();
    				if ( 1 == $i ) { $classes = "slides displayblock"; } else { $classes = "slides displaynone"; }
    				$attitude_featured_post_slider .= '
    				<div class="'.$classes.'">';
    						if( has_post_thumbnail() ) {
    	
    							$attitude_featured_post_slider .= '<figure><a href="' . get_permalink() . '" title="'.the_title('','',false).'">';
    	
    							$attitude_featured_post_slider .= get_the_post_thumbnail( $post->ID, $slider_size, array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class'	=> 'pngfix' ) ).'</a></figure>';
    						}
                            /** patch begins **/
    						//if( $title_attribute != '' || $excerpt !='' ) {
    						<strong>if( ($options[ 'featured_post_slider_title' ][$i]==1) && ($title_attribute != '' || $excerpt !='' )) {</strong>
    						$attitude_featured_post_slider .= '
    							<article class="featured-text">';
    							if( $title_attribute !='' ) {
    									$attitude_featured_post_slider .= '<div class="featured-title"><a href="' . get_permalink() . '" title="'.the_title('','',false).'">'. get_the_title() . '</a></div><!-- .featured-title -->';
    							}
    							if( $excerpt !='' ) {								
    								$attitude_featured_post_slider .= '<div class="featured-content">'.$excerpt.'</div><!-- .featured-content -->';
    							}
    						$attitude_featured_post_slider .= '
    							</article><!-- .featured-text -->';
    						}
                            
                            /** patch ends **/
    				$attitude_featured_post_slider .= '
    				</div><!-- .slides -->';
    			endwhile; wp_reset_query();
    		$attitude_featured_post_slider .= '</div>				
    		<nav id="controllers" class="clearfix">
    		</nav><!-- #controllers --></section><!-- .featured-slider -->';
    			
    	set_transient( 'attitude_featured_post_slider', $attitude_featured_post_slider, 86940 );
    	}
    	echo $attitude_featured_post_slider;	
    }
    endif;
    #12397
    gonzalo.cao
    Participant

    Don’t ask me why but now it works! You can show a sample at http://www.despensasolidaria.org

    (Maybe I had some kind of cache issue)

    These are the changes I’ve made

    Files edited
    library/admin/theme-options.php
    library/structure/header-extensions.php

    library/admin/theme-options.php

    Inmediately after this (line 594 aprox)
    <a href="<?php bloginfo ( 'url' );?>/wp-admin/post.php?post=<?php if( array_key_exists ( 'featured_post_slider', $options ) && array_key_exists ( $i, $options[ 'featured_post_slider' ] ) ) echo absint( $options[ 'featured_post_slider' ][ $i ] ); ?>&action=edit" class="button" title="<?php esc_attr_e('Click Here To Edit'); ?>" target="_blank"><?php _e( 'Click Here To Edit', 'attitude' ); ?></a>

    add this

        <!-- patch begins -->
        <input type="checkbox" name="attitude_theme_options[featured_post_slider_title][<?php echo absint( $i ); ?>]" value="1" <?php if( array_key_exists( 'featured_post_slider_title', $options ) && array_key_exists( $i, $options[ 'featured_post_slider_title' ] ) ) checked( '1', $options['featured_post_slider_title'][$i] ); ?>/> <?php _e( 'Display post title', 'attitude' ); ?>
        <!-- patch ends -->
    

    Also substitute this (line 793 aprox)

        if ( isset( $input[ 'featured_post_slider' ] ) ) {
    		$input_validated[ 'featured_post_slider' ] = array();
    	}   
        
    	if( isset( $input[ 'slider_quantity' ] ) )   
    	for ( $i = 1; $i <= $input [ 'slider_quantity' ]; $i++ ) {
    		if ( intval( $input[ 'featured_post_slider' ][ $i ] ) ) {
    			$input_validated[ 'featured_post_slider' ][ $i ] = absint($input[ 'featured_post_slider' ][ $i ] );
    		}
    	}
    

    With this

    	if ( isset( $input[ 'featured_post_slider' ] ) ) {
    		$input_validated[ 'featured_post_slider' ] = array();
    	}   
        /** patch begin **/
    	if ( isset( $input[ 'featured_post_slider_title' ] ) ) {
    		$input_validated[ 'featured_post_slider_title' ] = array();
    	}   
        /** patch end **/
    
    	if( isset( $input[ 'slider_quantity' ] ) )   
    	for ( $i = 1; $i <= $input [ 'slider_quantity' ]; $i++ ) {
    		if ( intval( $input[ 'featured_post_slider' ][ $i ] ) ) {
    			$input_validated[ 'featured_post_slider' ][ $i ] = absint($input[ 'featured_post_slider' ][ $i ] );
    		}
            /** patch begin **/
    		if ( intval( $input[ 'featured_post_slider_title' ][ $i ] ) ) {
    			$input_validated[ 'featured_post_slider_title' ][ $i ] = absint($input[ 'featured_post_slider_title' ][ $i ] );
    		}
            /** patch end **/
    	}

    library/structure/header-extensions.php

    Substitute this line (450 aprox)
    if( $title_attribute != '' || $excerpt !='' ) {

    With this one
    if( ($options[ 'featured_post_slider_title' ][$i]==1) && ($title_attribute != '' || $excerpt !='' )) {

    I’d like to insert it into a child theme like other mods I’ve done but I’m not sure how to do it.

    #12437

    Hi gonzalo.cao,

    here is more information about child theme.
    http://codex.wordpress.org/Child_Themes

    Thank you!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.