php is_page()
-
Mod
I’ve been using the PHP plugin, trying to echo something to both posts and pages. No matter what I try, I can’t get it to show up on pages, only posts.
I’ve tried
if (is_singular())which only shows up only on posts, and
if (is_single() || is_page())which also shows up only on posts, and even
if ($post_type->name == 'page' )which I got from here and which didn’t show up anywhere.
I even tried this:
if (is_front_page() || is_archive() || is_attachment()) {} elsewhich again worked on posts, but not pages.
Any ideas what I am doing wrong?
References:
http://codex.wordpress.org/Function_Reference/is_single
http://codex.wordpress.org/Function_Reference/is_singular
Thanks
Admin
Hurm..where is this function attached to?
Mod
It’s in a PHP widget in the after_post_content widget area.
Full code is here: http://pastebin.com/2H7SRLNY
Admin
It could be that the global
$postvariable has been changed (or destroyed?) by the time the script is executed. Can’t really tell without delving deeper into it.Have you tried using the Widget Logic (Visual) with it?
Mod
It could be that the global $post variable has been changed (or destroyed?)
I’ll look into this. At least my syntax is right.
Have you tried using the Widget Logic (Visual) with it?
I’ll try this tomorrow, I think, if I can’t get anything else to work. I wanted to avoid adding another plugin as I’m still looking for a good secondary slider plugin. (Nothing yet on that account, though.)
Thanks for taking a look.
Admin
Try this and see what’s the output:
global $wp_query;
disect_it( $wp_query );Mod
Where should I add that?
Mod
Of course, you are absolutely right.
I didn’t even notice that file before. I did exactly as you suggested and it all works fine now. Thanks.
Sidenote: I can now do what I originally intended to do with an HTML widget, instead of a PHP widget. Graphene really does make things easy, except for when I overcomplicate them.
Thanks again, everyone.
Admin
Quote:isn’t after_post_content intended for posts only.why not add to both after_post_content and after_page_content hooks
Ah yes, I forgot this too 🙂
Viewing 10 posts - 1 through 10 (of 10 total)
- You must be logged in to reply to this topic.
