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>';
}
Related
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 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.
I have different categories where the post displayed are characterized by different elements, for this reason when I use the search in wordpress the results are not shown very well.
For this reason I would like to change the appearance of the post shown in the search results based on its category.
Example:
My search.php template look like this:
<?php get_header(); ?>
<div id="content">
<div class="padder">
<?php do_action( 'bp_before_blog_search' ); ?>
<div class="page" id="blog-search" role="main">
<?php if (have_posts()) : ?>
<?php bp_dtheme_content_nav( 'nav-above' ); ?>
<?php while (have_posts()) : the_post(); ?>
<?php do_action( 'bp_before_blog_post' ); ?>
<div class="blog-post">
// Here is displayed the blog post style and features
</div><!--blog-post-->
<div class="clear"> </div>
<?php do_action( 'bp_after_blog_post' ); ?>
<?php endwhile; ?>
<?php bp_dtheme_content_nav( 'nav-below' ); ?>
<?php else : ?>
<h2 class="center"><?php _e( 'No posts found. Try a different search?', 'OneCommunity' ); ?></h2>
<?php endif; ?>
<div style="display:inline">
<center><?php wp_pagenavi(); ?></center>
</div>
</div>
<?php do_action( 'bp_after_blog_search' ); ?>
</div><!-- .padder -->
</div><!-- #content -->
<div id="sidebar">
<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('sidebar-blog')) : ?><?php endif; ?>
<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('sidebar-ad-blog')) : ?><?php endif; ?>
</div><!--sidebar ends-->
<?php get_footer(); ?>
I tried to achieve the result of displaying based on the post category a different "template" for the post but without success.
I asked the same question on wordpress.stackexchange.com but without success, and there I pointed out a non working solution, hope it can help you in developing the code I need.
https://wordpress.stackexchange.com/questions/141856/different-layout-on-search-page-depending-on-category-post
Thank you very much for any help you will give, and excuse me for my english.
If I understand your question correctly, you could simply use the post_class() function:
<div <?php post_class( 'blog-post' );?> >
// Here is displayed the blog post style and features
</div><!--blog-post-->
This will render like:
<div class="post-3654 post type-post status-publish format-standard hentry category-buildings blog-post">
// Here is displayed the blog post style and features
</div><!--blog-post-->
for posts in the buildings category.
Then your CSS will take care of the rest:
.post.category-buildings {
border: 3px solid red;
}
But I think your setup/idea is only suitable for single category posts.
Ref: From the Codex:
The post_class may include one or more of the following values for the
class attribute, dependent upon the pageview.
.post-id
.post
.attachment
.sticky
.hentry (hAtom microformat pages)
.category-ID
.category-name
.tag-name
.format-name
I have my front page set to a static page and am trying to build my custom template. How do I actually show the selected front page in front-page.php? I have googled and googled but can't seem to figure out how to do it.
The front-page.php actually loads like it should, but I can't seem to find documentation on exactly how to show the page that is assigned as the static home page. Any suggestions?
I have tried
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
but that didn't seem to work...
Your static page uses a page template (usually page.php for the default template)
You can create a new one for the homepage if you wish. see : Creating_Your_Own_Page_Templates copy page.php to homepage.php and change the template name
Example template (homepage.php) :
<?php
/*
Template Name: Homepage
*/
//the content of page.php and now you can do what you want.
?>
$id = 0; /* The id of your page */
$page = get_page($id);
echo apply_filters('the_content', $page->post_content);
If its a static page, I should not use a loop.
First, take a look to topic to show something only on home page. a related question is Wordpress Post Thumbnail Issue (Only 1 thumbnail on frontpage). Also, it can be useful how to create a static front page in wordpress.
I was missing something obvious. The loop I was using I had copied out of wordpress template. It actually called another template file. What I should have used was:
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<h1 class="entry-title"><?php the_title(); ?></h1>
</header>
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages(array('before' => '<div class="page-links">' . __('Pages:', 'twentytwelve'), 'after' => '</div>')); ?>
</div><!-- .entry-content -->
<footer class="entry-meta">
<?php edit_post_link(__('Edit', 'twentytwelve'), '<span class="edit-link">', '</span>'); ?>
</footer><!-- .entry-meta -->
</article><!-- #post -->
<?php endwhile;?>
I have a set-up a custom theme on my wordpress install. I have been developing with it locally and everything was working fine.
I uploaded to my server tonight and was setting up the fresh wordpress install. I turned on permalinks and all of a sudden my custom category pages are causing infinite re-direct loops.
My .htaccess is writable so I don't think its that problem (I have seen this mentioned a lot online).
The code from one of my custom pages is below - it pulls from a specific category - does anyone know how to fix this issue?
<?php get_header(); ?>
<?php
/*
Template Name: Podcasts
*/
?>
<ul class="mcol">
<?php
query_posts("cat=1");
while(have_posts()) : the_post(); ?>
<li class="article" id="post-<?php the_ID(); ?>">
<?php
if ( has_post_thumbnail() ) { ?>
<?php
$imgsrcparam = array(
'alt' => trim(strip_tags( $post- >post_excerpt )),
'title' => trim(strip_tags( $post->post_title )),
);
$thumbID = get_the_post_thumbnail( $post->ID, array(200,200), $imgsrcparam ); ?>
<div class="preview"><?php echo "$thumbID"; ?><div class="front-titles"><?php the_title(); ?></div></div>
<?php } else {?>
<div class="preview"><img src="<?php bloginfo('template_url'); ?>/images/default-thumbnail.jpg" alt="<?php the_title(); ?>" /></div>
<?php } ?>
<div class="article-over">
</div>
</li> <?php ?>
<?php endwhile;
//Reset Query
wp_reset_query();
?>
</ul>
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<?php endwhile; ?>
<?php else : ?>
<h1 id="error"><?php _e("Sorry, but you are looking for something that isn’t here."); ?></h1>
<?php endif; ?>
<div class="pagination"><?php previous_posts_link('<< Newer Entries', 0) ?> <?php next_posts_link('Older Entries >>', 0); ?> </div>
<?php get_footer(); ?>
Anyone any ideas? I'm quite new to this so am unsure as to what the problem might be...
What your doing is weird.
query_posts is meant to alter the main loop.
You have 2 loops with different syntax on the same page.
The second loop is not doing anything, so remove it, and use get_posts or WP Query for your custom query.