I'm having a problem when it comes to adding sidebar at single.php. I already included
<?php get_sidebar(); ?>
But it seems to be appear below and the content(Blog post) still at the middle of the whole page. I've tried to check all of the previous forum but none of them helped me to figure this out.
Here's my single.php
<?php
/**
* The template for displaying all single posts.
*
* #package Tesseract
*/
get_header(); ?>
<div id="primary" class="full-width-page">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'single' ); ?>
<?php tesseract_post_nav(); ?>
<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
?>
<?php comments_template(); ?>
<?php endwhile; // end of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
The most logical reason for this to happen is that there isn't enough room for both the main content and the sidebar to appear next to each other. Check the width of your sections in your stylesheet and make the necessary changes to the styles.
First of all you create the sidebar in the admin and then call that sidebar where you want.Following is the code for calling sidebar
<ul id="sidebar">
<?php dynamic_sidebar( 'right-sidebar' ); ?>
Use following link to know more about how to create a sidebar
https://codex.wordpress.org/Function_Reference/register_sidebar
Related
This is a single.php and for example url is
http://url.com/sample-post/
I added some extra content with Advanced Custom Fields plugin and show it in the content. Everything is all right here but I want to show this extra content like http://url.com/sample-post/extra-content/
Is it possible? If yes how can I make it? I've been searching for hours but I have not found anything.
I hope you understand me and so sorry for my bad english. Thank you everyone who will help.
<?php get_header(); ?>
<main class="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php the_field('some-extra-content'); ?> // Extra Content
<?php endwhile; ?>
</main>
<?php get_footer(); ?>
please try below code for ACF
<?php get_header(); ?>
<main class="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php echo get_field('some-extra-content', $post->ID); ?>
<?php endwhile; ?>
</main>
<?php get_footer(); ?>
Not exactly the same url but you could use a query string.
http://url.com/sample-post?extra=true
<?php
if($_GET['extra'] === 'true'){
the_field('some-extra-content');
}
?>
I want to display name of multiple authors on the front end like below
By John Doe,Linn Doe and Penny
In the back end I can add many users for the same post.But In the front end only the first author on the post shows up both for the byline and the bio. I'm using Twenty Thirteen theme and how to show all the user added in the back end in the front end?
this is my single.php file
get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php twentythirteen_post_nav(); ?>
<?php comments_template(); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Incorporate Co-Authors Plus template tags into your theme
Other Solution:
In order to add add Co-Authors Plus support you must have access to edit the theme template. In order to display information about multiple authors on the fronted, you'll need to add the necessary Co-Authors Plus template tags to your single.php and other theme files.
Specifically for the bylines, you'll want to replace where it says something like:
<?php the_author(); ?>
With something like this:
<?php if ( function_exists( 'coauthors' ) ) { coauthors(); } else { the_author(); } ?>
That specific snippet will allow your theme to degrade gracefully when Co-Authors Plus isn't activated.
To show the authors with their posts link, you'll want to use something like:
<?php if ( function_exists( 'coauthors_posts_links' ) ) { coauthors_posts_links(); } else { the_author_posts_link(); } ?>
You can use the following code for the bios
<?php $coauthors = get_coauthors(); ?>
<?php foreach( $coauthors as $coauthor ): ?>
<center><div class="authbio">
<img src="<?php bloginfo('template_url'); ?>/images/<?php echo $coauthor->user_firstname; ?>.jpg" alt="" class="alignleft"/>
<?php $userdata = get_userdata( $coauthor->ID ); ?>
<?php if ( $userdata->user_description ) echo $userdata->user_description; ?>
</div></center>
<?php endforeach; ?>
Reference
I have a signifiantly big problem up there.
I'm trying to design my search restult page on WordPress, but if it comes that the search find a page with the keyword I just entered, it display the entire page instead of the title();
My code
<?php
/**
* The template for displaying search results pages.
*
* #package miller
*/
get_header(); ?>
<section id="primary" class="content-area">
<main id="int_top_main" class="internal blue_top" style="min-height:80px;">
<div class="wrapper">
<h2 class="page_title uppercase"><span class="parent_page">Search results</h2>
<div id="infinite_blue_top_bar"></div>
</div>
</main><!-- #main -->
<div id="int_content_main" class="internal">
<div class="wrapper physician_headline">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php else : ?>
<h2><?php _e( 'Nothing Found', 'miller' ); ?></h2>
<div class="page-content">
<?php if ( is_search() ) : ?>
<p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'miller' ); ?></p>
<?php else : ?>
<p><?php _e( 'It seems we can’t find what you’re looking for. Perhaps searching can help.', 'miller' ); ?></p>
<?php endif; ?>
</div><!-- .page-content -->
<?php endif; ?>
</div>
</div>
</section><!-- #primary -->
<?php get_footer(); ?>
If it finds nothing, it will go into the else: but if it do finds something they display all the pages (fullpage) of what it finds out there.
It should only display the_title(); but no..
Even if I completly destruct the search.php file it stills automaticly goes to the "suggested" page.
First time I am getting this kind of thing and I do not know how to solve it :(
It's calling for the post before the title, which is why it pulls for the full post.
Try:
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_title(); ?>
<?php endwhile; ?>
<?php else : ?>
I'm trying to style a search page in wordpress. In search.php I can style most of the page but then the following statement (which I got from the original uneditted page) generates the content.
<?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', get_post_format() );
?>
<?php endwhile; ?>
This ALMOST displays the page as I want it, but there are a few elements off the page, making it expand etc. I can't figure out what file is generating this content!
Using the instructions I created a content-search.php and change the line of code to this...
get_template_part( 'content', get_post_format() );
Which works...but it doesn't display much of anything because I don't know what to put in my page within seeing the original.
Anyone have any clue?
You can use a template part named post-search.php and can use it inside your search.php file like
get_template_part( 'post' , 'search')
but you have to create a php file inside your theme folder and name it post-search.php and inside this file just put the WordPress' loop i.e.
<?php while (have_posts()) : the_post(); ?>
<div class="post-entry clearfix"> <!-- Main wrapper -->
<div class="post-entry-content"> <!-- Post-entry-content -->
<h2><?php the_title(); ?></h2>
<div class="post-entry-date">Posted on <?php the_time('F Y') ?> with <?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?></div>
<?php the_excerpt(); ?>
Read More ?
</div><!-- END of post-entry-content -->
</div><!--End of main wrapper -->
<?php endwhile; ?>
and your search.php could be something like this
<?php get_header(' '); ?>
<div id="post-wrap">
<div id="post-content">
<?php if (have_posts()) : ?>
<?php get_template_part( 'post' , 'search') ?> // This will load/include the file post-search.php and result will be displayed as formatted in this file
<?php else : ?>
<p>Sorry, it does not exist !</p>
<?php endif; ?>
</div><!-- END post-conten -->
<?php get_sidebar(' '); ?>
</div><!-- END post-wrap -->
<?php get_footer(' '); ?>
This is just an example, change div/h2 id/class names according to your theme css.
Note: I'm currently using this approach in one of my site and I've one file named 'post-entry.php' in my theme folder and in my every template file (index.php, search.php e.t.c) I just use this file by calling
<?php get_template_part( 'post' , 'entry') ?>
So I have a page called "latest news" and using a custom template t_latest_news.php
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="latest-news" id="post-<?php the_ID(); ?>">
<?php the_content(); ?>
<?php edit_post_link('Edit this page','<p class="edit-link">','</p>'); ?>
</div><!-- /.latest-news -->
<?php endwhile; endif; ?>
I've created a page item and put some content into that page. Now, I want to show the content on the sidebar. How can I do that please?
I've tried something like:
<?php include(get_query_template('t_latest_news.php')); ?>
<?php include(TEMPLATEPATH . 't_latest_news.php'); ?>
<?php get_query_template('t_latest_news.php') ?>
<?php get_template_part( 't_latest_news.php' ); ?>
But none of them works. HELP!
<?php query_posts('page_id=76'); ?>
<?php while (have_posts()) { the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php } ?>
<?php wp_reset_query(); ?>
It works with "page_id" but not pagename. any idea?
To query a specific page by name you do this:
<?php
query_posts('pagename=about'); //retrieves the about page only
?>
You should remove the .php at the end so that it reads t_latest_news
I was just showing this as an example, please be advised:
The query_posts function is intended to be used to modify the main page Loop only. It is not intended as a means to create secondary Loops on the page. If you want to create separate Loops outside of the main one, you should use get_posts() instead. Use of query_posts on Loops other than the main one can result in your main Loop becoming incorrect and possibly displaying things that you were not expecting.
see: http://codex.wordpress.org/Template_Tags/get_posts for more information