Site logo

Archived topic

How can I duplicate an element?

3 replies · Started by Saranne on August 24, 2021

Viewing posts 1–4 of 4

I want to duplicate my footer element, so I can have different colour footers on different pages.

Two questions:
(1) What's the best way to duplicate an element, if indeed that's possible?
(2) Is there an easier way to achieve the same ends. i.e. use the same footer element on all pages but with a different colour background, depending on the page?

Thanks!

Hi there,

1. Elements are a post type, so you can use the Duplicate Post plugin:

https://wordpress.org/plugins/duplicate-post/

One caveat - i haven't tested on a Block Element that uses the GenerateBlocks or other 3rd party plugins. It should be ok, but theres a possibility that unique IDs and classes for blocks may be duplicated.

2. It would require some CSS, if you have a Block element that is replacing the Site Footer then the base CSS would be:

.site-footer .gb-container {
    background-color: #f00;
}

This would replace the color on the entire site. To specify where it applies we can prefix the selector with a body class eg. this would apply to just the Pages ( not posts or archives ).

.page .site-footer .gb-container {
    background-color: #f00;
}

Let us know what specific pages you want to change it on and i can help.

I realised as I was that I could make a reusable block out of the footer and use that (unlinked) make the copy I needed.

Thanks David for your help :)

So many ways to do things :) Glad to hear you found one that works for you!!!

This archived topic is closed to new replies.