Rift Wordpress theme, sidebar on single posts not showing - php

I have http://spainthephilippines.com/ where I use Rift Theme. Im having problem with showing the sidebar on single post page. On my index page the sidebar is showing, on the 404 page the sidebar is showing. It is working anywhere I use it just not in signle post page. I was looking 2 hours for answer but I cant find it. The theme is on version 1.0, so is it possible that to be the problem? Then why the sidebar shows on most pages? Anyone can help? Tell me if you need any code.
<?php global $theme; get_header(); ?>
<div id="main">
<?php $theme->hook('main_before'); ?>
<div id="content">
<?php $theme->hook('content_before'); ?>
<?php
if (have_posts()) : while (have_posts()) : the_post();
/**
* Find the post formatting for the single post (full post view) in the post-single.php file
*/
get_template_part('post', 'single');
endwhile;
else :
get_template_part('post', 'noresults');
endif;
?>
<?php $theme->hook('content_after'); ?>
</div><!-- #content -->
<?php get_sidebars(); ?>
<?php $theme->hook('main_after'); ?>
</div><!-- #main -->
EDIT
Here is the sidebar:
<?php global $theme; ?>
<div id="sidebar-primary">
<?php
if(!dynamic_sidebar('sidebar_primary')) {
/**
* The primary sidebar widget area. Manage the widgets from: wp-admin -> Appearance -> Widgets
*/
$theme->hook('sidebar_primary');
}
$theme->hook("sidebar_primary_after");
?>
And also the post-single.php:
<?php global $theme; ?>
<div <?php post_class('post post-single clearfix'); ?> id="post-<?php the_ID(); ?>">
<h2 class="title"><?php the_title(); ?></h2>
<div class="postmeta-primary">
<span class="meta_date"><?php echo get_the_date(); ?></span>
<span class="meta_categories"><?php the_category(', '); ?></span>
<?php if(comments_open( get_the_ID() )) {
?> <span class="meta_comments"><?php comments_popup_link( __( 'No comments', 'themater' ), __( '1 Comment', 'themater' ), __( '% Comments', 'themater' ) ); ?></span><?php
}
if(is_user_logged_in()) {
?> <span class="meta_edit"><?php edit_post_link(); ?></span><?php
} ?>
</div>
<div class="entry clearfix">
<?php
if(has_post_thumbnail()) {
the_post_thumbnail(
array($theme->get_option('featured_image_width_single'), $theme->get_option('featured_image_height_single')),
array("class" => $theme->get_option('featured_image_position_single') . " featured_image")
);
}
?>
<?php
the_content('');
wp_link_pages( array( 'before' => '<p><strong>' . __( 'Pages:', 'themater' ) . '</strong>', 'after' => '</p>' ) );
?>
<?php if(get_the_tags()) {
?><div class="postmeta-secondary"><span class="meta_tags"><?php the_tags('', ', ', ''); ?></span></div><?php
}
?>
<!-- Post ID <?php the_ID(); ?> wtf-->
<?php
if(comments_open( get_the_ID() )) {
comments_template('', true);
}
?>

Related

Show more post stanleywp theme WordPress

