apiraino
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: pagename variableSort of, but unfortunately it’s more complicated.
I am using is_page(‘name’) for some of what I’m doing, but for this particular part it would be more like:
if (is_page(‘2’) || is_page(‘3’) || is_page(‘4’)) {
do some stuff
if (is_page(‘3’)) {
do some additional stuff
}
if (is_page(‘4’)) {
do yet some other stuff
}
}just as an approximation. Some of the “stuff” I have to do could be simplified if I had access to the current page name, rather than having to do multiple checks for it.
Forum: Fixing WordPress
In reply to: pagename variable“So if it works, then it works.”
Yeah, part of me thinks that way too, but then another part thinks that if it’s not “proper” it could abruptly stop working in a subsequent WP update without niceties like deprecation or any kind of warning. I’m also curious why it seems like such an easy, straightforward way to do this, yet is not mentioned *anywhere* (except for on the one mystery page that I can’t find anymore).
What I’m trying to do is use the current page name in some conditional logic – i.e., if you’re looking at Page1, show X, and if you’re looking at Page2, show Y.
I tried an alternate way of doing it that I’ve seen elsewhere, using
$post->post_name;
to get the page name. However, some of my Pages display post content on them, and that line of code then returns the slug for the post rather than the Page, which is not what I’m looking for.