I have been working on a custom archive page but I have run into some trouble. The pagination is shifting down into the footer area.
I have gone through my code several times and I cannot work out why this is happening. If I remove the loop, the template works correctly.
With the loop in place, the pagination shifts down to the footer and takes any coding below it (in the archive page) with it.
The archive page coding is:
<?php get_header(); ?>
<main role="main">
<section class="commissions">
<div class="commissions-section-one">
<h1>Commissions</h1>
<?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('commissions-intro')) ?>
</div>
<?php get_template_part('single-commissions'); ?>
<?php get_template_part('pagination'); ?>
</section><!-- /section -->
</main><!--/ Main -->
<?php get_footer(); ?>
The custom loop code is:
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<div class="commission-wrapper">
<div class="commission-inner cf">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="commission-content-wrapper">
<div class="commission-content-inner">
<img src="<?php the_field('commissions-company-logo'); ?>" />
<h2 class="company-author"><?php the_title(); ?></h2>
<p class="company-location"><?php the_field('commissions-company-location'); ?></p>
<p class="company-description"><?php the_field('commissions-company-description'); ?></p>
<p class="company-date"><?php the_field('commissions-company-date'); ?></p>
<?php echo do_shortcode("[indeed-social-media sm_list='fb,tw,goo,li' sm_template='ism_template_10' sm_list_align='horizontal' sm_display_counts='false' sm_display_full_name='false ]");?>
</div><!--/ Commission Content Inner -->
</div><!--/ Commission Content Wrapper -->
</article><!--/ Article -->
<div class="commission-images">
<div class="row first cf">
<div class="left-column" style="background-image:url(<?php the_field('commissions-image-one'); ?>);"></div>
<div class="right-column" style="background-image:url(<?php the_field('commissions-image-two'); ?>);"></div>
</div><!--/ Row -->
<div class="row cf">
<div class="left-column" style="background-image:url(<?php the_field('commissions-image-three'); ?>);"></div>
<div class="right-column" style="background-image:url(<?php the_field('commissions-image-four'); ?>);"></div>
</div><!--/ Row -->
</div><!--/ Commission Images -->
</div><!--/ Commission Inner -->
</div><!--/ Commission Wrapper -->
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h1><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h1>
</article>
<!-- /article -->
<?php endif; ?>
<?php get_footer(); ?>
I am using the HTML 5 blank theme and haven't added anything additional in regards to pagination.
I'm not sure what you're doing with this line...
<?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('commissions-intro')) ?>
...since you're not outputting anything. I'd either get rid of it, or fix it so that it's a valid conditional (with an endif;).
It also looks like you're calling get_footer() twice...
Related
<?php get_header(); ?>
</div><!--END CONTAINER-->
<?php
if (get_field('header_image')){
$image = get_field('header_image');
if (get_field('do_not_use_page_title')){
$title = get_field('alternate_page_title');
}else {
$title = get_the_title();
}
if (get_field('subheading')) $subheading = get_field('subheading');
?>
<div class="page-header" style="background-image: url(<?php echo $image['url']?>);">
<?php echo "<h1>$title</h1>"; ?>
<?php if ($subheading) { echo "<h2>$subheading</h2>";} ?>
</div>
<?
}
?>
<div class="container">
<div id="content" class="clearfix row">
<div id="main" class="col-sm-8 clearfix" role="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
<?php if (!(get_field('header_image'))) { ?>
<header>
<div class="page-header"><h1 class="page-title" itemprop="headline"><?php the_title(); ?></h1></div>
</header> <!-- end article header -->
<?php } ?>
<section class="post_content clearfix" itemprop="articleBody">
<?php the_content(); ?>
</section> <!-- end article section -->
</article> <!-- end article -->
<?php endwhile; ?>
<?php else : ?>
<article id="post-not-found">
<header>
<h1><?php _e("Not Found", "wpbootstrap"); ?></h1>
</header>
<section class="post_content">
<p><?php _e("Sorry, but the requested resource was not found on this site.", "wpbootstrap"); ?></p>
</section>
<footer>
</footer>
</article>
<?php endif; ?>
</div> <!-- end #main -->
</div> <!-- end #content -->
When creating a new page in WP I get an error
Parse error: syntax error, unexpected end of file in /home/example.com/example/public_html/wp-content/themes/exampletheme/page.php on line 69
I haven't been able to find any errors in the php that would trigger this parse error. Other pages that were already present on the website work fine, but making new pages and then viewing/previewing them brings an empty page with the above error. Any help would be appreciated, Thanks.
I created my own template in WordPress, but the loop entries does not work. I would like to entries work on one of the subpages. I also added entries.
This is my code of my subpage. Please help me. I don't know what is wrong. I added a picture under the code.
<?php include 'header.php'; ?>
<main class="subpage-blog">
<div class="subpage-banner">
<div class="container">
<h3>BLOG SIDEBAR</h3>
<div class="breadcrumbs">
</div>
</div>
</div>
<aside class="side-menu col-md-4">
<div class="search">
<h4>Search blog</h4>
<input type="text" value="Search">
</div>
<!-- .search -->
<div class="categories">
<h4>Blog Categories</h4>
<ul class="categories-blog-ul">
<li>Inspirtation</li>
<li>Work</li>
<li>Tech</li>
<li>Creative</li>
</ul>
</div>
<!--.categories-->
<div class="recent-posts">
<h4>Recents posts</h4>
<ul>
</ul>
</div>
<!-- .recent-posts-->
<div class="tags-spot">
<h4>Tags</h4>
<div class="tag"></div>
</div>
<!-- .tags-spot-->
</aside>
<!-- .side-menu-->
<article class="content">
<div class="container">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="news-box">
<div class="news-list-content">
<a href="">
<h3><?php the_title(); ?></h3>
<?php the_content('czytaj dalej'); ?>
</a>
</div>
<!-- .news-list-content-->
<div class="image-box-news">
<img src="<?=get_template_directory_uri(); ?>/images/ikona-wpisu.png" alt="" />
</div>
</div>
<!-- .news-box-->
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div>
<!-- .container-->
</article>
<!-- .content-->
</main>
<?php include 'footer.php'; ?>
The problem is that:
if (have_posts()) : while (have_posts()) : the_post();
is using the current page's have_posts query.. That means that it probably will just show whatever that current page template's content would be.
Instead, you'll want to create an entirely new query object and call these functions on it like so:
<?php
$the_query = new WP_Query( array('posts_per_page' => 10 ) ); //Create our new custom query
if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
<div class="news-box">
<div class="news-list-content">
<h3><?php the_title(); ?></h3>
<?php the_content('czytaj dalej'); ?>
</div>
<!-- all your other markup goes here.... -->
</div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php wp_reset_postdata(); //Restore the original postdata for this page, if needed later ?>
I created custom theme with WordPress and bootstrap and everything works fine except previous and next link in singe.php.
Here is my code:
<?php get_header(); ?>
<article>
<div class="container single-project">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<div class="row">
<div class=" col-md-4 col-lg-4 pull-right">
<header class="entry-header">
<h1 id="post-<?php the_ID(); ?>"><?php the_title();?></h1>
<hr>
</header><!-- .entry-header -->
</div>
<div class=" hidden-md hidden-lg"><hr></div>
<div class="col-md-4 col-lg-4"><?php the_content(); ?></div>
<?php previous_posts_link() ?>
<?php next_posts_link() ?>
</div> <!-- end of row -->
</div> <!-- end of container -->
<?php endwhile; endif; ?>
</article>
<?php get_footer(); ?>
Thanks in advance.
You have to move
<?php previous_posts_link() ?>
<?php next_posts_link() ?>
after
</article>
preferably inside some div so you can style it, like
<div class="navi">
<?php previous_posts_link() ?>
<?php next_posts_link() ?>
</div>
Found solution:
<?php previous_post('« « %', 'Previous Post', 'yes'); ?> |
<?php next_post('% » » ', 'Next Post', 'yes'); ?>
http://wpsites.net/web-design/previous-next-single-post-navigation-links-wordpress/
I'm working on making fixes to someones wordpress site, and i encountered this strange code in the loop.php and in a template file for a specific page. My goal is to change this to display the featured image in the header.I did some research into how to output the featured image using the get_thumbnail syntax, I don't normally do much in the back end / FTP of wordpress so thank you for your help and patience.
<?php
/**
* #package WordPress
* #subpackage WP-Skeleton
*/
?>
</div>
<div id="primary">
<div id="content">
**<?php the_post(); ?>
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID('full') ), 'page-header' );
$url = $thumb['0'];?>
<div id="page-header" style="background-image:url('<?php echo $url; ?>');">**
</div>
<div style="clear"></div>
<div class="container">
<section class="sixteen columns alpha">
<header class="entry-header">
<h2 class="entry-title">Events</h2>
</header>
<div class="entry-content ">
<?php while ( have_posts() ) : the_post(); ?> <!-- the Loop -->
<article id="post-<?php the_ID(); ?>" class="event">
<div class="title">
<?php the_title('<h3>', '</h3>'); ?> <!--Post titles-->
</div>
<div class="event-img"><?php the_post_thumbnail('event-img'); ?></div>
<?php the_content("Continue reading " . the_title('', '', false)); ?> <!--The Content-->
</article>
<?php endwhile; ?><!-- End the Loop -->
</div>
</section>
<div>
</div> <!-- End two-thirds column -->
</div><!-- End Content -->
</diV>
If you want to display the featured image inside the header, use the below code in it.
<?php
if(have_posts()) :
while (have_posts()) : the_post();
the_post_thumbnail();
endwhile;
endif;
?>
I'm actually trying to display the post thumbnail inside the loop just before the content by using the_post_thumbnail(); function.
It works like a charm in anywhere in my page before I call the function
<?php get_sidebar(); ?>
After that impossible to show the post thumbnail.
I've tried with
<?php the_post_thumbnail(); ?>
and also
<?php echo get_the_post_thumbnail(); ?> but nothing happens.
Here is my whole code :
<?php
/**
* The Template for displaying all single posts
*
* #package WordPress
*/
get_header(); ?>
<div id="pageHeader" >
<div id="pageHeader-inner"> <span class="shadow"></span><img src="<?php bloginfo('template_url'); ?>/images/header_01.jpg" /></div>
</div>
<div class="container" id="pageTitle">
<h1><?php the_title(); ?></h1>
</div>
<!--Begin of content-->
<div class="grey-bg">
<div class="container">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="row">
<div class="col-sm-3 sidebar">
<!-- Sub Nav -->
<?php if ( is_page() ) { ?>
<?php
if($post->post_parent)
$children = wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0'); else
$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
if ($children) { ?>
<div class="sidebar-module sub-menu">
<ul>
<?php echo $children; ?>
</ul>
</div>
<?php } } ?>
<!--Works perfectly till here -->
<?php get_sidebar(); ?>
<!--Broken till here-->
</div> <!-- /.sidebar -->
<div class="col-sm-9">
<div class="content-main">
<div class="content white-bg left-stroke <?php echo $post->post_name; ?>">
<?php if ( has_post_thumbnail() ) the_post_thumbnail(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php else : ?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<h1>Not Found</h1>
</div>
<?php endif; ?>
</div> <!-- /.content -->
</div><!-- /.content-main -->
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container -->
</div>
<?php get_footer(); ?>
Thank's a lot for your responses.
You are trying to use function the_post_thumbnail() outside WordPress loop. To use this function outside loop you have to specify "post ID". Documentation for this function http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail
For example to get thumbnail for post ID 4 you have to use function with parameter 4 like the_post_thumbnail(4) or store ID in variable.