Forums

is_home(), is_front_page() in Plugin Dev. (2 posts)

  1. ProHerb
    Member
    Posted 2 years ago #

    Hi,

    I try to develop plugin, so is_home() and is_front_page() even is_single() are not working for me.
    Many posts about this problem, it seem like "wp_reset_query();" placed before condition tag should be worked, but not me T-T.

    'wp_reset_query()' may work on wp theme develop NOT wp plugin.

    Here is my code

    wp_reset_query();
    if(!( is_home() || is_front_page() )){
          echo "my result's here";
    }

    or

    wp_reset_query();
    if(is_single()){
          echo "my result's here";
    }

    I put this code in my plugin and need it displays only single posts.

    Thank for everyone.

  2. ProHerb
    Member
    Posted 2 years ago #

    Just sample script.......

    Scritp path : htdocs/wp_local/wp-content/plugins/plugin_name/script.php
    Web path : http://localhost/wp_local/wp-content/plugins/plugin_name/script.php

    wp_reset_query();
    if ( is_single() ) {
        echo "This is a single";
    } else {
        echo "This is not a single";
    }

    See in Address Bar.
    ss_01
    ss_02

Topic Closed

This topic has been closed to new replies.

About this Topic