I'm using stanleywp theme for WordPress to display some post, actually I've inserted 20 posts, but it shows only 10posts.
This is what I did:
Portfolio -> Portfolio categories -> I added "brands" category
Portfolio -> add new -> and I've added 20 posts and set "brands" category
when I go to .../portfolio-category/brands/ I should see all my 20 posts, but I see only 10.
How can I solve that?
This is taxonomy-portfolio_cats.php:
<?php
/**
* #package WordPress
*/
?>
<?php get_header(); ?>
<?php if (have_posts()) : ?>
<div class="container pt">
<div class="row mt">
<div class="col-lg-6 col-lg-offset-3 centered">
<h1><?php echo single_term_title(); ?></h1>
<hr>
<?php if(category_description()) { ?>
<?php echo category_description( ); ?>
<?php } ?>
</div>
</div>
<div class="row mt centered">
<?php $cont = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<div class="col-lg-4">
<?php if ( has_post_thumbnail()) : ?>
<a class="zoom green" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>
<?php if(bi_get_data('project_title', '5')) {?>
<p><?php the_title(); ?></p>
<?php } ?>
</div> <!-- /col -->
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</div>
<?php endif; ?>
<?php get_footer(); ?>
I think it's due to the default pagination (10 posts per page): you could increase the value on Settings > Reading > Blog pages show at most, or insert the pagination after <?php wp_reset_query(); ?>, something like:
<?php
// Previous/next page navigation.
the_posts_pagination( array(
'prev_text' => __( 'Previous page', 'your-textdomain' ),
'next_text' => __( 'Next page', 'your-textdomain' ),
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'your-textdomain' ) . ' </span>',
) );
?>
Or if you want to change the number of posts per page only for that taxonomy archive you can use the pre_get_posts action:
function portfolio_cats_posts_per_page( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( is_tax( 'portfolio_cats' ) ) {
// Display all posts in one page
$query->set( 'posts_per_page', -1 );
}
}
add_action( 'pre_get_posts', 'portfolio_cats_posts_per_page', 1 );

How to include HTML and [shortcode] inside PHP?

I have a wordpress website and I want to display this at the end of every blog post:
<h5 style="margin-bottom: 15px;margin-top:35px;"><em><strong>Text:</strong></em>
[shareaholic app="share_buttons" id="5374371"]
If I add this to single.php which shows the pages I want to modify, the shortcode won't work.
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
/* Featured Image */
if(has_post_thumbnail()) { ?>
<p class="post-thumbnail">
<?php the_post_thumbnail('full'); ?>
</p>
<?php }
the_content();
the_tags('<p>'.__('Tags:', 'sntheme'),', ','</p>');
/* Show post page links */
wp_link_pages( array( 'before' => '<p>' . __( 'Pages:', 'sntheme' ), 'after' => '</p>' ) );
?>
<h5 style="margin-bottom: 15px;margin-top:35px;"><em><strong>Text:</strong></em>
[shareaholic app="share_buttons" id="5374371"]
</article><!-- end post -->
Is there a workaround for this?
Yes - http://wordpress.org/plugins/shareaholic/installation/
<?php echo do_shortcode ('[shareaholic app="share_buttons" id="5374371"]'); ?>

Link Wordpress post images to post

I'm developing a wordpress theme for my blog and I'm having some difficulty.
When I make a new post, the first image of that post is displayed on the homepage. When the image is clicked, it links to the image file and shows the full size. I would like for it to automatically link to the post from which it came. I understand that you can choose what the image links to upon upload or in the editor. I would like for the images to link to their original post automatically, since I have other people writing on my blog, and I don't want them to have to do this each time.
As I understand it the content.php file controls the post format in this case. Here is the file from my theme. Or is it possible to use a function?
<?php
/**
* The default template for displaying content single/search/archive
*
* #package test
* #since test 0.1.0
*/
?>
<!-- START: content.php -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php if ( is_single() ) : ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php else : ?>
<?php the_post_thumbnail(); ?>
<h1 class="entry-title">
<?php the_title(); ?>
</h1>
<?php endif; // is_single() ?>
</header><!-- .entry-header -->
<?php if ( 'post' == get_post_type() ) : ?>
<div class="entry-meta">
<?php posted_on(); ?>
<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
<span class="label radius secondary"><?php _ex( 'Featured', 'Post format title', 'test' ); ?></span>
<?php endif; ?>
</div><!-- .entry-meta -->
<?php endif; ?>
<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'test' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'test' ) . '</span>', 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
<footer class="entry-meta">
<?php if ( 'post' == get_post_type() ) : ?>
<?php get_template_part('entry-meta', get_post_format() ); ?>
<?php endif; ?>
</footer><!-- #entry-meta -->
</article><!-- #post-<?php the_ID(); ?> -->
<!-- END: content.php -->
https://codex.wordpress.org/Function_Reference/the_post_thumbnail
example 1. To link Post Thumbnails to the Post Permalink in a specific loop, use the following within your Theme's template files:
<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>

