Skip Navigation

[Resuelto] Related posts not showing well

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem: I would like to show a View of related Products in the single Product Layout. For some reason the Loop Template of the related Products View does not show the correct information. It shows the post body of each related Product.

Solution: In this case, the Loop Templates and Content Templates are causing some conflicts. The best solution is to put all the code directly in the Loop Output editor, and not use a Loop Template.

[wpv-layout-start]
  [wpv-items-found]
  <!-- wpv-loop-start -->
  <div class="container wpv-loop js-wpv-loop">
  <wpv-loop wrap="4" pad="true">
    [wpv-item index=1]
    <div class="row ">
      <div class="col-sm-3 col-xs-12">
        <div class="book-single-archive">
          <div class="imgbooks">
            <div class="imgbook">
              <a href="[wpv-post-url]">[wpv-post-featured-image size="woocommerce_thumbnail" class="book-image-shop"]</a>
            </div>
          </div>
          <div class="shop-text-wrapper">
            <p class="book-cat-shop">[wpv-post-taxonomy type="product_cat"]</p>
            <h2 class="book-title-shop">[wpv-post-link]</h2>
            <h3 class="book-author-shop">[wpv-post-link id="[wpv-post-field name="_wpcf_belongs_autor_id"]"]</h3>
          </div>
          <div class="price-shop-container">
            <div class="price-archive">
              [wpv-woo-product-price]
            </div>
            <div class="buy-archive">
              [wpv-woo-buy-or-select add_to_cart_text="COMPRAR"]
            </div>
          </div>
        </div>
      </div>
    [wpv-item index=other]
      <div class="col-sm-3 col-xs-12">
        <div class="book-single-archive">
          <div class="imgbooks">
            <div class="imgbook">
              <a href="[wpv-post-url]">[wpv-post-featured-image size="woocommerce_thumbnail" class="book-image-shop"]</a>
            </div>
          </div>
          <div class="shop-text-wrapper">
            <p class="book-cat-shop">[wpv-post-taxonomy type="product_cat"]</p>
            <h2 class="book-title-shop">[wpv-post-link]</h2>
            <h3 class="book-author-shop">[wpv-post-link id="[wpv-post-field name="_wpcf_belongs_autor_id"]"]</h3>
          </div>
          <div class="price-shop-container">
            <div class="price-archive">
              [wpv-woo-product-price]
            </div>
            <div class="buy-archive">
              [wpv-woo-buy-or-select add_to_cart_text="COMPRAR"]
            </div>
          </div>
        </div>
      </div>
    [wpv-item index=4]
      <div class="col-sm-3 col-xs-12">
        <div class="book-single-archive">
          <div class="imgbooks">
            <div class="imgbook">
              <a href="[wpv-post-url]">[wpv-post-featured-image size="woocommerce_thumbnail" class="book-image-shop"]</a>
            </div>
          </div>
          <div class="shop-text-wrapper">
            <p class="book-cat-shop">[wpv-post-taxonomy type="product_cat"]</p>
            <h2 class="book-title-shop">[wpv-post-link]</h2>
            <h3 class="book-author-shop">[wpv-post-link id="[wpv-post-field name="_wpcf_belongs_autor_id"]"]</h3>
          </div>
          <div class="price-shop-container">
            <div class="price-archive">
              [wpv-woo-product-price]
            </div>
            <div class="buy-archive">
              [wpv-woo-buy-or-select add_to_cart_text="COMPRAR"]
            </div>
          </div>
        </div>
      </div>
    </div>
    [wpv-item index=pad]
      <div class="col-sm-3 col-xs-12"></div>
    [wpv-item index=pad-last]
      <div class="col-sm-3 col-xs-12"></div>
    </div>
  </wpv-loop>
  </div>
  <!-- wpv-loop-end -->
  [/wpv-items-found]
  [wpv-no-items-found]
    <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
  [/wpv-no-items-found]
