Site logo

Archived topic

How to insert a container within a post

20 replies · Started by robchanoi on March 29, 2022

Viewing posts 1–15 of 21

I'd like to place a container just after the intro of a post.
I complete posts in classic editor as i prefer in one long format, not creating individual containers for paragrahs, images etc. Posts are then put in a container in Gblocks.
Tried creating a new container below, adding an html block or code block and pasting text not visual of post, but it is not accepting the code properly.
Wanted to duplicate post below, delete relevant info and place new container in between with smth.
If I duplicate existing container with post inside, it places it in the same container and it can't locate a position to place a new container within the post.
Hopefully u know what i'm trying to say.
Post also ranks 1 in G and don't want to upset seo.
Thanks if u can advise.

Hi there,

so when you have a post that has been published - is it saved in the Block Editor or the Classic Editor ?

Either - I switch between the two.

I am a little unclear on the entire workflow. But if you swtich between Classic and Block editor, and in between add or make edits in HTML then you're going to run into problems.

One thing in your OT:

Posts are then put in a container in Gblocks.

What is this Container for ? As if all your content is moved inside one - then any block you add below that block needs to be moved inside it if you want to move it within the content.

I put the post in a container to set the width and position.
If I add a container inside the post, it starts at the bottom, then when I click the up arrow it shoots all the way to the top. There's no way to position where that container can go in the post.

So the content inside this Container - is that all inside a Classic Editor block ?

Yes, the classic editor block I drag into a container as advised in a previous topic.

Yeah, theres no way to put a block inside a classic block, you have to convert the classic blocks into individual blocks to do that.

yup, which is why i am trying to split the post up but when i copy and paste text into either custom html or code block it doesn't paste the code properly - do u know of a way of doing this?

The simplest solution is to convert it all to blocks.
Otherwise you will need to split your Classic Editor Block content into multiple Classic Editor Blocks. Then you can add other blocks in between them

Converting a long article with multiple images and designs is not a simple procedure converting to blocks - it's a lengthy one which is why I prefer classic editor from the beginning, but again, on your latter point - that is what I am trying to do David. What do you paste the post html into if html and code blocks don't work?

Hi robchanoi,

To add to the conversation:

WordPress automatically attempts to convert contents added through classic editor into blocks.

While it's not a perfect conversion, paragraphs and images are usually fine. Designed from custom HTML generally gets carried over as well (converted into custom HTML blocks) but it's a hit or miss. But at least, the automatic conversion should do the bulk of the task.

What do you paste the post html into if html and code blocks don’t work?

Not sure if I understand this correctly but if you meant to ask "where do I put HTML codes if the conversion to blocks don't work?", you can place the code within a Custom HTML block - https://share.getcloudapp.com/mXuY1Dj4

Let us know if this isn't the case. :)

Not sure if I understand this correctly but if you meant to ask “where do I put HTML codes if the conversion to blocks don’t work?”, you can place the code within a Custom HTML block –

By html I meant custom html as I wrote again further down:

when i copy and paste text into either custom html or code block it doesn’t paste the code properly

Hi Robchanoi,

To have a better understanding of the issue, may you provide a copy of the HTML code you’re trying to add, and we’ll try to test it from our end.

Hope to hear from you soon. :)

Ah right yeah I missed that one.

Custom HTML block is meant to display the HTML it contains as is.

Can you share a specific example of this occurrence? (a screen recording and/or screenshot)

Or perhaps have a staging site clone and let us have temporary backend access to check things? You can use the private information text field to provide the details - https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information

For the actual goal:

Going forward, I'd suggest sticking to just 1 editor (ideally go with Gutenberg) as switching between 2 editors can cause problems as David mentioned.

A compromise would be to work within the Block editor but use Classic block on some parts - https://share.getcloudapp.com/nOuRlLXo

As for placing a container specifically after the intro of the post, you can do this manually purely w/ Block Editor through setting it up like this:

first GB Container block {
> Intro
}

Second GB Container Block {
> the content to be added after the intro
}

third GB container block {
> the rest of the contents
}

But if I may suggest, If the "Intro > Container" is a recurring pattern/theme for each post, you may want to consider templating this.

Consider, having the Intro value be typed-in on a custom field for each post and then add the Intro element dynamically for each post through a GP Block Element.

And then, if the container right after the intro is a patterned/themed dynamic value as well, you can make set a custom field for that too and display it through a hooked GP Block Element as well.

This archived topic is closed to new replies.