Update the custom CSS on one Avada or WPBakery page

MaintenanceAdvanced~10 min

Before you start

Plugin version 1.12.0 or newer with Avada or WPBakery Page Builder active. The CSS write tools start off. Both need edit access to the page and a user who may post unfiltered HTML; by default that is an administrator or editor on a single site and only a super admin on multisite. Without it, the tools do not show up for the agent at all.

One landing page needs its hero image to stop cropping on phones, and the fix is three lines of CSS that only that page should get. Both builders give each page its own CSS box for exactly this, buried in the page settings panel. The agent can read and set it directly.

The write replaces the page’s CSS as a whole, so the prompt has the agent start from what is already there.

The prompt
On our [Summer offer] page (id [93]) I want this CSS added for that page
only:
[@media (max-width: 600px) { .hero-image { object-position: center top; } }]
Tell me which builder owns the page. Read its current page CSS: on Avada,
with avada-get-page-content and include_page_options; on WPBakery, with
wpbakery-get-page-content and include_page_settings. Show it to me as it is.
Then show me the full new CSS: every existing rule kept, with mine added at
the end. Do not write anything until I approve. Then save it with
avada-update-page-css or wpbakery-update-page-code (custom_css only), and give
me the previous value from the response so I can put it back if the page looks
wrong.

Why this is safe to run

The first step is a read, and the new CSS you approve contains the old rules, so the write cannot drop styling you forgot was there. A value equal to what is stored is left alone and reported as unchanged.

The way back is in the response. Both tools return the old CSS as previous, and sending it back restores the page. Avada also tells you, through previous_restorable, when the old CSS holds a form the tool would now refuse and so cannot be sent back as is. No revision is kept for page CSS, and the change is not in the Changes tab, so keep that previous value until you have checked the page.

The gate is strict on purpose: page CSS reaches every visitor of that page, so both tools need unfiltered HTML on top of edit access, and the agent cannot see them without it. They start off, run as the user you bound the agent to, and land in the Activity Log.

Already connected? Ask your agent for the “update the custom CSS on one page” recipe, paste the rule, and it runs the same read-first flow on your own site.

How it works

  1. Read the page's current custom CSS.
  2. Draft the full new CSS: the old rules plus your change.
  3. Show the old and new CSS side by side and wait for approval.
  4. Write the new CSS, which replaces the page's CSS as a whole.
  5. Keep the previous value from the response as the way back.

Questions

Does this change the site-wide CSS?
No. It sets the custom CSS of one page, the CSS field in that page's builder settings. WPBakery's global custom CSS is a separate site-wide setting with its own admin-only tool. Avada's global custom CSS is out of reach: the Avada Global Options tools never read or write it.
Why was my CSS refused?
CSS that holds markup is refused, as WordPress refuses it in custom CSS. Avada also refuses a < and a percent-encoded sequence such as %20, which it rewrites or removes when it prints page CSS. WPBakery refuses a < followed by another character, such as a <= range query, because WPBakery cuts the CSS off there.
Can it edit the page's JavaScript too?
On WPBakery, Update WPBakery page code also sets the header and footer JS, refused when the JS holds a closing script tag or when WPBakery's own Role Manager would not save custom JS for this user. This recipe sticks to CSS.