Tagged: scss
- This topic has 6 replies, 2 voices, and was last updated 4 years, 10 months ago by
Sebastian.
Author | Posts |
---|---|
studioosiris
May 30, 2020 at 9:53 am
|
Heads up! this post was created when Microthemer was at version 6. The current version is 7. Some references to the interface may be out of date. Hi,
Its possible in Microthemer? |
Sebastian
May 30, 2020 at 5:55 pm
|
With ACF, you can get the value with PHP, but to incorporate that in your MT Sass code, you would need to use PHP to write some code to a Sass file e.g. wp-content/micro-themes/acf-variables.scss and then import that file at the top of the MT custom code editor using @import:
In order to write to the Sass code to a file you would need to use the PHP file system function e.g. file_put_contents. The Sass code you write to the file might look like this:
I hope that helps! Cheers, |
Sebastian
May 31, 2020 at 5:22 pm
|
Having said that, if the color needs to be different on different pages, the above solution won’t work. A better approach would be to use CSS variables rather than Sass variables. You can add the CSS code to the page head dynamically using the following PHP code:
(replacing red with the ACF PHP color variable) And then in Microthemer you would enter the color variable in the VAR field of the color picker:
|
studioosiris
June 2, 2020 at 8:29 pm
|
Hi, What I looking for is more complex rules, this is reason why I try it with SASS “if/else” conditions, there is more possibility. So not only for ACF, but if title is, or if post custom field, if sale_price is empty, … I find another SASS code, but conditions there not work (still display only “red”), I do not know how to implement ACF field there.
Its possible play with this code, or how modify it better? |
Sebastian
June 3, 2020 at 11:29 am
|
You could add the above code to your theme’s functions.php file, replacing ‘red’ with the ACF variable. But now that you’ve provided some more detail, I wonder if another method might be better. You could apply different classes to the body tag, depending on the ACF values. Then it’s simply a matter of referencing those classes to set different colors etc. You wouldn’t even need to use CSS or Sass variables. The PHP code (for functions.php) would look like this (I use get_field from checking the ACF API):
And then in Microthemer, you would have the following CSS:
You would set whatever classes you like in the PHP code, and then references the same class in the CSS. Does that make sense? |
studioosiris
June 7, 2020 at 12:39 am
|
Hi,
But not work. |
Sebastian
June 8, 2020 at 11:16 am
|
Hey, 1. It looks like the get_terms function returns an array of objects, rather than a single string like “custom_category_1”, so you would need to handle that with the relevant PHP code. For me to write this for you would be straying from the scope of support in this forum. If you are dabbling with custom PHP, I recommend seeking support on wordpress.org or stackoverflow. 2. You need to add the custom classes to the calendar entries, rather than the body tag. I’m not sure what you’re using to generate the calendar, but they might have an action hook you can tap into if you’re lucky. This would be a question for the author of the calendar, or its docs. I hope that helps! Cheers, |