Woocommerce quesiton about the loop

6 replies
  • WEB DESIGN
  • |
I have added Woocommerce to my site. There is some conflict with my theme.

In the troubleshoot it says to duplicate the page.php and call it woocommerce.php, then replace the loop with <?php woocommerce_content(); ?>

It says the loop starts with <?php if ( have_posts() ) : and ends with <?php endif; ?>


I am totally lost as I cant find the end but in the page.php.

Help!!!!

Below I have added the page.php

<?php
/**
* The template for displaying any single page.
*
*/
$layout = of_get_option('side_bar');
$layout = (empty($layout)) ? 'right_side' : $layout;
$hide_title = get_post_meta( $post->ID, 'bluth_page_hide_title', 'off' );
$post_subtitle = get_post_meta( $post->ID, 'bluth_page_subtitle', 'off' );
get_header();

// Advert above content
$ad_content_placement = of_get_option('ad_content_placement', array('home' => true,'pages' => true,'posts' => true));
$ad_content_mode = of_get_option('ad_content_mode', 'none');
$ad_content_box = of_get_option('ad_content_box', true);
$ad_content_padding = of_get_option('ad_content_padding', true);

if($ad_content_mode != 'none' and $ad_content_placement['pages'] == true){
echo '<div class="above_content'.(($ad_content_box) ? ' box' : '').(($ad_content_padding) ? ' pad15' : '').'">';
if($ad_content_mode == 'image'){
echo '<a href="'.of_get_option('ad_content_image_link').'" target="_blank"><img src="'.of_get_option('ad_content_image').'"></a>';
}elseif($ad_content_mode == 'html'){
echo apply_filters('shortcode_filter',do_shortcode(of_g et_option('ad_content_code')));
}
echo '</div>';
}
?>
<div id="primary" class="row">

<?php if($layout == 'left_side'){ ?>
<aside id="side-bar" class="span4 widget-area">
<?php dynamic_sidebar( 'sidebar_left'); ?>
</aside>
<?php } ?>
<?php if($layout == 'both_side'){ ?>
<aside id="side-bar" class="span3 widget-area">
<?php dynamic_sidebar( 'sidebar_left' ); ?>
</aside>
<?php } ?>

<div id="content" class="<?php echo ($layout == 'single') ? 'span10 offset1' : ($layout == 'both_side' ? 'span6' : 'span8'); ?>" role="main">

<?php if(have_posts()){
while ( have_posts() ) : the_post();
?>
<article class="type-page">
<?php
if ( has_post_thumbnail() ) { ?>
<div class="entry-image">
<?php the_post_thumbnail('gallery-large');

if($hide_title != 'on'){ ?>
<h1 class="title"><?php the_title(); echo '<small>'.$post_subtitle.'</small>'; ?></h1><?php
} ?>
</div><?php
}else{
if($hide_title != 'on'){ ?>
<h1 class="title"><?php the_title(); echo '<small>'.$post_subtitle.'</small>'; ?></h1><?php
}
} ?>
<div class="the-content">
<?php the_content(); ?>
<?php wp_link_pages(); ?>
<footer class="entry-meta clearfix">
<?php get_template_part( 'inc/meta-bottom' ); ?>
</footer><!-- .entry-meta -->
</div><!-- the-content -->
</article>

<?php endwhile; ?>

<?php }else{ ?>
<article class="type-page box pad25">
<h1 class="title"><?php _e('Post not found', 'bluth'); ?></h1>
<p class="lead"><?php _e('We could not find that post you were looking for.', 'bluth'); ?></p>
<br>
<h3><?php _e('Try searching', 'bluth') ?></h3>
<?php echo get_search_form(); ?>
<?php get_template_part( 'inc/recent-posts' ); ?>

</article>
<?php }
// If comments are open or we have at least one comment, load up the default comment template provided by Wordpress
if ( of_get_option('enable_page_comments') && (comments_open() || '0' != get_comments_number()) )
comments_template( '', true );
?>

</div><!-- #content .site-content -->

<?php if($layout == 'right_side'){ ?>
<aside id="side-bar" class="span4 widget-area">
<?php dynamic_sidebar( 'sidebar_right' ); ?>
</aside>
<?php } ?>
<?php if($layout == 'both_side'){ ?>
<aside id="side-bar" class="span3 widget-area">
<?php dynamic_sidebar( 'sidebar_right' ); ?>
</aside>
<?php } ?>

