Domanda

This issue has been driving me up a wall.

I've been working on a mobile website for a friend who uses wordpress. I'm attempting to modify a wordpress plugin that "rethemes" each page for mobile users. I want the plugin to do it's normal thing ("retheme" the page) iff the user is on the blog page, otherwise (if the user visits a different page, he will be redirected to a different address (the address of the mobile website).

In order to do this, I have to be able to detect whether I'm on the blog page, or a different page when the functions in the plugin are run.

I tried condtionals like is_home, is_page(id), ect., but none of them work. I also tried parsing the url and attempting to determine the page that way, but I can't.

I'm just getting my feet wet with PHP, so I'm really not sure what to try next.

To restate my question: How can I determine whether I'm on a certain page within a wordpress plugin function?

The plugin, for the record, is "Wordpress PDA & iPhoned" (http://imthi.com/wp-pda/)

Here's the relevant code:

function PDAPlugin() {
        if(true) {
        header("Location: http://adavidcreation.com/mobile");
        exit;
        }
...
}

This works, but I want to change the if statement to only be true if it's NOT the blog.

Any help would be greatly appreciated!

È stato utile?

Soluzione

Try using this, which should retrieve the page id: $id = get_option('page_for_posts');

If this doesnt work -> https://wordpress.stackexchange.com/

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top