WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Detecting If The Current Page Is A Post Or A Page (2 posts)

  1. golddave
    Member
    Posted 4 years ago #

    I'm trying to add an option to a plugin that limits an action to posts, pages or both. When the setting is set to "posts" I want to check the current page to see if it's a post or a page. I'm using the following if statement:

    if ( ($current_options["page_type"] == "posts") && ( !is_page() ) )

    In other if we're set for posts only AND the current page is not a page (meaning it's a post) then execute the following code. When I load a page in the browser the the code still executes. I've tried adding wp_reset_query(); before the if statement but it still doesn't work.

    Any ideas how I can properly detect if I'm in a page or post?

  2. golddave
    Member
    Posted 4 years ago #

    Apparently removing some extraneous spaces makes a difference. It's working now with the following code:
    if ( ($current_options['page_type']=="posts") && (!is_page()) )

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags