How To Integrate Woocommerce With A Custom Wordpress Theme - wordpress

I am having a hard time figuring out where to add the woocommerce loop in my woocommerce.php file.
Here is the page.php code,
<?php
/*
Package: OnAir2
Description: Normal single page template with sidebar
Version: 0.0.0
Author: QantumThemes
Author URI: http://qantumthemes.com
*/
?>
<?php get_header(); ?>
<?php
get_template_part ('phpincludes/menu');
get_template_part ('phpincludes/part-searchbar');
?>
<div id="maincontent" class="qt-main">
<?php while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- ======================= HEADER SECTION ======================= -->
<?php get_template_part( 'phpincludes/part-header-caption-page'); ?>
<!-- ======================= CONTENT SECTION ======================= -->
<div class="qt-container qt-spacer-l">
<div class="row">
<div class="col s12 m12 l1 qt-pushpin-container">
<div class="qt-pushpin">
<?php get_template_part( 'phpincludes/sharepage' ); ?>
</div>
<hr class="qt-spacer-m">
</div>
<div class="col s12 m12 l8">
<div class="qt-the-content">
<?php the_content(); ?>
</div>
<?php if ( comments_open() || '0' != get_comments_number() ){ ?>
<hr class="qt-spacer-m">
<?php comments_template(); ?>
<?php } ?>
<hr class="qt-spacer-l">
</div>
<div class="qt-sidebar col s12 m12 l3">
<?php get_template_part ( 'phpincludes/sidebar' ); ?>
<hr class="qt-spacer-l">
</div>
</div>
</div>
</div>
<?php endwhile; // end of the loop. ?>
<?php get_template_part ( 'phpincludes/part-sponsors' ); ?>
</div><!-- .qt-main end -->
<?php get_template_part ( 'phpincludes/footerwidgets' ); ?>
<?php get_template_part ( 'phpincludes/part-player-sidebar' ); ?>
<?php get_footer(); ?>
Where do I add the
<?php woocommerce_content(); ?>
I have tried just using the the get header and footer alone but the output was very very bad. Since the developer didn't make the theme woocommerce compatible I need to make it....

Replace the_content(); with woocommerce_content();. But still it won't adopt design. You manually have to make it woocommerce compatible.

Related

Wordpress hierarchy issue with categorized post not using specific template

I'm trying to implement a dedicated template for any post with a category slug of 'rentals'. There are posts in the database with a category of rentals set up and applied. I've created the template with a standard loop and called it category-rentals.php, saving it in my root folder.
It's just not working. It keeps reverting to single post template (index.php specifically).
My rendered body classes are as such:
post-template-default single single-post postid-278 single-format-standard
Am I missing a step here?
category-rentals.php:
/*
* Rental property template
*/
?>
<?php get_header(); ?>
<div class="jumbotron jumbotron-fluid" style="background-image: url('<?php bloginfo( 'template_url' ); ?>/img/bg-semi-trans.png'), url('<?php bloginfo( 'template_url' ); ?>/img/bg-jumbotron.jpg');">
<div class="container">
<div class="headline text-center animated fadeInUp">
<p><?php wp_title(''); ?></p>
</div>
</div>
</div>
<section>
<div class="container">
<div class="row">
<div class="col-12">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; else : ?>
<p><?php esc_html_e( 'Sorry, no content matched your criteria.' ); ?></p>
<?php endif; ?>
<hr>
← Go Back | Contact Us
</div>
</div>
</div>
</section>
<?php get_footer(); ?>

How can i increase number of post on each row in wordpress col-6 module-content grid

