WordPress.org

Ready to get started?Download WordPress

Forums

Contextual Related Posts
Slight Conflict with Genesis Themes (6 posts)

  1. brettbum
    Member
    Posted 9 months ago #

    Using 1.8.8 of Contextual Related Posts and the Genesis Framework running in this case on the luscious theme (although this is a genesis related issue not child theme)

    If I am displaying a Genesis Featured Page in a Widget,

    & I have Contextual Related Posts to NOT show up on Pages

    The Contextual related Posts will show up anyway on the display of a page through the widget.

    If I alternately try to block the specif page by the post ID, the Contextual related posts STILL show up below the page in the widget.

    In my case, I could not find any setting to correct this so I simply HID the Contextual Related Post output using CSS for just the widget area

    .widget-wrap .crp_related {
    display: none;
    }

    Still, this seems like a bit of a conflict.

    Hope my css helps others, but if possible would like to see the compatibility problem resolved.

    Any ideas?

    http://wordpress.org/extend/plugins/contextual-related-posts/

  2. Ajay
    Member
    Plugin Author

    Posted 9 months ago #

    Brett, unfortunately, I don't have access to the Genesis Framework to sort this out.

    Are you aware of how exactly the page is included in the widget which seems to be confusing the logic of my plugin.

    Did you enter the page ID under output options > Exclude display of related posts on these posts / pages?

  3. brettbum
    Member
    Posted 9 months ago #

    I do not know exactly how the page is included through the Genesis widget, but will look and see if I can find it.

    I DID enter the page ID under output options to exclude the page. On the page itself, that did prevent the output of related posts. Just disabling it on all pages did the same thing. It was when this page content was later pulled in through the widget displayed in a sidebar that the related post content shows up again.

  4. brettbum
    Member
    Posted 9 months ago #

    Here's the code that setups their widget option to display a page via a widget, but I do not believe this is what we are looking for....

    <?php
    /**
     * Adds the Featured Page Widget.
     *
     * @category Genesis
     * @package  Widgets
     * @author   StudioPress
     * @license  http://www.opensource.org/licenses/gpl-license.php GPL-2.0+
     * @link     http://www.studiopress.com/themes/genesis
     */
    
    /**
     * Genesis Featured Page widget class.
     *
     * @category Genesis
     * @package Widgets
     *
     * @since 0.1.8
     */
    class Genesis_Featured_Page extends WP_Widget {
    
    	/**
    	 * Holds widget settings defaults, populated in constructor.
    	 *
    	 * @var array
    	 */
    	protected $defaults;
    
    	/**
    	 * Constructor. Set the default widget options and create widget.
    	 *
    	 * @since 0.1.8
    	 */
    	function __construct() {
    
    		$this->defaults = array(
    			'title'           => '',
    			'page_id'         => '',
    			'show_image'      => 0,
    			'image_alignment' => '',
    			'image_size'      => '',
    			'show_title'      => 0,
    			'show_byline'     => 0,
    			'show_content'    => 0,
    			'content_limit'   => '',
    			'more_text'       => '',
    		);
    
    		$widget_ops = array(
    			'classname'   => 'featuredpage',
    			'description' => __( 'Displays featured page with thumbnails', 'genesis' ),
    		);
    
    		$control_ops = array(
    			'id_base' => 'featured-page',
    			'width'   => 200,
    			'height'  => 250,
    		);
    
    		$this->WP_Widget( 'featured-page', __( 'Genesis - Featured Page', 'genesis' ), $widget_ops, $control_ops );
    
    	}
    
    	/**
    	 * Echo the widget content.
    	 *
    	 * @since 0.1.8
    	 *
    	 * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
    	 * @param array $instance The settings for the particular instance of the widget
    	 */
    	function widget( $args, $instance ) {
    
    		extract( $args );
    
    		/** Merge with defaults */
    		$instance = wp_parse_args( (array) $instance, $this->defaults );
    
    		echo $before_widget;
    
    		/** Set up the author bio */
    		if ( ! empty( $instance['title'] ) )
    			echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
    
    		$featured_page = new WP_Query( array( 'page_id' => $instance['page_id'] ) );
    		if ( $featured_page->have_posts() ) : while ( $featured_page->have_posts() ) : $featured_page->the_post();
    			echo '<div class="' . implode( ' ', get_post_class() ) . '">';
    
    			if ( ! empty( $instance['show_image'] ) && $image = genesis_get_image( array( 'format' => 'html', 'size' => $instance['image_size'] ) ) )
    				printf( '<a href="%s" title="%s" class="%s">%s</a>', get_permalink(), the_title_attribute( 'echo=0' ), esc_attr( $instance['image_alignment'] ), $image );
    
    			if ( ! empty( $instance['show_title'] ) )
    				printf( '<h2><a href="%s" title="%s">%s</a></h2>', get_permalink(), the_title_attribute( 'echo=0' ), get_the_title() );
    
    			if ( ! empty( $instance['show_byline'] ) ) {
    				echo '<p class="byline">';
    				the_time( 'F j, Y' );
    				echo ' ' . __( 'by', 'genesis' ) . ' ';
    				the_author_posts_link();
    				echo '…';
    				comments_popup_link( __( 'Leave a Comment', 'genesis' ), __( '1 Comment', 'genesis' ), __( '% Comments', 'genesis' ) );
    				echo ' ';
    				edit_post_link( __( '(Edit)', 'genesis' ), '', '' );
    				echo '</p>';
    			}
    
    			if ( ! empty( $instance['show_content'] ) ) {
    				if ( empty( $instance['content_limit'] ) )
    					the_content( $instance['more_text'] );
    				else
    					the_content_limit( (int) $instance['content_limit'], esc_html( $instance['more_text'] ) );
    			}
    
    			echo '</div><!--end post_class()-->' . "\n\n";
    
    			endwhile;
    		endif;
    
    		echo $after_widget;
    		wp_reset_query();
    
    	}
    
    	/**
    	 * Update a particular instance.
    	 *
    	 * This function should check that $new_instance is set correctly.
    	 * The newly calculated value of $instance should be returned.
    	 * If "false" is returned, the instance won't be saved/updated.
    	 *
    	 * @since 0.1.8
    	 *
    	 * @param array $new_instance New settings for this instance as input by the user via form()
    	 * @param array $old_instance Old settings for this instance
    	 * @return array Settings to save or bool false to cancel saving
    	 */
    	function update( $new_instance, $old_instance ) {
    
    		$new_instance['title']     = strip_tags( $new_instance['title'] );
    		$new_instance['more_text'] = strip_tags( $new_instance['more_text'] );
    		return $new_instance;
    
    	}
    
    	/**
    	 * Echo the settings update form.
    	 *
    	 * @since 0.1.8
    	 *
    	 * @param array $instance Current settings
    	 */
    	function form( $instance ) {
    
    		/** Merge with defaults */
    		$instance = wp_parse_args( (array) $instance, $this->defaults );
    
    		?>
    		<p>
    			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'genesis' ); ?>:</label>
    			<input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" />
    		</p>
    
    		<p>
    			<label for="<?php echo $this->get_field_id( 'page_id' ); ?>"><?php _e( 'Page', 'genesis' ); ?>:</label>
    			<?php wp_dropdown_pages( array( 'name' => $this->get_field_name( 'page_id' ), 'selected' => $instance['page_id'] ) ); ?>
    		</p>
    
    		<hr class="div" />
    
    		<p>
    			<input id="<?php echo $this->get_field_id( 'show_image' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'show_image' ); ?>" value="1"<?php checked( $instance['show_image'] ); ?> />
    			<label for="<?php echo $this->get_field_id( 'show_image' ); ?>"><?php _e( 'Show Featured Image', 'genesis' ); ?></label>
    		</p>
    
    		<p>
    			<label for="<?php echo $this->get_field_id( 'image_size' ); ?>"><?php _e( 'Image Size', 'genesis' ); ?>:</label>
    			<select id="<?php echo $this->get_field_id( 'image_size' ); ?>" class="genesis-image-size-selector" name="<?php echo $this->get_field_name( 'image_size' ); ?>">
    				<option value="thumbnail">thumbnail (<?php echo absint( get_option( 'thumbnail_size_w' ) ); ?>x<?php echo absint( get_option( 'thumbnail_size_h' ) ); ?>)</option>
    				<?php
    				$sizes = genesis_get_additional_image_sizes();
    				foreach ( (array) $sizes as $name => $size )
    					echo '<option value="' . esc_attr( $name ) . '" ' . selected( $name, $instance['image_size'], FALSE ) . '>' . esc_html( $name ) . ' (' . absint( $size['width'] ) . 'x' . absint( $size['height'] ) . ')</option>';
    				?>
    			</select>
    		</p>
    
    		<p>
    			<label for="<?php echo $this->get_field_id( 'image_alignment' ); ?>"><?php _e( 'Image Alignment', 'genesis' ); ?>:</label>
    			<select id="<?php echo $this->get_field_id( 'image_alignment' ); ?>" name="<?php echo $this->get_field_name( 'image_alignment' ); ?>">
    				<option value="alignnone">- <?php _e( 'None', 'genesis' ); ?> -</option>
    				<option value="alignleft" <?php selected( 'alignleft', $instance['image_alignment'] ); ?>><?php _e( 'Left', 'genesis' ); ?></option>
    				<option value="alignright" <?php selected( 'alignright', $instance['image_alignment'] ); ?>><?php _e( 'Right', 'genesis' ); ?></option>
    			</select>
    		</p>
    
    		<hr class="div" />
    
    		<p>
    			<input id="<?php echo $this->get_field_id( 'show_title' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'show_title' ); ?>" value="1"<?php checked( $instance['show_title'] ); ?> />
    			<label for="<?php echo $this->get_field_id( 'show_title' ); ?>"><?php _e( 'Show Page Title', 'genesis' ); ?></label>
    		</p>
    
    		<p>
    			<input id="<?php echo $this->get_field_id( 'show_byline' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'show_byline' ); ?>" value="1"<?php checked( $instance['show_byline'] ); ?> />
    			<label for="<?php echo $this->get_field_id( 'show_byline' ); ?>"><?php _e( 'Show Page Byline', 'genesis' ); ?></label>
    		</p>
    
    		<p>
    			<input id="<?php echo $this->get_field_id( 'show_content' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="1"<?php checked( $instance['show_content'] ); ?> />
    			<label for="<?php echo $this->get_field_id( 'show_content' ); ?>"><?php _e( 'Show Page Content', 'genesis' ); ?></label>
    		</p>
    
    		<p>
    			<label for="<?php echo $this->get_field_id( 'content_limit' ); ?>"><?php _e( 'Content Character Limit', 'genesis' ); ?>:</label>
    			<input type="text" id="<?php echo $this->get_field_id( 'content_limit' ); ?>" name="<?php echo $this->get_field_name( 'content_limit' ); ?>" value="<?php echo esc_attr( $instance['content_limit'] ); ?>" size="3" />
    		</p>
    
    		<p>
    			<label for="<?php echo $this->get_field_id( 'more_text' ); ?>"><?php _e( 'More Text', 'genesis' ); ?>:</label>
    			<input type="text" id="<?php echo $this->get_field_id( 'more_text' ); ?>" name="<?php echo $this->get_field_name( 'more_text' ); ?>" value="<?php echo esc_attr( $instance['more_text'] ); ?>" />
    		</p>
    		<?php
    
    	}
    
    }
  5. Ajay
    Member
    Plugin Author

    Posted 9 months ago #

    That code above helps. I think the plugin is latching onto the_content of the featured page.

    Unfortunately, I'm not sure how exactly to prevent it from hitting the featured page

    Is it possible for you to check with support from the developers of Genesis to see what they have to say about preventing a plugin from adding anything to the_content of the featured page?

  6. brettbum
    Member
    Posted 9 months ago #

    Will see what I can do on that front...

Reply

You must log in to post.

About this Plugin

About this Topic