Embedding css file for specific page only

Beside the index.html page I have a special pages that I need to embed a CSS file only for it and shouldn’t be embedded with other pages.

I use case for that is when I have RTL styling that should be included only with that RTL page.
The issue is whenever I include some link to that rtl css, it get automatically get embedded with all other pages (including index.html one).
I tried to change the page settings to :

  • [page-rtl.html] → Enable the This is a master page with its own header & footer option
  • [page-rtl.html] → Enable the Don't export template parts

But all css links mentioned on every page get embedded with every page, which I’m not expecting.

My question:

  • is this the normal behaviour to embed every mentioned css links on every pages ?
  • If I’d like to embed a special css file with 1 specific page, how can I do it ?

Note: I’m using the WP plugin designer not the desktop app, where I noticed that it contains libraries management that I couldn’t find in the WP plugin.

  • is this the normal behaviour to embed every mentioned css links on every pages ?
    Yes, PG will collect all JS/CSS files and add them to the functions.php file unless you mark that file as “Don’t Export” in the WP actions.

  • If I’d like to embed a special css file with 1 specific page, how can I do it ?
    You’ll need to write a custom piece of code so that the CSS file only gets enqueued on your specific page.

I’m not sure about the flexibility of the Plugin version of Pinegrow but in the desktop app, you would put that code in your inc/custom.php file. You can also look for a plugin that allows you to add PHP to your site, but I don’t like using plugins like that because it creates potential security issues.

@amersaw you can also use Condition action on the link / script elements to control conditions under which the resource loads:

There is also an approach of using a special settings.html page for defining all resources, that is suitable for keeping things organized in more complex projects:

1 Like