X-generated-css doesn't get written for custom post type

I know this is a very odd issue, and involves custom development work I did, so I hope you can answer it.

I have written a plugin that uses a custom post type and ties into ACF for specific fields I need for the posts. For the editor I’m using Cornerstone to make it simple for my clients (and because they’re used to using it). The posts are included in a page using a shortcode. This is because my plugin script needs to manipulate which post gets put on the page based on things in the custom fields.

While the posts look great in Cornerstone when editing, the x-generated-css doesn’t always get written to the page where I use the shortcode. SOMETIMES it will write, but other times it doesn’t. This means any kind of padding, margins, spacing, etc that I put into an element is ignored since that gets passed using the x-generated-css. To work around it, I’ve been adding CSS inline to text elements to get the spacing I want, but I want to fix the problem rather than try to work around it. I’ve tried changing the priority of when the CSS gets written (in X’s core file) but it hasn’t made any difference.

Is there something I can do to ensure the x-generated-css actually gets written to the page where I have the shortcode? And before you ask, I can’t use Global Blocks for this because - as I mentioned - I have to be able to manipulate which post gets put onto the page. This is dynamic content, not anything static.

Hi @geekgoddess,

Thanks for reaching out.

You mean you’re calling the content of the custom post type which is connected to ACF? The X generated CSS is always displayed on my custom post types because it’s part of wp_head action where a single post or custom post type has. If my guess is correct, you’re calling your created content as shortcode inputted as the shortcode from another post? if yes, then it’s not really going to work since there is no wp_head when you remotely access the content of another. Or if not correct, then please provide more information on how you implemented it. Though, I can’t really provide correction if it happened to be related to customization.

And maybe I was right since that pages and opt-in only contains page and not a post type, so I assume you only displayed the content of custom post type on that page. Hence only normal that it won’t generate the CSS that is supposed to be on wp_head.

Thanks!

Yes, I’m using a shortcode to insert the post. But that’s not unusual to insert a post onto a page. I’m simply doing a meta query reading the post meta to see what the dates are (thats the only thing I’m using ACF for, and it’s just to make sure the post falls between the dates I want to post to the page), then posting the content to the page.

I dug further into things and I see the generated code from cornerstone is actually NOT the x-generated-css. The cornerstone CSS comes from the Cornerstone plugin. I played around with my code some more and now I have it working perfectly. :slight_smile:

It’s awesome to create a custom post type and be able to use Cornerstone as the editor, then insert the results anywhere I want via shortcode.

To tell you exactly what I was writing the code for, it was to allow my client to have different opt-ins RANDOMLY rotate onto the top of the home page – but also be able to specify start and end dates for each one, AND also “weight” each one so some would appear more often than others.

Thank you again for responding even though it didn’t give me an answer. It DID make me go back to my code and bury myself in it until I figured out how to make it work. :slight_smile:

Hi @geekgoddess,

I’m glad that you found a way to fix the issue. As you are a developer and into these stuff, I suggest that you dig into the dynamic Ontent feature which is available in the new version.

It might not be useful for this case as you had to load the posts randomly, but in other cases, it helps you avoid adding code such as get_field() of teh ACF in the template files as you already have a way to show the custom fields in teh Cornerstone.

You can read more about the dynamic content here.

Thank you.

I’ve looked at the dynamic content and found it to be very limited – but I’m really glad Themeco is working hard to add more customization options to X and Pro!

I had never heard of Toolset. I see it’s not an included plugin (like the others the dynamic content can pull from), but I found it interesting since you can use your own functions within it. I’m so used to building out my own plugins for things that I am not always aware of options out there. Thanks for pointing me back to the changelog to make me look it up. :slight_smile: Could be a useful plugin for me. I’m always looking for ways to allow my clients to do things on their own if possible and also to speed up giving them the features they want.

Keep up the awesome work! ALL of you are so appreciated (particularly with the HUGE # of support questions you get).

You are most welcome!
We’re glad we were able to help you out.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.