i am working on a wordpress news theme. On that theme there is sidebar with "col-3"and "col-6 module-content" for news thumb. Now its showing 2 thumb on each row. I want to show 3 thumb on each row. How can i do so? bellow the content.php file of the theme.
<?php
/**
* Template part for displaying posts
*
* #link https://codex.wordpress.org/Template_Hierarchy
*
* #package Online_News
*/
?>
<div class="col-6 module-content">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if( is_sticky() ){ ?>
<div class="favourite"><i class="fa fa-star"></i></div>
<?php } ?>
<?php if(has_post_thumbnail()):?>
<div class="list-img">
<?php the_post_thumbnail('online-news-feature-thumb');?>
</div>
<?php endif;?>
<div class="news-content">
<?php if ( 'post' === get_post_type() ) : ?>
<div class="entry-meta">
<?php $disable_post_meta = online_news_get_option('disable_postmeta');
if('false'== !$disable_post_meta): ?>
<?php online_news_posted_on();?>
<?php endif;?>
<?php $disable_categories = online_news_get_option('disable_categories');
if('false'== !$disable_categories): ?>
<div class="category-link">
<?php online_news_category();?>
</div>
<?php endif;?>
</div><!-- .entry-meta -->
<?php endif; ?>
<header class="entry-header">
<?php
if ( is_single() ) :
the_title( '<h1 class="entry-title">', '</h1>' );
else :
the_title( '<h3 class="entry-title">', '</h3>' );
endif;
?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php the_excerpt();?>
<?php $readmore_text = online_news_get_option('readmore_text'); ?>
<a class="more-link" href="<?php the_permalink();?>"><?php echo esc_html($readmore_text);?></a>
</div><!-- .entry-content -->
</div>
</article><!-- #post-## -->
</div>
You can simply change the div class from col-6 into col-4.
<div class="col-4 module-content">
Cheers!

Custom template for category WordPress

