including a template within another template in wordpress - php

I am developing a very simple wordpress project. One of the page will have thumbnails of my projects and some texts and when I will click on the thumbnails it will land me to the page corresponding to the project. I created a template where i am trying to include another template which will just hold the thumbnails. I want to be able to update the thumbnails and text from two different pages from the wordpress dashboard. This is what I have so far...the concept is kinda goofy...let me know if i explained it correctly
lets say this is the rendering template
<?php
/*
Template Name: projects
* This template displays project thumbnails and introductory copy as a rendering template
*/
$options = twentyeleven_get_theme_options();
$current_layout = $options['theme_layout'];
get_header();?>
<div id="primary">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<? /*php comments_template( '', true ); */?>
<?php endwhile; // end of the loop. ?>
<?php get_template_part( 'projectThumb', 'true' ); ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
and this is the thumbnail template.
<?php
/*
Template Name: projectThumb
* This template displays project thumbnails at the project page
*/
$options = twentyeleven_get_theme_options();
$current_layout = $options['theme_layout'];
get_header();?>
<div id="primary">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>

Related

get_footer not showing for Wordpress site

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.

Make a Blog Template page on underscore.me with wordpress

i am trying to personalize a new theme made in underscore.me, but i can't seem to create a new template page with a loop that can show me posts of one specific category, how can i do this?
I'm gonna paste here the index.php of the underscore.me theme, witch has a generic loop, sadly, copying and pasting this loop on a template page does
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php if ( is_home() && ! is_front_page() ) : ?>
<header>
<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
</header>
<?php endif; ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/*
* Include the Post-Format-specific template for the content.
* If you want to override 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( 'template-parts/content', get_post_format() );
?>
<?php endwhile; ?>
<?php the_posts_navigation(); ?>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
And this is the page.php.
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'template-parts/content', 'page' ); ?>
<?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 endwhile; // End of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
Good news for you, you dont need a specific loop for a specific category.
if you have a category.php file in your theme, and assume that your category name is "Lux Cars" with id of "35". if you copy your category.php as category-35.php or category-lux-cars.php (slug of your category). When you open the posts with this category. wordpress call this file and show posts in that loop. you can edit your category-35.php and add any category detail or sth.
But if you still want a loop for a specific category then you can use that code;
<?php
$args = array ( 'category' => ID, 'posts_per_page' => 5);
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
?>
//Style Posts here
<?php endforeach; ?>

Wordpress Blank Page with header/sidebar/footer of my template

How can i create a page in a directory like public_html/test1 that has a single blank page with the header/sidebar/footer of my actual template.
I can only see the header, no sidebar , no content ( by content i mean "Hello." ).
I'm using twenty fourteen template.
This is the php code i am using:
<?php
/*
* Template Name: My own page!
* Description: I made a page!
*/
require (dirname(dirname( __FILE__ )).'/wp-load.php');
get_header();
get_sidebar();
?>
Hello.
Note: if i delete the the_content(); get_footer(); , then the header ONLY appears but without format.
Any help deeply appreciated
The content isn't appearing because there's no loop inside your template. Please add this code inside your template and move your template file to the 'page-templates' folder inside the twentyfourteen theme.
<?php
/*
* Template Name: My own page!
* Description: I made a page!
*/
get_header(); ?>
<div id="main-content" class="main-content">
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( 'content', 'page' );
endwhile;
?>
</div><!-- #content -->
</div><!-- #primary -->
</div><!-- #main-content -->
<?php
get_sidebar();
get_footer();
p.s. you can remove the div's if you'd like to.

WordPress Blog Not Displaying Posts

I've created a custom template using the twentythirteen template. When I activate the template the blog posts disappear from the front page. I've used the same process to make the new template as I did for my own.
You can see my blog page here, http://www.gnarlydigital.com/blog/ and the new blog that I'm working on is here, http://www.flowdirectpumps.com/news/.
I've tripled checked all the code and both templates are identical. I've uploaded the Gnarly Digital template and it works.
Can anyone see anything obvious?
This is the index.php file
<?php get_header(); ?>
<div class="container pageContent">
<div class="row">
<div class="col-md-12">
<?php if ( have_posts() ) : ?>
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php twentythirteen_paging_nav(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</div>
</div>
</div>
<?php get_footer(); ?>

issue with post format in wordpress on a custom page template

Hey guys so I am trying to have a loop run to get all the post that are within a certain category on a page, for some reason nothing happens though?
Code :
<?php
/*
Template Name: djequip
*/
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php /*query_posts('test');uncategorized*/
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile; endif; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Let me know if you can help, thanks a ton!
<?php /* Template Name: TEMPLATE NAME */ ?>
<?php get_header();?>
<?php query_posts('category_name=CATEGORY NAME'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_excerpt(); ?>
<?php endwhile; ?>
Is this what you mean?
the_excerpt
can be changed to
the_content
Also I'd just like to add that you can put divs in there around the WP PHP.

Categories