</div><!-- #primary .content-area -->
<?php get_footer(); ?>
#loop #quesiton #woocommerce
  • Profile picture of the author rhinocl
    They used while instead of if.This part is the loop:
    Code:
    <?php if(have_posts()){
    while ( have_posts() ) : the_post();
    ?>
    <article class="type-page">
    <?php
    if ( has_post_thumbnail() ) { ?>
    <div class="entry-image">
    <?php the_post_thumbnail('gallery-large');
    
    if( != 'on'){ ?>
    <h1 class="title"><?php the_title(); echo '<small>'..'</small>'; ?></h1><?php
    } ?>
    </div><?php
    }else{
    if( != 'on'){ ?>
    <h1 class="title"><?php the_title(); echo '<small>'..'</small>'; ?></h1><?php
    }
    } ?>
    <div class="the-content">
    <?php the_content(); ?>
    <?php wp_link_pages(); ?>
    <footer class="entry-meta clearfix">
    <?php get_template_part( 'inc/meta-bottom' ); ?>
    </footer><!-- .entry-meta -->
    </div><!-- the-content -->
    </article>
    
    <?php endwhile; ?>
    {{ DiscussionBoard.errors[8832379].message }}
  • Profile picture of the author oliverjones
    Yeah I thought so but when I do as they suggest I end up with this - http://blog.relationshipsurgery.com/...indful-loving/


    Any ideas?
    {{ DiscussionBoard.errors[8832392].message }}
    • Profile picture of the author entrepenerd
      The end of the "if" you're replacing is where this appears:

      </article>
      <?php }

      That closing brace is the end of the IF for the loop
      {{ DiscussionBoard.errors[8832675].message }}
      • Profile picture of the author oliverjones
        Originally Posted by entrepenerd View Post

        The end of the "if" you're replacing is where this appears:

        </article>
        <?php }

        That closing brace is the end of the IF for the loop
        Sorry I am not sure what you mean? Have I deleted too much?
        {{ DiscussionBoard.errors[8832695].message }}
        • Profile picture of the author entrepenerd
          Originally Posted by oliverjones View Post

          Sorry I am not sure what you mean? Have I deleted too much?
          Sorry. No, you didn't delete enough.

          Here's what your page should be

          <?php
          /**
          * The template for displaying any single page.
          *
          */
          $layout = of_get_option('side_bar');
          $layout = (empty($layout)) ? 'right_side' : $layout;
          $hide_title = get_post_meta( $post->ID, 'bluth_page_hide_title', 'off' );
          $post_subtitle = get_post_meta( $post->ID, 'bluth_page_subtitle', 'off' );
          get_header();

          // Advert above content
          $ad_content_placement = of_get_option('ad_content_placement', array('home' => true,'pages' => true,'posts' => true));
          $ad_content_mode = of_get_option('ad_content_mode', 'none');
          $ad_content_box = of_get_option('ad_content_box', true);
          $ad_content_padding = of_get_option('ad_content_padding', true);

          if($ad_content_mode != 'none' and $ad_content_placement['pages'] == true){
          echo '<div class="above_content'.(($ad_content_box) ? ' box' : '').(($ad_content_padding) ? ' pad15' : '').'">';
          if($ad_content_mode == 'image'){
          echo '<a href="'.of_get_option('ad_content_image_link').'" target="_blank"><img src="'.of_get_option('ad_content_image').'"></a>';
          }elseif($ad_content_mode == 'html'){
          echo apply_filters('shortcode_filter',do_shortcode(of_g et_option('ad_content_code')));
          }
          echo '</div>';
          }
          ?>
          <div id="primary" class="row">

          <?php if($layout == 'left_side'){ ?>
          <aside id="side-bar" class="span4 widget-area">
          <?php dynamic_sidebar( 'sidebar_left'); ?>
          </aside>
          <?php } ?>
          <?php if($layout == 'both_side'){ ?>
          <aside id="side-bar" class="span3 widget-area">
          <?php dynamic_sidebar( 'sidebar_left' ); ?>
          </aside>
          <?php } ?>

          <div id="content" class="<?php echo ($layout == 'single') ? 'span10 offset1' : ($layout == 'both_side' ? 'span6' : 'span8'); ?>" role="main">

          <?php woocommerce_content(); ?>

          <?php
          // If comments are open or we have at least one comment, load up the default comment template provided by Wordpress
          if ( of_get_option('enable_page_comments') && (comments_open() || '0' != get_comments_number()) )
          comments_template( '', true );
          ?>

          </div><!-- #content .site-content -->

          <?php if($layout == 'right_side'){ ?>
          <aside id="side-bar" class="span4 widget-area">
          <?php dynamic_sidebar( 'sidebar_right' ); ?>
          </aside>
          <?php } ?>
          <?php if($layout == 'both_side'){ ?>
          <aside id="side-bar" class="span3 widget-area">
          <?php dynamic_sidebar( 'sidebar_right' ); ?>
          </aside>
          <?php } ?>

          </div><!-- #primary .content-area -->
          <?php get_footer(); ?>
          {{ DiscussionBoard.errors[8833575].message }}
          • Profile picture of the author oliverjones
            Hi

            I changed it to that and it still wont work? Any ideas? Thanks for all your help
            {{ DiscussionBoard.errors[8834303].message }}

Trending Topics