I am a beginner in wordpress and I tried all the ways but I cannot make my theme woocommerce supportable. Below is my page.php
page.php
<?php
/**
* The template for displaying pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages and that
* other "pages" on your WordPress site will use a different template.
*
*/
?>
<?php get_header(); ?>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="page">
<?php if ( have_posts() ) : ?>
<?php while( have_posts() ) : the_post(); ?>
<div class="post">
<h3 class="<?php post_class(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?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();
}
?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>
At first I duplicate page.php and create woocommerce.php and upload to server, but it fails, below is my woocommerce.php
woocommerce.php
<?php
/**
* The template for displaying pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages and that
* other "pages" on your WordPress site will use a different template.
*
*/
?>
<?php get_header(); ?>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="page">
<?php woocommerce_content(); ?>
</div>
</div>
<?php get_footer(); ?>
But it fails, after this I deleted woocommerce.php from server and edited my functions.php file to add woocommerce supportable code. Below is the code I added in my functions.php file.
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
function my_theme_wrapper_start() {
echo '<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"><div class="page">';
}
function my_theme_wrapper_end() {
echo '</div></div>';
}
add_action( 'after_setup_theme', 'woocommerce_support' );
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}
but it also fails, you can see the output here
If you see in debugger you can see that no woocommerce css file has been loaded.
Please help me with your suggestion. Thank you.
go to functions.php and add this at the top,
add_theme_support('woocommerce');
most preferably at an initialisation function.
Related
Hey Guys Extremely sorry for the silly question because I am newbie to wordpress. I just wanted to show user testimonials.
For that I Installed Easy Testimonials Plugin.
Then I creates a new page called Testimonials. In that I give the below shortcode
[testimonials theme="default_style" paginate="all" count="5" orderby="date" order="ASC" show_title="0" use_excerpt="0" show_thumbs="1" show_date="1" show_other="1" hide_view_more="1" output_schema_markup="1" show_rating="stars"]
Upto now all are working fine, But in my site its showing that shortcode that I have given in the testimonial page.
My admin panel
This is my page.php
<?php
/**
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages and that other
* 'pages' on your WordPress site will use a different template.
*
* #package OceanWP WordPress theme
*/
get_header(); ?>
<?php do_action( 'ocean_before_content_wrap' ); ?>
<div id="content-wrap" class="container clr">
<?php do_action( 'ocean_before_primary' ); ?>
<div id="primary" class="content-area clr">
<?php do_action( 'ocean_before_content' ); ?>
<div id="content" class="site-content clr">
<?php do_action( 'ocean_before_content_inner' ); ?>
<?php
// Elementor `single` location
if ( ! function_exists( 'elementor_theme_do_location' ) || ! elementor_theme_do_location( 'single' ) ) {
// Start loop
while ( have_posts() ) : the_post();
get_template_part( 'partials/page/layout' );
endwhile;
} ?>
<?php do_action( 'ocean_after_content_inner' ); ?>
</div><!-- #content -->
<?php do_action( 'ocean_after_content' ); ?>
</div><!-- #primary -->
<?php do_action( 'ocean_after_primary' ); ?>
<?php do_action( 'ocean_display_sidebar' ); ?>
</div><!-- #content-wrap -->
<?php do_action( 'ocean_after_content_wrap' ); ?>
<?php get_footer(); ?>
I suggest you to go to admin panel Testimonials->All Testimonials select edit testimonial and check description content there
in your page.php put below code anywhere and check it working or not
<?php echo do_shortcode('[testimonials theme="default_style" paginate="all" count="5" orderby="date" order="ASC" show_title="0" use_excerpt="0" show_thumbs="1" show_date="1" show_other="1" hide_view_more="1" output_schema_markup="1" show_rating="stars"]'); ?>
So, in my page.php (and other template pages) I have a hero section with a background image and the title of the page. Then, following that, a section where the content goes (with ) all that is inside the loop.
To add WooCommerce functionality I added the below code, as per the official documentation:
// WooCommerce Integration
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
function my_theme_wrapper_start() {
echo '<section class="page-content large-padding shop-container">';
echo '<div class="grid-container">';
echo '<div class="grid-x">';
echo '<div class="cell entry-content" id="woocom">';
}
function my_theme_wrapper_end() {
echo '</div>';
echo '</div>';
echo '</div>';
echo '</section>';
}
The problem is that, yes, the products appear on the products page and the header and the footer appear, but the previous section (the hero image and title) don't.
What am I doing wrong?
Edit: Here's my page.php code:
<?php get_header(); ?>
<?php while (have_posts()): the_post(); ?>
<section class="page-hero text-center background" style="background-image:url(<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), '1600×1000', false ); echo $src[0]; ?>);">
<div class="grid-container vertically-aligned">
<div class="grid-x justify-center">
<div class="cell large-9">
<h1 class="m-0"><?php the_title(); ?></h1>
</div>
</div>
</div>
</section>
<section class="page-content large-padding">
<div class="grid-container">
<div class="grid-x">
<div class="cell entry-content">
<?php the_content(); ?>
</div>
</div>
</div>
</section>
<?php endwhile; ?>
<?php get_footer(); ?>
In any case, I've been able to add that section modifying the archive-product.php template from woocommerce. The issue here is that because it's an archive page it doesn't get the attached image to add on the header but the image of the first listed product... is there a way to get the attached image of the Products page?
I am using a Wordpress template made with Cherry Framework. The complete footer only appears on the home page. I would like it to appear on all page types, which are mostly 'fullwidth page templates'.
When I look at the PHP files for each template, the difference I can see is this:
<?php do_action( 'cherry_after_home_page_content' ); ?>
I can't seem to find where cherry_after_home_page_content is defined. Could this be what I'm looking for? I tried copying that into the fullwidth page template, but it doesn't work. If I'm totally off base, what would be the correct way to accomplish this?
Footer that appears on every page regardless of template type. Here is the screenshot:
Code from fullwidth page template:
<?php
/**
* Template Name: Fullwidth Page
*/
get_header(); ?>
<div class="motopress-wrapper content-holder clearfix">
<div class="container">
<div class="row">
<div class="<?php echo cherry_get_layout_class( 'full_width_content' ); ?>" data-motopress-wrapper-file="page-fullwidth.php" data-motopress-wrapper-type="content">
<div class="row">
<div class="<?php echo cherry_get_layout_class( 'full_width_content' ); ?>" data-motopress-type="static" data-motopress-static-file="static/static-title.php">
<?php get_template_part("static/static-title"); ?>
</div>
</div>
<div id="content" class="row">
<div class="<?php echo cherry_get_layout_class( 'full_width_content' ); ?>" data-motopress-type="loop" data-motopress-loop-file="loop/loop-page.php">
<?php get_template_part("loop/loop-page"); ?>
</div>
</div>
</div>
<?php do_action( 'cherry_after_home_page_content' ); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
Complete footer that only appears on the home page. Below is a screenshot:
Code from homepage template:
<?php
/**
* Template Name: Home Page
*/
get_header(); ?>
<div class="motopress-wrapper content-holder clearfix">
<div class="container">
<div class="row">
<?php do_action( 'cherry_before_home_page_content' ); ?>
<div class="<?php echo apply_filters( 'cherry_home_layout', 'span12' ); ?>" data-motopress-wrapper-file="page-home.php" data-motopress-wrapper-type="content">
<div class="row">
<div class="<?php echo apply_filters( 'cherry_home_layout', 'span12' ); ?>" data-motopress-type="static" data-motopress-static-file="static/static-slider.php">
<?php get_template_part("static/static-slider"); ?>
</div>
</div>
<div class="row">
<div class="<?php echo apply_filters( 'cherry_home_layout', 'span12' ); ?>" data-motopress-type="loop" data-motopress-loop-file="loop/loop-page.php">
<?php get_template_part("loop/loop-page"); ?>
</div>
</div>
</div>
<?php do_action( 'cherry_after_home_page_content' ); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
I figured this out, so just for anyone who comes across this with the same problem.
The "cherry_after_home_page_content" had nothing to do with it. (And actually I noticed afterward that in my pasted code above I accidentally put in the code where I had pasted it in to the fullwidth page template where it does not belong. Ooops!)
Anyway, it is just in the CSS. If you are seeing that the footer widgets only appear on your homepage, you probably have this in your CSS:
.home .footer .footer-widgets { display:block; }
In your child theme, paste in the above code but change .home to the pages where you want it to show up. For me it was .page for all regular pages, .blog and .single-post for the blog.
Hope that helps someone!
I am trying to insert meta slider to display above my posts in wordpress.
I correctly inserted the code in the theme index.php file above the loop. it works correctly, but it also displays on top of the side bar as well, and i would like it just above the posts.
is there any advice on how i can do this? where in the loop would i need to insert it?
here is what i have
<?php
/**
* The main template file
*
* #package SimpleMag
* #since SimpleMag 1.0
**/
get_header();
global $ti_option;
?>
<?php $archive_sidebar = get_field( 'page_sidebar', get_option('page_for_posts') ); ?>
<section id="content" role="main" class="clearfix animated">
<?php
echo do_shortcode("[metaslider id=437]");
?>
<?php if ( $ti_option['posts_page_title'] == 'full_width_title' ) : ?>
<header class="entry-header page-header">
<div class="wrapper title-with-sep page-title">
<h1 class="entry-title">
<?php
$posts_page_id = get_option( 'page_for_posts' );
echo get_the_title( $posts_page_id );
?>
</h1>
</div>
</header>
<?php endif; ?>
<div class="wrapper">
<?php
// Enable/Disable sidebar based on the field selection
if ( ! $archive_sidebar || $archive_sidebar == 'page_sidebar_on' ):
?>
<div class="grids">
<div class="grid-8 column-1">
<?php endif; ?>
<?php if ( $ti_option['posts_page_title'] == 'above_content_title' ) : ?>
<header class="entry-header page-header">
<div class="title-with-sep page-title">
<h1 class="entry-title">
<?php
$posts_page_id = get_option( 'page_for_posts' );
echo get_the_title( $posts_page_id );
?>
</h1>
</div>
</header>
<?php endif; ?>
<div class="grids <?php echo $ti_option['posts_page_layout']; ?> entries">
<?php
if ( have_posts() ) : while ( have_posts()) : the_post();
get_template_part( 'content', 'post' );
endwhile;
?>
</div>
<?php ti_pagination(); ?>
<?php else : ?>
<p class="message">
<?php _e( 'Sorry, no posts were found', 'themetext' ); ?>
</p>
<?php endif;?>
<?php
// Enable/Disable sidebar based on the field selection
if ( ! $archive_sidebar || $archive_sidebar == 'page_sidebar_on' ):
?>
</div><!-- .grid-8 -->
<?php get_sidebar(); ?>
</div><!-- .grids -->
<?php endif; ?>
</div><!-- .wrapper -->
</section><!-- #content -->
<?php get_footer(); ?>
As long as the sidebar is deactivated, your placement is fine. When the sidebar is active you should place it just below <div class="grid-8 column-1">. That's the beginning of the main area of your page, next to the sidebar. (I'm guessing the div is using something similar to bootstrap, taking up 8 of 12 available grids).
To prevent future updates of your theme to overwrite your customizations, if this is in fact a supported theme, you should also consider creating a child theme. It's real easy and is explained here: https://codex.wordpress.org/Child_Themes
I am trying to get the jigoshop to put everything in my main container and it appears to be not working.
My template is below:
<?php get_header(); ?>
<div id="productsidebar"><?php get_sidebar('products'); ?></div>
<div id="contentwrap">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<div class="entry">
<?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
</div>
</div>
<?php endwhile; endif; ?>
</div><!-- #content -->
<?php get_footer(); ?>
And i have this in my functions file as per Jigoshops themeing (http://forum.jigoshop.com/kb/customize-jigoshop/wrap-your-themes-content-for-jigoshop)
function mytheme_open_jigoshop_content_wrappers()
{
echo '<div id="productsidebar"></div><div id="contentwrap">';
}
function mytheme_close_jigoshop_content_wrappers()
{
echo '</div>';
}
function mytheme_prepare_jigoshop_wrappers()
{
remove_action( 'jigoshop_before_main_content', 'jigoshop_output_content_wrapper', 10 );
remove_action( 'jigoshop_after_main_content', 'jigoshop_output_content_wrapper_end', 10);
add_action( 'jigoshop_before_main_content', 'mytheme_open_jigoshop_content_wrappers', 10 );
add_action( 'jigoshop_after_main_content', 'mytheme_close_jigoshop_content_wrappers', 10 );
}
add_action( 'wp_head', 'mytheme_prepare_jigoshop_wrappers' );
It was obviously erroring when i put the sidebar function in the functions file.
Can anyone advise how best to do this?
Site is http://upholstery180degree.co.uk/NewSite/
thanks
After analyzing the code your function is putting the product page in the main container as specified.
<div id="contentwrap">
<ul class="products">
<li class="product first">
Although from what it seems like you are using a different template for your shop page in which is causing it to show the widgets from you site. Your code is working properly, I would go into your product page and change the type of template it is using and have it the same as your other pages. Also you would not need the sidebar div information as it is not part of the main wrapper.
function mytheme_open_jigoshop_content_wrappers()
{
echo '<div id="contentwrap">';
}
function mytheme_close_jigoshop_content_wrappers()
{
echo '</div>';
}