Getting data twice on page in wordpress

I have my theme page.php as:
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> >
<header class="entry-header">
<div class="hd"><?php the_title(); ?></div>
<?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
<div class="video"><?php the_post_thumbnail(); ?></div>
<?php endif; ?>
<div class="hd"><?php //the_title(); ?></div>
</header><!-- .entry-header -->
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
<!-- .entry-content -->
<footer class="entry-meta">
<?php edit_post_link( __( 'Edit', 'twentythirteen' ), '<span class="edit-link">', '</span>' ); ?>
</footer><!-- .entry-meta -->
</article><!-- #post -->
<?php // comments_template( '', true ); ?>
<?php endwhile; ?>
And I have made three page in wordpress blog, image and news and i also assigned them category for each. now i have installed php-exec plugin . Now I am writing some php code in page editor to retrieve blog data...
It working fine but it fetching data twice and now got it is becouse of page.php .
So can i have some condition on page.php if i am trying to fetch some data by cotegory then page.php data would not be display...
here is my code which i applied on blog page editor
<?php if (query_posts('cat=63&showposts=5')) : ?>
<?php while (have_posts()) : the_post();
// do whatever you want
?>
<div class="gallery_views">
<div class="hd"><?php the_title(); ?></div>
<?php // get_template_part( 'content', get_post_format() ); ?>
<?php // cup_post_nav(); ?>
<?php the_post_thumbnail(); ?>
<?php comments_template(); ?>
<b><?php the_title(); ?></b>
</div>
<?php endwhile; ?>
<?php else : ?>
Thanks in advance..
<?php if (query_posts('cat=63&showposts=5')) : ?>
<?php while (have_posts()) : the_post();
// do whatever you want
?><div class="gallery_views">
<div class="hd"><?php the_title(); ?></div>
<?php // get_template_part( 'content', get_post_format() ); ?>
<?php // cup_post_nav(); ?>
<?php the_post_thumbnail(); ?>
<?php comments_template(); ?>
<b><?php the_title(); ?></div>
<?php
break;
endwhile;
?>
<?php else : ?>
Add a break in your while, it'll stop after the first loop.

Wordpress Search

is there a way to just search
pages
Custom Types
Posts
I am currently modifying the twenty eleven theme.
here is the Code for search.php:
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title"><?php printf( __( 'Search Results for "%s"', 'twentyeleven' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
<div class="SearchCount"><?php /* Search Count */
$allsearch = &new WP_Query("s=$s&showposts=-1");
//$key = wp_specialchars($s, 1);
$count = $allsearch->post_count; _e(''); _e();
echo $key; _e(); _e();
echo $count . ' '; _e('');
wp_reset_query(); ?> Saved Results </div>
<div id="topPagination"><?php twentyeleven_child_content_nav( 'nav-above' ); ?></div>
</header>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to overload this in a child theme then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', 'search' );
?>
<?php endwhile; ?>
<?php twentyeleven_child_content_nav( 'nav-below' ); ?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'twentyeleven' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; ?>
And here is the content-search.php
<h2><a href="<?php the_permalink();?>">
<?php $title = get_the_title(); $keys= explode(" ",$s); $title = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt">\0</strong>', $title); ?>
<?php echo $title; ?>
</a><br />
<span class="categoryClass"><?php the_category(','); ?></span></h2>
<?php the_excerpt(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
Thank you
The way I see it you have two options. One is to modify wp_query to only return the type that you want. The second is search on everything, but filter the results afterwards.
This is how I believe you would modify wp_query by using Type Parameters
$allsearch = &new WP_Query("s=$s&showposts=-1"); //what you currently have
$customsearch = &new WP_Query("post_type=page&posts_per_page =5");
This is how I believe you would filter post search
if ( have_posts() ) : while ( have_posts() ) : the_post();
if (is_page()) {} //do something if page
endwhile;
http://codex.wordpress.org/Creating_a_Search_Page

Categories