Skip Navigation

[Resolved] Masonry styles are not applied to a View of sibling posts displayed via wpv-view shortcode

This thread is resolved. Here is a description of the problem and solution.

Problem: I have created some Views that use Masonry to display a grid of posts. One of these Views displays sibling posts of the post where this View is displayed. I need to use a shortcode attribute here to pass the current post's parent post ID into the post relationship Query Filter. The Query Filter seems to work as expected because I see the correct results in the output, however, the Masonry styles are not applied as expected.

If I insert the View via the original Content Template, the Masonry styles are applied as expected, but the results are not filtered by post relationship. I need to use the wpv-view shortcode in this case so I can add a shortcode argument for the post relationship Query filter. How can I insert the View in a way that maintains the post relationship Query Filter and also displays the results in a Masonry grid?

Solution: The most practical solution in this case is to add the missing CSS grid styles manually. To find the missing styles, temporarily insert the Content Template containing the original View. Compare the two results in the browser inspector / debugger tools to find missing styles. In this case, the following styles were missing when the View is inserted using a shortcode:

.tb-masonry {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  grid-column-gap: 25px;
}

Add the missing styles in the View block's Custom CSS panel.

This support ticket is created 2 years, 11 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 12 replies, has 3 voices.

Last updated by Christian Cox 2 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#2046375
Screenshot 2021-05-06 at 17.16.01.png
Screenshot 2021-05-06 at 17.10.07.png

Hii,
I'm trying to show brothers contents into a child page and I followed this post: https://toolset.com/forums/topic/view-to-display-more-children-of-the-same-parent-on-the-single-page-of-a-child/

I created a new content template with a view that shows contents filtered with The post with ID set by the shortcode attribute wpvrelatedto and I set up its layout as masonry style. (attachment 1)

Then in the product custom template I created a shortcode field and I added this shortcode
[wpv-view name="WorkOfSameArtist" wpvrelatedto="[wpv-post-id item='@artist-works.parent']"]

It works fine but I see it as a large column layout and not with a masonry layout as in my view. (attachment 2)

How can I solve it? Thank you!

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#2046925

Hello, I will be glad to help figure this out. It sounds like the View's post relationship filter is working correctly, but the masonry design is broken. I am not able to determine the source problem based on these screenshots - there could be a conflict between Toolset and another plugin, or a conflict between Toolset and your theme, a problem with the image dimensions, or some other issue I'm not able to predict. If you provide a URL where I can see the problem on your site, I will be glad to take a closer look.

Please try these troubleshooting steps, or let me know if it's okay for me to run the same tests after logging in:
- Be sure your WordPress installation, your theme, and all your Toolset plugins are up-to-date. To update to the latest Toolset plugins automatically, go to wp-admin > Plugins > Add New. Click the Commercial tab. Scroll down to the Toolset Installer and click "Check for Updates" to verify the latest plugins are installed.
- Temporarily activate a default theme like Twenty Twenty One.
- Temporarily deactivate any custom code snippets in Toolset > Settings > Custom Code.
- Temporarily deactivate all plugins except Toolset Types and Toolset Blocks (or Toolset Views, if your site uses the legacy Views plugin). If these Product posts are WooCommerce Products, keep WooCommerce and Toolset WooCommerce Blocks active as well.
- Test the masonry View again.
- If the problem is resolved, reactivate your theme, custom code snippets, and other plugins, one by one, testing each time until the problem returns.
- If the problem is not resolved, I will need to take a closer look. Please provide login credentials in the private reply fields here, and let me know the URL of one of the Product posts where I can see the masonry problem.

#2047685
Screenshot-2021-05-07-at-13.13.55.png

Sorry... the page where you can see tests is this: hidden link

Thank you!

#2049427

Sorry, I'm trying to log in here using those credentials but I get an error "Unknown username. Check again or try your email address."
hidden link

Am I logging into the correct site? Can you check the login credentials and provide an update if necessary?

#2049605

Thanks, I was able to log in this time and I can see the issue you have described. It looks like some of the masonry styles are not carried over when this View is inserted using a shortcode, instead of using the full Content Template where it was created. As a workaround, I have added the following CSS code to the Content Template here:
hidden link

.tb-masonry {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  grid-column-gap: 25px;
}

Now when I visit the Product post on the front-end of the site, I see the masonry layout applied as expected here:
hidden link

Can you confirm?

#2049965

My issue is resolved now and it works fine also with my theme. Thank you!

#2050835
wrong.jpg
correct.jpg

Hi,
I have the same problem with another view.

I created three formatted views with columns. I showed them in a content template with [wpv-view name="MainEventView"] shortcode. After saving they are ok, but if I refresh the page they lose columns.
You can see the correct and the wrong versions in the attachments.

You can access the site with the same credentials I sent you before.

You can find views in Content Template: MainEventView, PastEventsView, ComingUpView
You can find the final page in Content Template: Events Directory.

Should I add some other CSS code?

Thank you for your help.

#2051087

Shane
Supporter

Languages: English (English )

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

Hello,

Christian is currently on a public holiday today but he will be back tomorrow to continue assisting you with this one.

Thank you for the patience and understanding.

#2052061

Hello, in these 3 cases it looks like you are not using shortcode arguments to pass Query Filter parameters into these Views. If you are not using shortcode arguments, it will be more appropriate to place the Content Template containing each View in the Block Editor using a Content Template block, instead of using a shortcode to place the View directly in the Block Editor. When you place the Content Template containing the View instead, the styles you apply to each View will be automatically applied without the need for additional CSS. This will make maintenance easier in the future, since you don't need to worry about updating CSS in other locations throughout the site when you make changes to each View.

#2052299

Hi, I tried t add the view in a bock as you said, but the result is the same.
You can see it at hidden link
The first block is a view, the second is a shortcode field.
They don't show columns.
I don't understand why.

#2052397

Please check now, I have replaced the View block with a Content Template Block, since this View is designed in a Content Template. Now the top View is displayed in columns as expected. Use a Content Template Block, not a View Block. Thank you.

#2052729

Sorry I haven't understood the difference.
Now the page works fine.
Thank you, have a nice day 🙂

#2053023

Great! I'm glad this is resolved for you. Feel free to open new tickets if new issues arise.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.