Sidebar question for Reviews News Video
-
Is there a way to set the sidebar on news as default rather than reviews?
-
This should work for you buddy.
find themes/Gamepress/admin/recent-posts-widget.php
extract to desktop copy this code all i did was modify the tab sequence to set your news to be first tab, I only use Video tab when displaying widget so in mine i have took out Reviews and News Tabs
<?php /** * Plugin Name: Recent Posts */ add_action( 'widgets_init', 'gamepress_recent_posts_load_widgets' ); function gamepress_recent_posts_load_widgets() { register_widget( 'gamepress_recent_posts_widget' ); } class gamepress_recent_posts_widget extends WP_Widget { /** * Widget setup. */ function gamepress_recent_posts_widget() { /* Widget settings. */ $widget_ops = array( 'classname' => 'gamepress_tabbed_widget', 'description' => __('Displays a list of recent posts, reviews and videos in a tabbed widget', 'gamepress') ); /* Widget control settings. */ $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'gamepress_tabbed_widget' ); /* Create the widget. */ $this->WP_Widget( 'gamepress_tabbed_widget', __('GamePress: Recent news, reviews & videos', 'gamepress'), $widget_ops, $control_ops ); } /** * How to display the widget on the screen. */ function widget( $args, $instance ) { extract( $args ); /* Our variables from the widget settings. */ $number = $instance['number']; ?> <div class="widget reviews_widget"> <div class="tabs-wrapper"> <ul class="tabs-nav tabs"> <li><a href="#"><?php _e('News','gamepress'); ?></a></li> <li><a href="#"><?php _e('Reviews','gamepress'); ?></a></li> <li><a href="#"><?php _e('Videos','gamepress'); ?></a></li> </ul> <ul id="tabs-1" class="reviews pane"> <?php /** Get all reviews **/ $query_r = array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'gamepress_reviews'); $reviews = new WP_Query($query_r); if ($reviews->have_posts()) : ?> <?php while ($reviews->have_posts()) : $reviews->the_post(); ?> <li> <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?> <div class="entry-thumb"> <a href="<?php echo get_permalink() ?>" class="img-bevel" rel="bookmark" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?> </a> </div> <?php endif; ?> <div class="entry-wrapper"> <h6 class="entry-title"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6> <div class="entry-meta"> <?php the_time('F j, Y') ?> | <?php comments_popup_link(__('No comments','gamepress'), __('1 comment','gamepress'), __('Comments: %','gamepress')); ?> </div> <?php if(get_post_meta(get_the_ID(), "gamepress_score", true)) : ?> <div class="rating-bar"> <?php echo gamepress_rating(get_post_meta(get_the_ID(), "gamepress_score", true)); ?> </div> <?php endif; ?> </div> </li> <?php endwhile; ?> <?php else: _e('No game reviews yet.','gamepress'); endif; wp_reset_query(); ?> </ul> <ul id="tabs-2" class="news pane"> <?php $recent_posts = new WP_Query(array('showposts' => $number,'post_status' => 'publish')); ?> <?php while($recent_posts->have_posts()): $recent_posts->the_post(); ?> <li> <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?> <div class="entry-thumb"> <a href="<?php echo get_permalink() ?>" class="img-bevel" rel="bookmark" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?> </a> </div> <?php endif; ?> <div class="entry-wrapper"> <h6 class="entry-title"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6> <div class="entry-meta"> <?php the_time('F j, Y') ?> | <?php comments_popup_link(__('No comments','gamepress'), __('1 comment','gamepress'), __('Comments: %','gamepress')); ?> </div> </div> </li> <?php endwhile; ?> </ul> <?php wp_reset_query(); ?> <ul id="tabs-3" class="video pane"> <?php /** Get all videos **/ $query_v = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'gamepress_video'); $videos = new WP_Query($query_v); if ($videos->have_posts()) : ?> <?php while ($videos->have_posts()) : $videos->the_post(); ?> <li> <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?> <div class="entry-thumb"> <a href="<?php echo get_permalink() ?>" class="img-bevel" rel="bookmark" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?> </a> </div> <?php endif; ?> <div class="entry-wrapper"> <h6 class="entry-title"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6> <div class="entry-meta"> <?php the_time('F j, Y') ?> | <?php comments_popup_link(__('No comments','gamepress'), __('1 comment','gamepress'), __('Comments: %','gamepress')); ?> </div> </div> </li> <?php endwhile; ?> <?php else: _e('No videos yet.','gamepress'); endif; wp_reset_query(); ?> </ul> </div> <?php /* After widget (defined by themes). */ echo $after_widget; } /** * Update the widget settings. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip tags for title and name to remove HTML (important for text inputs). */ $instance['number'] = strip_tags( $new_instance['number'] ); return $instance; } function form( $instance ) { /* Set up some default widget settings. */ $defaults = array('number' => 3); $instance = wp_parse_args( (array) $instance, $defaults ); ?> <!-- Number of posts --> <p> <label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e('Number of posts to show','gamepress') ?>:</label> <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" value="<?php echo $instance['number']; ?>" size="3" /> </p> <?php } } ?>
Thanks for your suggestion, I tried..
but seems only to have changed the title of the tab and not the order in which they are open, what I need is for it to be set to open (tab 2) by default. currently when a user lands on the website the default tab is links (tab 1).
These are the tab orders in the code
<ul class="tabs-nav tabs"> <li><a href="#"><?php _e('News','gamepress'); ?></a></li> <li><a href="#"><?php _e('Reviews','gamepress'); ?></a></li> <li><a href="#"><?php _e('Videos','gamepress'); ?></a></li>
#1 News
#2 Reviews
#3 VideosAll you have to do is rearrange that to say
<ul class="tabs-nav tabs"> <li><a href="#"><?php _e('Reviews','gamepress'); ?></a></li> <li><a href="#"><?php _e('News','gamepress'); ?></a></li> <li><a href="#"><?php _e('Videos','gamepress'); ?></a></li>
Now
#1 Reviews
#2 News
#3 VideosIs this the issue you speak of?
Thanks again for getting back to me, but this solution is just renaming the tab titles it is not what I am trying to do.
on loading the webpage , I wish for the website sidebar to be open on tab #2 of the three as default, because this shows the latest posts/news
altering the tab titles doesnt make any difference to the content shown underneath the title. even by moving the titles so that News is on tab #1 the content still shows the original tab #1 content.
If you can imagine out of three tabs its only tab #2 that has any content. I want my page to show tab #2 content as default, so that the page looks a bit more busy when loaded.. currently it always shows tab #1 which unfortunately is empty.
Hope this makes it clearer what I aim to do.
Thanks
Maybe it would be easier to use different widget – there’s no point in having tabs if only one has any content. I’d suggest going with simple “Recent posts” widget.
Maybe it would be easier to use different widget – there’s no point in having tabs if only one has any content. I’d suggest going with simple “Recent posts” widget.
Yes Ive used this widget before (Recent posts) its very good.
I do wish to maintain the tabs for future use. Because I am going to have links added and also Videos. Also I do like the way this tab section works and how it fits in with the website.
You’re absolutely right it would be easier to use alternative but I would like to try and resolve the issue rather than pass it off as a cant be done.
by the way ..Great theme!!!
Many thanks
I know this is a old post but all you have to do is change the heading lines as suggested earlier then swap the news Ul with the reviews UL so basically this is my code
<div class="widget reviews_widget"> <div class="tabs-wrapper"> <ul class="tabs-nav tabs"> <li><a href="#"><?php _e('News','gamepress'); ?></a></li> <li><a href="#"><?php _e('Reviews','gamepress'); ?></a></li> <li><a href="#"><?php _e('Videos','gamepress'); ?></a></li> </ul> <ul id="tabs-1" class="news pane"> <?php $recent_posts = new WP_Query(array('showposts' => $number,'post_status' => 'publish')); ?> <?php while($recent_posts->have_posts()): $recent_posts->the_post(); ?> <li> <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?> <div class="entry-thumb"> <a href="<?php echo get_permalink() ?>" class="img-bevel" rel="bookmark" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?> </a> </div> <?php endif; ?> <div class="entry-wrapper"> <h6 class="entry-title"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6> <div class="entry-meta"> <?php the_time('F j, Y') ?> | <?php comments_popup_link(__('No comments','gamepress'), __('1 comment','gamepress'), __('Comments: %','gamepress')); ?> </div> </div> </li> <?php endwhile; ?> </ul> <?php wp_reset_query(); ?> <ul id="tabs-2" class="reviews pane"> <?php /** Get all reviews **/ $query_r = array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'gamepress_reviews'); $reviews = new WP_Query($query_r); if ($reviews->have_posts()) : ?> <?php while ($reviews->have_posts()) : $reviews->the_post(); ?> <li> <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?> <div class="entry-thumb"> <a href="<?php echo get_permalink() ?>" class="img-bevel" rel="bookmark" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?> </a> </div> <?php endif; ?> <div class="entry-wrapper"> <h6 class="entry-title"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6> <div class="entry-meta"> <?php the_time('F j, Y') ?> | <?php comments_popup_link(__('No comments','gamepress'), __('1 comment','gamepress'), __('Comments: %','gamepress')); ?> </div> <?php if(get_post_meta(get_the_ID(), "gamepress_score", true)) : ?> <div class="rating-bar"> <?php echo gamepress_rating(get_post_meta(get_the_ID(), "gamepress_score", true)); ?> </div> <?php endif; ?> </div> </li> <?php endwhile; ?> <?php else: _e('No game reviews yet.','gamepress'); endif; wp_reset_query(); ?> </ul> <ul id="tabs-3" class="video pane"> <?php /** Get all videos **/ $query_v = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'gamepress_video'); $videos = new WP_Query($query_v); if ($videos->have_posts()) : ?> <?php while ($videos->have_posts()) : $videos->the_post(); ?> <li> <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : ?> <div class="entry-thumb"> <a href="<?php echo get_permalink() ?>" class="img-bevel" rel="bookmark" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?> </a> </div> <?php endif; ?> <div class="entry-wrapper"> <h6 class="entry-title"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6> <div class="entry-meta"> <?php the_time('F j, Y') ?> | <?php comments_popup_link(__('No comments','gamepress'), __('1 comment','gamepress'), __('Comments: %','gamepress')); ?> </div> </div> </li> <?php endwhile; ?> <?php else: _e('No videos yet.','gamepress'); endif; wp_reset_query(); ?> </ul>
- The topic ‘Sidebar question for Reviews News Video’ is closed to new replies.