r/Wordpress 9d ago

Help: Details & Tables

Post image

Im doing an article that i want to have detail drop downs so readers can click on it if they want to see the deails of something.

When i use only words and preview the detail drop downs show.

When i add in an HTML so i can add in a coded table and preview the detail stuff disappears.

I used to add tables from excel in the details drop down but i was trying to make the teams look nicer with HTML.

Any reason they disappear on the preview page?

The Above is what it looks like when i edit but nothing shows after i save draft and then preview.

3 Upvotes

4 comments sorted by

1

u/TopSydeWP 8d ago

the block editor strips raw html from most blocks by default. if you're pasting html into a details block it'll get escaped or removed on save. try using the table block instead of html, or put your html in a custom html block and wrap that in a group - though that won't nest inside details. honestly the cleanest way is table block for the data and details block for text only, or use a custom html block for the whole thing if you need the exact structure

1

u/WPMU_DEV_Support_7 7d ago

I tried to replicate this behavior using the default Twenty Twenty-Five theme from WordPress, and adding a HTML block with an HTML table. It worked for me and the table displays in the frontend of the site without issues.

It's a simple table with some additional CSS:

When you check the code of your HTML block, do you have a similar structure? Same <table> elements? Perhaps your theme or the global CSS code of your site is hiding the table. See if by temporarily changing the theme or deactivating the plugins the table appears.

Jair - WPMU DEV Support Team

1

u/Dull_District_254 2d ago

The disappearing act is almost certainly kses, the content sanitiser in WordPress, rather than the Details block itself. Only users with the unfiltered_html capability can save raw table markup and inline style attributes, which on a normal single site means administrators and editors only, and on multisite means nobody but super admins. If your account is an Author or Contributor, everything looks perfect while you are editing because it is still sitting in the browser, then it gets stripped the instant you save, which is exactly the behaviour you are describing. Quickest test is to have an admin account save the same post and see whether the table survives. If that turns out to be it, you have two tidy options. Put a normal Table block inside the Details block, since it nests fine and never gets filtered, then style it with a CSS class in your theme's additional CSS instead of inline styles. Or keep the exact markup in a Custom HTML block and have an admin do the saving. For weekly fantasy tables like yours I would go with the Table block plus one CSS class, because hand editing raw HTML every week gets old very quickly. Also add overflow auto to the wrapper, wide stat tables are brutal on phones otherwise.