I'm working on a custom WP theme with a blog page. The Blog page is showing the posts but when you click on each post, it takes you to an empty page.
I've set: Settings > Post Page > Blog
Basically, blog page displays all content but BLOG POST page is blank. Here's my index.php.
<div class="header-img-container container-fluid">
<img
class="header-img"
role="banner"
src="http://cc.local/wp-content/uploads/2020/04/blog-page.jpg"
>
<hr class="horizontal-line">
</div>
<div class="container">
<div class="row">
<div class="col">
<div class="vertical-center">
<form action="http://cc.fullslate.com/">
<button class="appointment-button btn button">Schedule</button>
</form>
</div>
<p class="page-body-title">Blog</p>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php
if ( have_posts() ) {
// Load posts loop.
while ( have_posts() ) {
the_post();
get_template_part( 'template-parts/content/content' );
}
// Previous/next page navigation.
//cc_the_posts_navigation();
} else {
// If no content, include the "No posts found" template.
get_template_part( 'template-parts/content/content', 'none' );
}
?>
</main><!-- .site-main -->
</div><!-- .content-area -->
</div>
</div>
</div>
If you want to edit the view of a single post, you need to use the single.php
Find out more about template hierarchy in wordpress:
https://developer.wordpress.org/themes/basics/template-hierarchy/
Here is what it should look like:
https://developer.wordpress.org/themes/template-files-section/post-template-files/
You can adjust this single.php to your needs, it will work as it is because of the post loop in it.
Related
I have 3 to 4 categories on my website. I am using WordPress search but when I am searching my category then I am getting
Nothing Found
also, I tried to search the subcategory then also I am getting the same message.
Would you help me out with this issue?
search.php
<section id="primary" class="content-area mainSearch">
<main id="main" class="site-main">
<div class="equalPadding">
<div class="cp-seeWrapper">
<?php if ( have_posts() ) :
get_search_form();//search form
?>
<div class="resultCount"><?php
global $wp_query;
echo $wp_query->found_posts.' RESULTS';
?></div>
<div class="row">
<?php
while (have_posts()){the_post();?>
//displaying result here
<?php } ?>
<?php
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
</div>
</div>
</div>
</main><!-- #main -->
</section><!-- #primary -->
WordPress does not include category names to search results by default. You should do this by yourself. Previously discussed here.
You can not search the category You can only search the content of the category...
My Wordpress blog works fine on the main page that shows all posts, however, when I click a category the most recent post's title becomes the main header and that post doesn't even show up in the blog post list of that category.
https://ibb.co/ebReRV
I spied on other people with the same theme as me and they have the same problem so I believe this is a problem with the original code. My theme's creator seems to have disappeared and hasn't responded to any of my messages.
archive.php
<section id="wp-main-content" class="clearfix main-page title-layout-standard">
<?php do_action( 'naturalfood_before_page_content' ); ?>
<div class="container">
<div class="main-page-content row">
<!-- Main content -->
<div class="content-page <?php echo esc_attr($main_content_config['class']); ?>">
<div id="wp-content" class="wp-content">
<?php get_template_part('templates/layout/archive') ?>
</div>
</div>
You Need to Create Archive Page
Give Archive Page name is "archive.php".
Archive Page Structure Like this:
<?php
/*
Template Name: Archives
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content(); ?>
/* Custom Archives Functions Go Below this line */
/* Custom Archives Functions Go Above this line */
</div><!-- .entry-content -->
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
For some reason my footer disappeared for my site http://juliannaspizza.com.
I checked the template file for the home page and get_footer is being called as shown below. Any idea why my footer is still not showing up?
<?php
/**
* Template Name: Full Width Page
*
* #package Fortune
*/
get_header();
get_template_part( 'parts/single', 'page-header' ); ?>
<div class="container full-width-page">
<div class="row">
<div id="primary" class="content-area col-lg-12">
<main id="main" class="site-main" role="main">
<?php
while ( have_posts() ) : the_post();
get_template_part( 'content', 'page' );
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile; ?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .row -->
</div><!-- .container -->
<?php
get_footer();
This is what my footer used to look like (https://certifagift.blog/):
Your widgets are gone. From the markup, it looks like your footer (which does appear) is expecting to have widgets, but those are not appearing. Go to Appearance -> Widgets in your dashboard and add your widgets back in, and you should be good.
I am trying to establish 2 x custom page templates for a site using Zerif Pro on Wordpress 4.7.3
I have created the template files but can't get the layout I want.
I am trying to get a full-width template where the content appears directly below the navbar.
Using inspect element I can edit the CSS to
.content-left-wrap {
padding-top: 0px;
}
And get the desired look, but I can't figure out what to change in my fullwidth.php file or where to put it.
Template Code Below:
<div class="clear"></div>
</header> <!-- / END HOME SECTION -->
<?php zerif_after_header_trigger(); ?>
<div id="content" class="site-content">
<div class="container">
<div class="content-left-wrap col-md-12">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'content', 'page-no-title' );
/* If comments are open or we have at least one comment,
load up the comment template */
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
endwhile;
?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .content-left-wrap -->
</div><!-- .container -->
<?php
get_footer();
?>
Edit fullwidth.php Add another class to this div like this
<div class="content-left-wrap wrap-new col-md-12">
and then add css to the template css file using the new class
.wrap-new
{
.content-left-wrap {
padding-top: 0px;
}
}
I created a custom theme for word-press. When i say 'add new' page and i put content into this page it only displays the footer and header but dosnt hook my content which is in the CMS on that page.
This is what i have : page.php
<?php get_header(); ?>
<div class="row">
<div class="col-sm-12">
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile; endif;
?>
</div> <!-- /.col -->
</div> <!-- /.row -->
<?php get_footer(); ?>
Its been a long day what am i doing wrong here. Any tips please?
Would also like to make like a parent page from this new page, but its only option with page attributes are 'default template'.
If you didn't have a template part please use the_content() instead of
get_template_part( 'content', get_post_format() );
My actual problem, resolved. So i used 'advanced custom field' plugin for my WordPress. The problem using this is that it still requires you to do some coding.
I added a new page.
For that page I had an header image and content. So for ACF(advanced custom field) that is equal to two field types "Image --> field type and Text-Area --> field type"
Field name is what i used to call the fields to my .php page template.
Field Name : Image = header-image
Field Name : (2)Text Area = header-image-text-top (and) header-image-text-author
(I needed to display my text on the image thats why my div is just based on header image.)
So I hooked my page template and then added the the hooks for the fields i want to display on this page template.
page-stay.php :
<?php
/*Template Name: Stay - Parent Page */
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<article id="post=<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- <header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header>(you can use this if you need your page header to display)-->
<div class="enry-content">
<?php
$image = get_field('header-image');
if( !empty($image) ): ?>
<div class="head-image">
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<div class="head-text-box">
<div class="head-text-box-holder">
<p class="headtext-quote"><?php the_field('header-image-text-top'); ?></p>
<p class="headtext-author"><?php the_field('header-image-text-bottom'); ?></p>
</div>
</div>
</div>
<?php endif; ?>
</article>
<?php endwhile; ?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_footer(); ?>