[wpv-layout-end]
This support ticket is created hace 4 años, 4 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 12 respuestas, has 4 mensajes.

Last updated by ericL-12 hace 4 años, 4 meses.

Assigned support staff: Christian Cox.

Autor
Mensajes
#872629

I am trying to: have a view of related products in a layout that shows products in the same category

Link to a page where the issue can be seen: hidden link

I expected to see: related custom post as it's built in the view - link: hidden link

Instead, I got: strange results, I can only see the content of the posts

#872765

Hi, I think you just need to change the Query parameter to "Product categories the same as the page where this View is shown"
This because you want the same category as the current single post, not as the post in the loop (which is usually as from the parent view).

Can you try this?

I saw your site is spanish so I add the comment in spanish as well:

Creo que se entiendo bien, deberias cambiar el filtro en la view a "página donde se muestra esta view".

Quieres muestrar products similar a el que se ve en el front end, designado con este Layout, verdad?
Entonces aquel seria el setting correcto.

Ahora mismo estas "llamando" a posts en el Loop de una View, por ejemplo.

#872766

Hello,

I did it and the error remains.

Thank you

#873769

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Eric,

I think something might be wrong with the template for this view.

Could you try re-creating this view and let me know if the issue still remains.

Thanks,
Shane

#873876

I created another view, with only the post title name, and the error is the same.

New view: hidden link
Result: hidden link

#876944

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Eric,

I took another look at this and it seems that if the view is loading its content from a content template or view template then the issue occurs.

If its added directly to the view loop then it displays fine.

Would you mind disabling any non-toolset plugins or removing any custom code that was added to the site and try again ?

Please let me know the results of this.

Thanks,
Shane

#902381

Hello,

I did that and the problem remains, please check here: hidden link

#902563

Hi, Shane is unavailable today so I will try to help you. I hope that's okay. The main problem I see is here:

<div id="bio-autor-producto">[wpv-post-body view_template="None" id="[wpv-post-field name="_wpcf_belongs_autor_id"]"]</div>

This code is inserted in a Visual Editor cell in your Layout, along with another content template shortcode to display the main post content, and it seems to be causing a conflict with the Loop Template in your View of related products. I think the easiest way to get around this problem is to discard the Loop Template in the View, and to copy + paste the code into each of the 4 item blocks in the loop.

Another alternative may be to replace the Autor content template shortcode with another View, filtered by Autor ID, but I think discarding the Loop Template in the current View of related products will be simpler.

#902807

Hello,

I don't understand, the problem is in the "book-rels" view just below the code you copied. What should I do exactly? I'm a bit lost.

Thank you

#902995
Screen Shot 2018-05-24 at 11.12.17 AM.png

Hi, I have made the change for you. Please see the attached screenshot, which was taken before I made any changes. The problem was the Loop Templates, marked in red. I have replaced the Loop Template shortcodes with the actual content from the Loop Template, marked in blue. I also combined the 2nd and 3rd loop items into one item with index "other", since they are identical.

Now instead of making changes in the Loop Template, you must make changes directly in the Loop Output, and be sure to make the same changes in all 3 loop items.

#903038

Hello,

Thank you so much. I tried to put my code there and the result is strange: hidden link

I need 4 rows of my custom code:

<div class="book-single-archive">
<div class="imgbooks">
  <div class="imgbook">
  <a href="[wpv-post-url]">[wpv-post-featured-image size="woocommerce_thumbnail" class="book-image-shop"]</a>
  </div>
</div>
<div class="shop-text-wrapper">
  <p class="book-cat-shop">[wpv-post-taxonomy type="product_cat"]</p>
  <h2 class="book-title-shop">[wpv-post-link]</h2>
  <h3 class="book-author-shop">[wpv-post-link id="[wpv-post-field name="_wpcf_belongs_autor_id"]"]</h3>
  </div>
<div class="price-shop-container">
  <div class="price-archive">
