Wordpress Archive page completely blank - php

I have the following archive page setup:
<?php
get_header(); ?>
<div id="container">
<div id="content" role="main">
<?php the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php get_search_form(); ?>
<h2>Archives by Month:</h2>
<ul>
<?php wp_get_archives('type=monthly'); ?>
</ul>
<h2>Archives by Subject:</h2>
<ul>
<?php wp_list_categories(); ?>
</ul>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
However, the page is completely white when I load the archive page. It is a new site with no plugins, and all the other pages are working fine. Any idea?

For some weird reason, the archive became visible when i added the code to the index.php file.

Related

Customise wordpress theme search.php to include product image

I want my search results to show an image of the product. Currently the search results only show a text link. My wordpress theme is Intuition Pro and the website is https://heritagecountrypottery.com. I am also using the Ivory search wordpress plugin
<?php get_header(); ?>
<div id="main" class="main">
<div class="container">
<section id="content" class="content">
<?php do_action('cpotheme_before_content'); ?>
<?php if(have_posts()): while(have_posts()): the_post(); ?>
<article class="search-result" id="post-<?php the_ID(); ?>">
<h4 class="search-title heading">
<?php the_title(); ?>
</h4>
<div class="search-byline">
<?php the_permalink(); ?>
</div>
</article>
<?php endwhile; ?>
<?php cpotheme_numbered_pagination(); ?>
<?php endif; ?>
<?php do_action('cpotheme_after_content'); ?>
</section>
<?php get_sidebar(); ?>
</div>
</div>
<?php get_footer(); ?>
I have searched online for a solution but have not found one that works with my theme
You can get the post thumbnail like this
<?php if ( has_post_thumbnail() ): ?>
<div class="search-thumbnail">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
</a>
</div>
<?php endif; ?>
You can add it before the heading, but you need to figure out the CSS rules you have to apply to make it looks good.

link to archive.php in wordpress

I have the following code in my single.php which outputs the following links
<div class="dt"><?php echo get_the_date();?></div>
<div class="cat">
<?php the_category(', ');?>
</div>
<div class="tag">
<?php the_tags();?>
</div>
<div class="arc">
Archives
</div>
both links to category and tag are working producing output via category.php and tag.php, however, I can't figure it out how to link to archive.php where I plan to show post archive
Just to let you know there is no full archive page like you describe created by default.
Refer to this link: https://codex.wordpress.org/Creating_an_Archive_Index
<?php
/*
Template Name: Archives
*/
get_header(); ?>
<div id="container">
<div id="content" role="main">
<?php the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php get_search_form(); ?>
<h2>Archives by Month:</h2>
<ul>
<?php wp_get_archives('type=monthly'); ?>
</ul>
<h2>Archives by Subject:</h2>
<ul>
<?php wp_list_categories(); ?>
</ul>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Access the archives like this:
<?php wp_get_archives('type=yearly'); ?>

wordpress footer.php will not appear in single.php

My footer.php file will pull into every page except the single.php, I have no idea why this is occurring! Any ideas?
Below is the Single.php code
<?php get_header(); ?>
<div class="page-content">
<div class="small-banner">
<h1><?php the_title(); ?></h1>
<img src="http://www.quorngrangehotel.local/wp-content/uploads/2017/04/new-events-banner.jpg">
</div>
<main role="main" class="mainContent">
<div id="inner-content" class="row">
<main id="main" class="large-8 medium-8 columns" role="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'parts/loop', 'single' ); ?>
<?php endwhile; else : ?>
<?php get_template_part( 'parts/content', 'missing' ); ?>
<?php endif; ?>
</main> <!-- end #main -->
</div> <!-- end #inner-content -->
</main><!-- end #content -->
<?php get_footer(); ?>
I found out the issue it was something to do with the comments section being pulled in via the single template part!

Single.php showing blank page

I'm trying to build a theme of my own and uploading it to Wordpress, but my single.php file it's not working at all. It's just showing a blank page. I've tried so many things to get it to work, but now I don't know what to do anymore. This is my php-file for the blog page:
<?php
/**
*Template Name: Blog Posts
*/
get_header('header4'); ?>
<section id="headerbox">
<header>
<h2 class="referensrubrik">Nyheter</h2>
</header>
<p class="referenstext">Det senaste från AL Konsult.</p>
</section>
<main id="blog">
<?php // Display blog posts on any page # http://m0n.co/l
$temp = $wp_query; $wp_query= null;
$wp_query = new WP_Query(); $wp_query->query('showposts=5' . '&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<article id="blogpost" id="post-<?php get_the_ID(); ?>" <?php post_class(); ?>>
<h2><?php the_title(); ?></h2>
<h5><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></h5>
<?php the_excerpt(); ?>
<hr>
</article>
<?php endwhile; ?>
<?php if ($paged > 1) { ?>
<nav id="nav-posts">
<div class="prev"><?php next_posts_link('« Previous Posts'); ?></div>
<div class="next"><?php previous_posts_link('Newer Posts »'); ?></div>
</nav>
<?php } else { ?>
<nav id="nav-posts">
<div class="prev"><?php next_posts_link('« Previous Posts'); ?></div>
</nav>
<?php } ?>
<?php wp_reset_postdata(); ?>
</main>
<?php get_footer(); ?>
Now my single.php just looks like this (I've tried the loop, but it's just not working...):
<?php
/**
* The Template for displaying all single posts.
*/
get_header('header3'); ?>
<section id="headerbox">
<header>
<h2 class="referensrubrik">Rubrik</h2>
</header>
<p class="referenstext">Text</p>
</section>
<?php
error_reporting(-1);
?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content(); ?>
</div>
</article>
<?php endwhile; ?>
<?php get_footer(); ?>
What am I doing wrong!?
I fixed it! The single.php code that works for me looks like this:
<?php
/**
* The Template for displaying all single posts.
*/
get_header('header3'); ?>
<section id="headerbox">
<header>
<h2 class="referensrubrik">Rubrik</h2>
</header>
<p class="referenstext">Text</p>
</section>
<?php
$post = $wp_query->post;
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<article id="blogpost" id="post-<?php get_the_ID(); ?>" <?php post_class(); ?>>
<h2><?php the_title(); ?></h2>
<h5><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></h5>
<?php the_content(); ?>
<hr>
</article>
<?php endwhile; ?>
<?php if ($paged > 1) { ?>
<nav id="nav-posts">
<div class="prev"><?php next_posts_link('« Äldre inlägg'); ?></div>
<div class="next"><?php previous_posts_link('Nyare inlägg »'); ?></div>
</nav>
<?php } else { ?>
<nav id="nav-posts">
<div class="prev"><?php next_posts_link('« Äldre inlägg'); ?></div>
</nav>
<?php } ?>
<?php wp_reset_postdata(); ?>
<?php get_footer(); ?>
Your template tag is outside of the block.
<!-- /*
Template Name: Blog Posts
*/ -->
<?php
It should be:
<?php
/*
Template Name: Blog Posts
*/
Make sure there are no blank spaces or carriage returns outside the tags (especially in WP page templates): The spaces/carriage returns will cause the page not to render by throwing an exception (which you are likely not seeing because you dont have reporting enabled).
Specifically I am referring to this:
<!-- /*
Template Name: Blog Posts
*/ -->
It needs to be inside the opening PHP tag, and there should be no empty lines at the top of the page.
It should look like (no empty line breaks):
<?php
/**
* The Template for displaying all single posts.
*/
require_once('../../../wp-load.php');
get_header('header3'); ?>
Remove the following line from your code:
require_once('../../../wp-load.php');

Coding after WordPress loop not showing

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...

Categories