Can I use PHP inside CSS pseudo class
I have this code
a:after{
content url:(/path to my image/my_image.png)
......
}
and it works fine. But I am now migrating my site to WordPress. I can't use the WordPress function get_theme_file_uri();
to get my image path Or is there another alternative.
css wordpress
add a comment |
I have this code
a:after{
content url:(/path to my image/my_image.png)
......
}
and it works fine. But I am now migrating my site to WordPress. I can't use the WordPress function get_theme_file_uri();
to get my image path Or is there another alternative.
css wordpress
2
how is this a php question? There's only CSS here.
– Funk Forty Niner
Nov 14 '18 at 18:38
You need to add your PHP code when you tag PHP!
– Ashouri
Nov 14 '18 at 18:59
add a comment |
I have this code
a:after{
content url:(/path to my image/my_image.png)
......
}
and it works fine. But I am now migrating my site to WordPress. I can't use the WordPress function get_theme_file_uri();
to get my image path Or is there another alternative.
css wordpress
I have this code
a:after{
content url:(/path to my image/my_image.png)
......
}
and it works fine. But I am now migrating my site to WordPress. I can't use the WordPress function get_theme_file_uri();
to get my image path Or is there another alternative.
css wordpress
css wordpress
edited Nov 14 '18 at 19:00
foliwe83
asked Nov 14 '18 at 18:30
foliwe83foliwe83
7711
7711
2
how is this a php question? There's only CSS here.
– Funk Forty Niner
Nov 14 '18 at 18:38
You need to add your PHP code when you tag PHP!
– Ashouri
Nov 14 '18 at 18:59
add a comment |
2
how is this a php question? There's only CSS here.
– Funk Forty Niner
Nov 14 '18 at 18:38
You need to add your PHP code when you tag PHP!
– Ashouri
Nov 14 '18 at 18:59
2
2
how is this a php question? There's only CSS here.
– Funk Forty Niner
Nov 14 '18 at 18:38
how is this a php question? There's only CSS here.
– Funk Forty Niner
Nov 14 '18 at 18:38
You need to add your PHP code when you tag PHP!
– Ashouri
Nov 14 '18 at 18:59
You need to add your PHP code when you tag PHP!
– Ashouri
Nov 14 '18 at 18:59
add a comment |
2 Answers
2
active
oldest
votes
Unless you're running your CSS documents through a PHP eval()
function (which you shouldn't do by most standards) there isn't a good way to execture PHP inside of CSS. The best way to solve your issue is linking directly to the image.
Assuming your directory structure is something like:
[..]
[wp-admin]
[wp-content]
[uploads]
[images]
--my-image.jpg--
[wp-includes]
--other files--
You could use it by simply using a relative path to the file, like:
a::after {
content: url(/wp-content/uploads/images/my-image.jpg);
}
add a comment |
CSS urls are relative to the CSS file.
if you have structure like
..
images
my_image.png
index.php
style.css
you can use a relative URL like:
a:after{
content url:(images/my_image.png)
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53306652%2fcan-i-use-php-inside-css-pseudo-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Unless you're running your CSS documents through a PHP eval()
function (which you shouldn't do by most standards) there isn't a good way to execture PHP inside of CSS. The best way to solve your issue is linking directly to the image.
Assuming your directory structure is something like:
[..]
[wp-admin]
[wp-content]
[uploads]
[images]
--my-image.jpg--
[wp-includes]
--other files--
You could use it by simply using a relative path to the file, like:
a::after {
content: url(/wp-content/uploads/images/my-image.jpg);
}
add a comment |
Unless you're running your CSS documents through a PHP eval()
function (which you shouldn't do by most standards) there isn't a good way to execture PHP inside of CSS. The best way to solve your issue is linking directly to the image.
Assuming your directory structure is something like:
[..]
[wp-admin]
[wp-content]
[uploads]
[images]
--my-image.jpg--
[wp-includes]
--other files--
You could use it by simply using a relative path to the file, like:
a::after {
content: url(/wp-content/uploads/images/my-image.jpg);
}
add a comment |
Unless you're running your CSS documents through a PHP eval()
function (which you shouldn't do by most standards) there isn't a good way to execture PHP inside of CSS. The best way to solve your issue is linking directly to the image.
Assuming your directory structure is something like:
[..]
[wp-admin]
[wp-content]
[uploads]
[images]
--my-image.jpg--
[wp-includes]
--other files--
You could use it by simply using a relative path to the file, like:
a::after {
content: url(/wp-content/uploads/images/my-image.jpg);
}
Unless you're running your CSS documents through a PHP eval()
function (which you shouldn't do by most standards) there isn't a good way to execture PHP inside of CSS. The best way to solve your issue is linking directly to the image.
Assuming your directory structure is something like:
[..]
[wp-admin]
[wp-content]
[uploads]
[images]
--my-image.jpg--
[wp-includes]
--other files--
You could use it by simply using a relative path to the file, like:
a::after {
content: url(/wp-content/uploads/images/my-image.jpg);
}
answered Nov 14 '18 at 18:53
RyanRyan
3169
3169
add a comment |
add a comment |
CSS urls are relative to the CSS file.
if you have structure like
..
images
my_image.png
index.php
style.css
you can use a relative URL like:
a:after{
content url:(images/my_image.png)
}
add a comment |
CSS urls are relative to the CSS file.
if you have structure like
..
images
my_image.png
index.php
style.css
you can use a relative URL like:
a:after{
content url:(images/my_image.png)
}
add a comment |
CSS urls are relative to the CSS file.
if you have structure like
..
images
my_image.png
index.php
style.css
you can use a relative URL like:
a:after{
content url:(images/my_image.png)
}
CSS urls are relative to the CSS file.
if you have structure like
..
images
my_image.png
index.php
style.css
you can use a relative URL like:
a:after{
content url:(images/my_image.png)
}
answered Nov 14 '18 at 18:36
Eriks KlotinsEriks Klotins
1,3611517
1,3611517
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53306652%2fcan-i-use-php-inside-css-pseudo-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
how is this a php question? There's only CSS here.
– Funk Forty Niner
Nov 14 '18 at 18:38
You need to add your PHP code when you tag PHP!
– Ashouri
Nov 14 '18 at 18:59