[wpv-woo-product-price]
  </div>
  <div class="buy-archive">
[wpv-woo-buy-or-select add_to_cart_text="COMPRAR"]
  </div>
</div>
</div>
#903083

Check now, I think you had some unclosed divs causing problems. Here's the full code:

[wpv-layout-start]
  [wpv-items-found]
  <!-- wpv-loop-start -->
  <div class="container wpv-loop js-wpv-loop">
  <wpv-loop wrap="4" pad="true">
    [wpv-item index=1]
    <div class="row ">
      <div class="col-sm-3 col-xs-12">
        <div class="book-single-archive">
          <div class="imgbooks">
            <div class="imgbook">
              <a href="[wpv-post-url]">[wpv-post-featured-image size="woocommerce_thumbnail" class="book-image-shop"]</a>
            </div>
          </div>
          <div class="shop-text-wrapper">
            <p class="book-cat-shop">[wpv-post-taxonomy type="product_cat"]</p>
            <h2 class="book-title-shop">[wpv-post-link]</h2>
            <h3 class="book-author-shop">[wpv-post-link id="[wpv-post-field name="_wpcf_belongs_autor_id"]"]</h3>
          </div>
          <div class="price-shop-container">
            <div class="price-archive">
              [wpv-woo-product-price]
            </div>
            <div class="buy-archive">
              [wpv-woo-buy-or-select add_to_cart_text="COMPRAR"]
            </div>
          </div>
        </div>
      </div>
    [wpv-item index=other]
      <div class="col-sm-3 col-xs-12">
        <div class="book-single-archive">
          <div class="imgbooks">
            <div class="imgbook">
              <a href="[wpv-post-url]">[wpv-post-featured-image size="woocommerce_thumbnail" class="book-image-shop"]</a>
            </div>
          </div>
          <div class="shop-text-wrapper">
            <p class="book-cat-shop">[wpv-post-taxonomy type="product_cat"]</p>
            <h2 class="book-title-shop">[wpv-post-link]</h2>
            <h3 class="book-author-shop">[wpv-post-link id="[wpv-post-field name="_wpcf_belongs_autor_id"]"]</h3>
          </div>
          <div class="price-shop-container">
            <div class="price-archive">
              [wpv-woo-product-price]
            </div>
            <div class="buy-archive">
              [wpv-woo-buy-or-select add_to_cart_text="COMPRAR"]
            </div>
          </div>
        </div>
      </div>
    [wpv-item index=4]
      <div class="col-sm-3 col-xs-12">
        <div class="book-single-archive">
          <div class="imgbooks">
            <div class="imgbook">
              <a href="[wpv-post-url]">[wpv-post-featured-image size="woocommerce_thumbnail" class="book-image-shop"]</a>
            </div>
          </div>
          <div class="shop-text-wrapper">
            <p class="book-cat-shop">[wpv-post-taxonomy type="product_cat"]</p>
            <h2 class="book-title-shop">[wpv-post-link]</h2>
            <h3 class="book-author-shop">[wpv-post-link id="[wpv-post-field name="_wpcf_belongs_autor_id"]"]</h3>
          </div>
          <div class="price-shop-container">
            <div class="price-archive">
              [wpv-woo-product-price]
            </div>
            <div class="buy-archive">
              [wpv-woo-buy-or-select add_to_cart_text="COMPRAR"]
            </div>
          </div>
        </div>
      </div>
    </div>
    [wpv-item index=pad]
      <div class="col-sm-3 col-xs-12"></div>
    [wpv-item index=pad-last]
      <div class="col-sm-3 col-xs-12"></div>
    </div>
  </wpv-loop>
  </div>
  <!-- wpv-loop-end -->
  [/wpv-items-found]
  [wpv-no-items-found]
    <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
  [/wpv-no-items-found]
[wpv-layout-end]
#903092

Thank you so much Christian, you guys just rock it! Best support I've ever seen, love Toolset.