Title: Generated Content Into Post Templates
Last modified: October 9, 2023

---

# Generated Content Into Post Templates

 *  Resolved [Zync](https://wordpress.org/support/users/zync/)
 * (@zync)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/)
 * Hi , I’m hoping you could help me get AI-generated articles including media and
   featured images, into our styled WP post block template/patters (that came with
   the theme).
 * Here are the post templates we use [https://curvspace.com/2023/09/20/are-mirrorless-cameras-will-go-extinct-in-the-near-future/](https://curvspace.com/2023/09/20/are-mirrorless-cameras-will-go-extinct-in-the-near-future/)
 * But when we generate (batches of) articles to that site, they don’t ‘merge or
   match’ with our post layout and styling.
 * Example [https://curvspace.com/2023/10/04/identifying-red-flags-of-fake-shopify-sales/](https://curvspace.com/2023/10/04/identifying-red-flags-of-fake-shopify-sales/);
 * So how might we achive that?
 * Thanks a lot for your help.

Viewing 15 replies - 1 through 15 (of 15 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/#post-17114399)
 * Unless you can prompt the AI to generate articles matching your site’s layout
   and styling, I think you’d either need to manually cut and paste parts of the
   content into your template’s blocks, or develop custom CSS for the AI generated
   content that will cause it to achieve the same layout and style without needing
   to alter content.
 *  Thread Starter [Zync](https://wordpress.org/support/users/zync/)
 * (@zync)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/#post-17114508)
 * Thanks a lot, could you explain a bit more (for my understanding) about the custom
   CSS, so I can make a project of it.
 * If you’ve seen raw AI acrticles output, it all looks exactly the same, headers
   and spaces, badly styled.
 * Thanks again
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/#post-17117114)
 * CSS only works on HTML elements. If the AI output is just straight text with 
   no HTML, you’ll need some sort of intermediate processor that would automatically
   assign HTML tags to content. To start with you could run it through [wpautop()](https://developer.wordpress.org/reference/functions/wpautop/).
   I’m not sure how code could distinguish sub-titles from regular text. Maybe if
   there’s only one sentence between newlines that is less than a certain number
   of characters?
 * While an intermediate processor will help you save time, it will not be infallible.
   Some manual formatting is inevitable. You likely need to insert your own images
   anyway? Once the HTML is reasonably well structured, CSS could be applied. For
   example, images could float left or right based on whether their count in content
   is odd or even, meaning images will alternate left or right justified.
 * The challenge is more in developing a decent intermediate processor than applying
   appropriate CSS.
 * I don’t suppose you could ask the AI to write an article that’s already in HTML
   format? 🙂
 *  Thread Starter [Zync](https://wordpress.org/support/users/zync/)
 * (@zync)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/#post-17117983)
 * Thank you so much for giving me a clear perspective on my issue and possible 
   solutions.
 * I started the discussion with our favorite content AI [https://aiwisemind.com/](https://aiwisemind.com/),
   and with your permission I’ll keep you posted on developments.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/#post-17119740)
 * Yes, I’m interested to hear how things develop. Properly formatting imported 
   data has always been a challenge. Importing AI content isn’t conceptually much
   different, but what AI might be able to do to help us remains undiscovered at
   this point.
 *  Thread Starter [Zync](https://wordpress.org/support/users/zync/)
 * (@zync)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/#post-17128965)
 * Haven’t heard back yet, but spotted an article about hooks, is this relevant 
   and helpful? (I could ask author)
 * > [Introducing Block Hooks for dynamic blocks](https://make.wordpress.org/core/2023/10/15/introducing-block-hooks-for-dynamic-blocks/)
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/#post-17130799)
 * Block hooks could be useful for dynamically fetching content from an alternative
   source such as an external API. But if you plan on importing AI content into 
   your site so it can be appropriately styled and served from your own server, 
   then block hooks probably would not be useful.
 * With either approach the problem remains — how to automatically format generic
   content so it looks presentable on your site.
 *  Thread Starter [Zync](https://wordpress.org/support/users/zync/)
 * (@zync)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/#post-17139296)
 * Found some new info on their content exports, which are “in TXT files in HTML
   format”. Would that work?
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/#post-17140826)
 * > in TXT files in HTML format
 * That’s a good start, but is the HTML format the way you want it? Like does it
   include appropriate H tags for sub-headings? Assuming it’s in a suitable format,
   then you basically fetch the file and place its contents on your page. In PHP
   it may be as simple as `echo file_get_contents('https://example.com/the-file-
   i-want.txt');` added to a template file.
 * It won’t really be that simple, but that’s the gist of what needs to happen.
 *  Thread Starter [Zync](https://wordpress.org/support/users/zync/)
 * (@zync)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/#post-17140932)
 * I was hoping for that response from you, I’ll dig further thanks! 
 * I have a batch and single here [https://drive.google.com/drive/folders/1_WPmXzJdC8s6GJkVExGRB84mgFCwapxz?usp=share_link](https://drive.google.com/drive/folders/1_WPmXzJdC8s6GJkVExGRB84mgFCwapxz?usp=share_link),
   maybe you could have a look?
 * There’s isn’t software that could change code directly in that TXT file, to upload
   those nicely aligned with our style and templates? (If it works that way at all)
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/page/2/#post-17141988)
 * Well, CSV files aren’t exactly the same as TXT files, so importing is a little
   more involved. But the bonus in doing so is you get useful supporting data like
   title and description. I suggest using one of the [CSV importer plugins](https://wordpress.org/plugins/search/import+csv/)
   to import files like this.
 * The content field is HTML format, so it ought to be somewhat presentable as-is.
   But to match your site’s layout and styling you will likely need some additional
   CSS. This could be rather tricky if the imported HTML is lacking attribute values
   you could use to style certain elements a certain way.
 * If simple CSS alone proves to be inadequate it would be possible to have code
   that alters the content by algorithm so it can be better styled. But naturally
   the things that need to be changed need to be consistent in some way so the algorithm
   can distinguish what to change from what not to change.
 * It may be some things will be too difficult to accomplish automatically. You’d
   then either need to live with what it is or manually correct things as necessary.
 *  Thread Starter [Zync](https://wordpress.org/support/users/zync/)
 * (@zync)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/page/2/#post-17142106)
 * Thank you for rounding this up for me into a solid working theory (that even 
   makes sense to me), and I got the CSV importer to test: [https://wordpress.org/support/topic/best-way-to-transfer-content-from-site-to-site/](https://wordpress.org/support/topic/best-way-to-transfer-content-from-site-to-site/)
 * Could you say if this is something new I’m trying to achieve? To me it seems 
   ultimately required to publish ‘stylishly’, directly from AI (plugins as well
   as connected) to site, isn’t it? 
 * I’ll write a job with your approach, start with CSS. For the best results I’m
   counting on hand-editing, but I want to see if and how close we can get to ‘aesthetically
   generated and automated’. How long would a first go at this take you think?
 * I’d like to invite you (if appropriate), but would already be thankful if you
   could look into some finished code I could show you here? 
 *  Thread Starter [Zync](https://wordpress.org/support/users/zync/)
 * (@zync)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/page/2/#post-17142180)
 * One more thing for my understanding; we apply our styling and preferences ‘retroactively’
   in-website correct? Inserting our HTML directly into the exported CSV file (and
   then import) isn’t a consideration right?
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/page/2/#post-17144628)
 * Importing CSV data has been a need from the beginning. But of course importing
   generative content is relatively new.
 * The difficulty is in getting imported content to match the layout and styling
   of your site. Every site is different so the exact specific approach has to likewise
   be specific to the site.
 * The first step is to import some sample content so you know what you have to 
   work with. You may want to do some preliminary processing that you know you’ll
   need, such as wrapping the entire content in the same div containers your theme
   normally uses. Or maybe wrap content in a div with a unique class attribute so
   that you can target your imported content with CSS that would not affect the 
   rest of your site.
 * Then develop CSS that best achieves the style and layout you want. You may find
   some aspects are difficult style because of what you have to work with. Determine
   what you’d need to get to your goals. Can this be somehow automated by algorithm?
   Then great, develop it! If it’s something that has to be done manually, are you
   willing to make the effort, or can you live without?
 * How long would this all take? I don’t know. There are too many variables at play.
 * I would be interested to see what you end up with. If you get stuck on something
   along the way, I’d be willing try and help out. But I suggest creating a new 
   topic in these forums because others might be in a better position than I to 
   help with a particular problem.
 * Good luck and happy coding 🙂
 *  Thread Starter [Zync](https://wordpress.org/support/users/zync/)
 * (@zync)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/page/2/#post-17145244)
 * You’ve given me the right comprehension of all the moving parts, thanks so much
   again this could have been a big hangup for me.
 * I’ll start putting it into action and carve my way, close the ticket for now 
   and update you with news.
 * All the best.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Generated Content Into Post Templates’ is closed to new replies.

## Tags

 * [templates](https://wordpress.org/support/topic-tag/templates/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 20 replies
 * 2 participants
 * Last reply from: [Zync](https://wordpress.org/support/users/zync/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/generated-content-into-post-templates/page/2/#post-17145244)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