Hello I'm new in WordPress custom templates. Can anybody tell me how I can load a different template for a category.
Here is the index.php file
<?php
/**
* The main template file
*
* No comment for now
*
* #package WordPress
* #subpackage site
* #since site
*/
get_header(); ?>
<?php
$strFr='Featured';
$strFinancial='Financial Reports';
$strResearch='Research';
?>
<div id="page-body" role="main">
<div class="container">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12 SearchTop">
<form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-search"></i></div>
<input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" class="form-control customsearchfiled" placeholder="Search of anything related to Site" />
</div>
</form>
</div><!-- SearchTop -->
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="col-md-12 col-sm-12 col-xs-12 mb20 no-gutter">
<div class="col-md-12 col-sm-12 col-xs-12 no-gutter">
<?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">
<?php if (current_user_can('edit_posts')) :
// Show a different message to a logged-in user who can add posts.
?>
<header class="entry-header">
<h1 class="entry-title mt20"><?php _e('No posts to display', 'twentytwelve'); ?></h1>
</header>
<!--<div class="entry-content">
<p><?php //printf(__('Ready to publish your first post? Get started here.', 'twentytwelve'), admin_url('post-new.php')); ?></p>
</div> .entry-content -->
<?php else :
// Show the default message to everyone else.
?>
<header class="entry-header">
<h1 class="entry-title"><?php _e('Nothing Found', 'twentytwelve'); ?></h1>
</header>
<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>
</div>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
As far I know the index file is calling content php file that shows the post layout but don't know how to do this. Tried a lot of things but only get php error. I don't know php syntax much
<?php
/**
* Custom template with better structure than WP default.
*
* Used for both single and index/archive/search.
*
* #package WordPress
* #subpackage site
* #since Site 1.0
*/
# for one post
if (is_single()) {
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php if(function_exists('pf_show_link')){echo pf_show_link();} ?>
<p class="text-center topcategory">
<?php foreach((get_the_category()) as $category) {
echo $category->cat_name . ' ';
}
?>
</p>
<h1 class="entry-title"><?php the_title(); ?></h1>
<p class="postmetadown">By :<span class="bluecolor"><?php the_author(); ?></span> | <span><?php the_date() ?></span></p>
</header>
<div class="entry-content col-md-9 col-sm-9 col-xs-12">
<?php the_content(__('Continue reading <span class="meta-nav">→</span>', 'twentytwelve')); ?>
<?php wp_link_pages(array('before' => '<div class="page-links">' . __('Pages:', 'twentytwelve'), 'after' => '</div>')); ?>
</div>
<div class="col-md-3 col-sm-3 col-xs-12">
<?php get_sidebar(); ?>
</div>
<?php if (comments_open()) : ?>
<!--<div id="disqus_thread"></div>

<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'site'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
var dsq = document.createElement('script');
dsq.type =
'text/javascript';
dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')
[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/? ref_noscript">comments powered
by Disqus.</a></noscript>
comments powered by <span class="logo- disqus">Disqus</span>-->
<?php endif; ?>
<footer class="entry-meta col-md-12">
<?php if ($googlePlusAcc = get_the_author_meta('googleplus')) { ?>
<?php hr_single_entry_meta(); ?>
<?php } else { ?>
<?php twentytwelve_entry_meta(); ?>
<?php } ?>
<?php edit_post_link(__('Edit', 'twentytwelve'), '<span class="edit-link">', '</span>'); ?>
<?php if (is_singular() && get_the_author_meta('description') && is_multi_author()) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?>
<div class="author-info">
<div class="author-avatar">
<?php
/** This filter is documented in author.php */
$author_bio_avatar_size = apply_filters('twentytwelve_author_bio_avatar_size', 68);
echo get_avatar(get_the_author_meta('user_email'), $author_bio_avatar_size);
?>
</div>
<!-- .author-avatar -->
<div class="author-description">
<h2><?php printf(__('About %s', 'twentytwelve'), get_the_author()); ?></h2>
<p><?php the_author_meta('description'); ?></p>
<div class="author-link">
<a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>"
rel="author">
<?php printf(__('View all posts by %s <span class="meta-nav">→</span>', 'twentytwelve'), get_the_author()); ?>
</a>
</div>
</div>
</div>
<?php endif; ?>
</footer>
</article>
<?php
#for listing page
} else {
$category = get_the_category();
if (!empty($category))
$category = $category[0];
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php //if (is_sticky() && is_home() && !is_paged()) : ?>
<!--<div class="featured-post">
<?php //_e('Featured post', 'twentytwelve'); ?>
</div>-->
<?php //endif; ?>
<div class="col-md-4 col-sm-4 col-xs-12 categoryimg no-gutter">
<?php if (has_post_thumbnail()) { ?>
<div class="post-thumbnal-wrapper-multiple">
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
</div>
<div class="col-md-8 col-sm-8 col-xs-12 categoryContent">
<header class="entry-header">
<h1 class="entry-title">
<?php the_title(); ?>
</h1>
</header>
<?php if (is_search()) : // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div>
<?php else : ?>
<div class="entry-content">
<?php the_excerpt_more(); ?>
</div>
<?php endif; ?>
<div class="col-md-12">
<footer class="entry-meta">
<?php twentytwelve_entry_meta(); ?>
<?php edit_post_link(__('Edit', 'twentytwelve'), '<span class="edit-link">', '</span>'); ?>
</footer>
</div>
</div><!-- categoryContent -->
</article>
<div class="clearfix"></div>
<?php
}
If you want a template for the category page, see https://codex.wordpress.org/Category_Templates. If you want a different template for the content, based on the category, you could use (in your content.php)
<?php if (is_category('Category A')) : ?>
<p>This is the text to describe category A</p>
<?php elseif (is_category('Category B')) : ?>
<p>This is the text to describe category B</p>
<?php else : ?>
<p>This is some generic text to describe all other category pages,
I could be left blank</p>
<?php endif; ?>
If there's a lot of difference between categories, I would place this in index.php, and create different templates for every category
Check out this page Template Hierachy. Basically if you want to target a specific category you create a file like so category-{slug}.php {slug} being the category slug you want to target.
I suggest you to read about Wordpress Template Hierarchy in https://developer.wordpress.org/themes/basics/template-hierarchy/
To answer your question, you need to create a category-{id}.php or category-{slug}.php file. in your theme folder (Choose only one)
id = your category ID
slug = your category slug
After creating the file, then you can put your custom code if you want.
Add your code inside archive.php which will list all the posts in the category and add the detail page template inside single.php .
https://codex.wordpress.org/Category_Templates

Custom Blog Post Listing in Genesis Sample Child Theme

I want to add several images and divs and also customize the look of my Blog post listing... But i can't find the way to do it.
Here's the Blog Template code
<?php
/*
WARNING: This file is part of the core Genesis framework. DO NOT edit
this file under any circumstances. Please do all modifications
in the form of a child theme.
*/
/**
* Template Name: Blog
* This file handles blog post listings within a page.
*
* This file is a core Genesis file and should not be edited.
*
* The blog page loop logic is located in lib/structure/loops.php
*
* #category Genesis
* #package Templates
* #author StudioPress
* #license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
* #link http://www.studiopress.com/themes/genesis
*/
genesis();
and just above the genesis(); code.. i tried to put some divs and images there.. But i guess that's not the way it works. ..
I also tried to make my own Blog listing template using a normal wordpress code theme..
<?php /*
Template Name: List Post Pages
*/
?>
<?php get_header(); ?>
<?php if ( has_post_thumbnail() ) { ?>
<div class="featured">
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
<div class="divider"></div>
<div id="content" class="hfeed">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>">
<?php the_title(); ?>
</a></h2>
<div class="entry">
<?php the_content(); ?>
</div>
<div class="postmetadata">
<?php the_tags('Tags: ', ', ', '<br />'); ?>
Posted in
<?php the_category(', ') ?>
|
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<h2>Not Found</h2>
<?php endif; ?>
<?php genesis_after_loop(); ?>
</div>
<?php get_footer(); ?>
But no luck, what's the right way to do this?
***Update -code below is the one i want.. but instead of having the Content of the page. I want the list of Post with excerpts ....How can i do that????
<?php /*
Template Name: Page Template
*/ ?>
<?php get_header(); ?>
<?php if ( has_post_thumbnail() ) { ?>
<div class="featured">
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
<div class="divider"></div>
<?php genesis_before_content_sidebar_wrap(); ?>
<div id="content-sidebar-wrap">
<?php genesis_before_content(); ?>
<div id="content" class="hfeed">
<?php genesis_before_loop(); ?>
<?php genesis_loop(); ?>
<?php genesis_after_loop(); ?>
</div>
<!-- end #content -->
<?php genesis_after_content(); ?>
</div>
<!-- end #content-sidebar-wrap -->
<?php genesis_after_content_sidebar_wrap(); ?>
<?php get_footer(); ?>
Im shocked that no one answered my question.. anyway, if someone bumps onto this post with similar problem. The answer is adding
<?php query_posts( $args ); ?>
just above the <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
All in all, my code looks like this ...
<?php /*
Template Name: Page Template
*/ ?>
<?php get_header(); ?>
<?php if ( has_post_thumbnail() ) { ?>
<div class="featured">
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
<div class="divider"></div>
<?php genesis_before_content_sidebar_wrap(); ?>
<div id="content-sidebar-wrap">
<?php genesis_before_content(); ?>
<div id="content" class="hfeed">
<?php genesis_before_loop(); ?>
<?php query_posts( $args ); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>">
<?php the_title(); ?>
</a></h2>
<div class="entry">
<?php the_content(); ?>
</div>
<div class="postmetadata">
<?php the_tags('Tags: ', ', ', '<br />'); ?>
Posted in
<?php the_category(', ') ?>
|
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<h2>Not Found</h2>
<?php endif; ?>
<?php genesis_after_loop(); ?>
</div>
<!-- end #content -->
<?php genesis_after_content(); ?>
</div>
<!-- end #content-sidebar-wrap -->
<?php genesis_after_content_sidebar_wrap(); ?>
<?php get_footer(); ?>

Wordpress: Post has no formatting

I've just begun learning to develop WordPress themes, and I'm developing my first theme, but I have an issue, where the formatting set in the Visual Editor isn't used when displaying a post...
So, my code is as follows:
<?php
/*
Template Name: News
*/
?>
<?php get_header(); ?>
<div id="contentWrap">
<div id="content">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query = array (
'posts_per_page' => 3,
'paged' => $paged,
'cat' => 4
);
query_posts ($query); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="meta">
<em>Posted on:</em> <?php the_time('F jS, Y') ?>
</div>
<div class="entry">
<?php the_content(); ?>
</div>
</article>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
<?php else : ?>
<h2>Not found</h2>
<?php endif; ?>
</div><!-- end content -->
</div><!-- end contentWrap -->
<?php get_footer(); ?>
So the issue is, if I create a post and set some formatting (bold, italics, etc.), the post is still shown as plain text with no formatting except line breaks... I'm guessing the issue is related to how I get the post, but as I'm completely new in WordPress, I haven't been able to find the solution...
What am I missing?

Resources