When I'm logged in to my site, viewing an individual post, the right sidebar displays perfectly, but when I log out on the same page (via the sidebar widget), the right sidebar suddenly ends up below my comments. This only happens with I'm viewing individual posts. Any ideas what causing this?
I've double checked the CSS, and as far as I can tell being logged out doesn't add or change any class attributes. Also - the theme I'm working with doesn't have a posts.php file...
Post: http://www.wespeakfashion.com/cool-sunglasses
page.php...
<?php include (TEMPLATEPATH . '/header.php'); ?>
<div id="content">
<?php include(TEMPLATEPATH."/l_sidebar.php");?>
<div id="contentleft">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(__('Read more'));?><div style="clear:both;"></div>
<!--
<?php trackback_rdf(); ?>
-->
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
<?php posts_nav_link(' — ', __('« go back'), __('keep looking »')); ?>
</div>
<?php include(TEMPLATEPATH."/r_sidebar.php");?>
</div>
<!-- The main column ends -->
<?php get_footer(); ?>
The right sidebar appears to be in the main content div. This is suspicious because the left sidebar is a sibling of the main content div. Try taking the right sidebar out of there, and putting it as a sibling of the left sidebar and main content div.
Related
I am currently using the cubic theme and ran into some trouble with template creation. I have multiple sections on my site and am trying to replicate the functionality of my home page onto another page where ideally the home page would display featured articles and another page for urban exploration would be able to display posts about urban exploration in the same format. I.e. Images with nicely displayed titles in rows of three link to posts I have created.
So far this is what my template looks like:
<?php /* Template Name: Page Directory */ ?>
<?php get_header(); ?>
<?php the_content(); ?>
<div id='primary' class='content-area'>
<main id='main' class='site-main' role='main'>
</main><!-- .site-main -->
<?php get_sidebar( 'content-bottom' ); ?>
</div><!-- .content-area -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
This allows me to display the header with the integrated side bar and footer, but I cannot figure out how to replicate cubic's home page functionality.
I imagine the PHP function would have to query for tags in order to place the post on the page, then look for a post's featured image and title to display it as a square image covering 1/3 of the page. Any help would be greatly appreciated.
Update:
I found you can use WP_Query to create a loop to pull information then display it using get_template_part as a means of formatting the post information. I can now display the images for my posts however the formatting is off because of the way content.php is written. [Do any users of cubic (a child theme in WordPress) know how the homepage is constructed and how I might be able to reference that file so I can recreate its format on a different page in WordPress?]
<?php /* Template Name: Page Directory */ ?>
<?php get_header(); ?>
<?php the_content(); ?>
<main id='main' class='site-main' role='main'>
<?php
$postid = new WP_Query( array( 'tag' => 'featured' ) );
if( $postid->have_posts() ):
while( $postid->have_posts() ): $postid->the_post(); ?>
<?php get_template_part('content',get_post_format()); ?>
<?php endwhile;
endif;
?>
</main><!-- .site-main -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
You need to add the loop which fetches the posts:
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
I am following along with this tutorial and what I have made so far is not working as it should. I have gotten to the point where I am starting to use the loop - this is my code:
index.php
<?php get_header(); ?>
<div class="row">
<div class="col-sm-8 blog-main">
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile; endif;
?>
</div><!-- /.blog-main -->
<?php get_sidebar(); ?>
</div><!-- /.row -->
<?php get_footer(); ?>
</div><!-- /.container -->`
content.php
<div class="blog-post">
<h2 class="blog-post-title"><?php the_title(); ?></h2>
<p class="blog-post-meta"><?php the_date(); ?><?php the_author(); ?></p>
<?php the_content(); ?>
</div><!-- /.blog-post -->
I have two posts but only the latest post is getting displayed (by the loop) and within the post that gets displayed - the only part that is displayed is the title. So it seems like the_date(), the_author(), and the_content() functions are not working for some reason, and the loop is only getting one of the posts (the latest one).
What is wrong? Thanks.
I'm not sure what I did, but I went to WP admin and clicked "customize" for the theme, and it loaded correctly in the theme editor - and then I went to the site, and it was working. I think maybe I didn't save a file, and I didn't realize it - and as I was trying to figure it out, I ended up saving the file, and it started working.
I've made my first theme and it works great for editing updating pages etc, but won't display any posts.
I have put the "loop" in a template page (copied from twentytwelve theme), as I only want the posts to appear on that page. I've set the blog posts to appear on this page (from the settings page), but still nothing will show.
Here is my code for the template page to display blog posts.
Any idea what's wrong?
<?php
/**
* Template Name: blog
*
* Full width page template with no sidebar.
*
* #package Myfirsttheme
* #subpackage Template
*/
get_header(); ?>
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<div class="entry-content">
<p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
<?php endif; // end current_user_can() check ?>
</article><!-- #post-0 -->
<?php endif; // end have_posts() check ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
Posts will always appear in the index.php template, unless you change the "Front page displays" option in Settings=>Reading, see here for example: http://imgur.com/izwa5yw If you have this set to show the blog posts on a page (is in the image), then whatever page that is (blog) has to have the Default Template (in the page edit screen) set to the value you wrote in the Template Name: section of your file (in your case blog), as Tamil said.
Updated: You have to echo get_template_part() or it won't show up. You can use the_content() instead which is preferred. Any variables that start with the_ output themselves. The get_ variables don't output themselves.
<?php echo get_template_part(); ?>
<?php the_content() ?>
I have a categories page in Wordpress and it has its own template categories.php, which is actually a static page with boxes that link to specific categories. This is a shortened code:
<?php
/*
Template Name: Categories
*/
?>
<?php get_header(); ?>
<nav><?php wp_nav_menu(array('menu' => 'Main Nav Menu')); ?></nav>
<div id="main-content-categories">
<h5 class="inner_text_shadow">Categories & Tags</h5>
<div id="clear-box">
<div id="cc" class="c1"><h6>The Fall Locations</h6></div>
<div id="cc" class="c2"><h6>Info</h6></div>
<div id="cc" class="c3"><h6>Budget</h6></div>
</div> <!-- END main-content -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
CSS doesn't matter.
My question is - which PHP file/template is used for those posts that are in certain category like www.mywebsite.com/category/budget? When I click any of the boxes I do get the posts that are in that category but there's no formatting, just the header, sidebar and footer. What is the actual code for "posts from category" and what PHP file do I input it to?
[Same question goes for tags. (www.mywebsite.com/tag/food)]
The category.php can handle all categories. See my example below:
<?php get_header(); ?>
<?php
//Get Category
$category = get_category(get_query_var('cat'));
?>
<!-- Start Loop -->
<?php query_posts('category_name=' . $category->cat_name . '&paged='. get_query_var('paged')); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!-- Loop Code Here -->
<?php endwhile; else: ?>
<p>An Error Occurred</p>
<?php endif; ?>
<?php wp_reset_query(); ?>
<!-- End Loop -->
<?php get_footer(); ?>
You can also have separate files for each category in the format category-slug.php. In your case you would have category-locations.php, category-info.php & category-budget.php
Hope this helps.
Problem page: www.kendraschaefer.com/mandapop (problem with images in thin middle column)
Hi,
I'm working on a new Wordpress template, and I've run into an issue with Fancybox. I'm trying to get the pictures in the thin middle column of the page above to, when clicked on, pop up in fancybox with attached post data.
It's mostly working OK - on first click, no problem. Click an image, post pops up in a fancybox. But close the fancybox and try again, and you'll notice that the post loads once, then loads again. Click on aother, and this time the post loads multiple times. (Don't click too many times, your browser will freak). Sounds like a recursion problem, but I'm not sure where I'm going wrong.
I tried using other pop-up plugins, like Facebox and Lightbox, with the same problem, so it must be my loop or something. I also commented out all other javascript on the page to see if there was a conflict - still had the problem.
Here's my code (there are two loops - one for the gallery images and one for the blog entries):
<div id="homeGalleryCol">
<div id="homeGalleryContent">
<?php
query_posts('post_type=galleryimage&posts_per_page=7');
if(have_posts()) : while(have_posts()) : the_post(); ?>
<div class="singlePhotoPost">
<h3 class="galleryListDate"><?php the_time('M d'); ?></h3>
<?php the_post_thumbnail('gallery-pic-thumbnail'); ?>
</div><!-- end singlePhotoPost -->
<?php endwhile; ?>
<?php endif; ?>
</div><!-- end homeGalleryContent -->
</div><!-- end homeGalleryCol -->
<div id="thinRightCol">
<div id="rightColContent">
<div id="blogListColWrapper">
<div id="blogListCol">
<?php
query_posts('posts_per_page=3');
global $more;
$more = 0;
if(have_posts()) : while(have_posts()) : the_post(); ?>
<div class="singlePost">
<h3 class="blogListDate"><?php the_time('M d'); ?></h3>
<?php the_post_thumbnail(); ?>
<h2 class="postTitle"><?php the_title(); ?></h2>
<?php the_content('<span class="moretext"> </span>'); ?>
</div><!-- end singlePost -->
<?php endwhile; ?>
<?php endif; ?>
</div><!-- end blogListCol -->
</div><!-- end blogListColWrapper -->
</div><!-- end rightColContent -->
</div><!-- end thinRightCol -->
Thanks much.
It seems that you've removed the actual output. Can you restore it and I'll let you know what's going on? Thanks.
Try with this function <?php wp_reset_postdata(); ?>
Because this function is used to restore the global $post variable of the main query loop after a secondary query loop using new WP_Query. It restores the $post variable to the current post in the main query.
Example: http://pastebin.com/kSEg5JPg
Pay attention to <?php wp_reset_postdata(); ?>
Hope that will help you