6

I'd like to access a DB table and render it in some data grid format using php on a dedicated wordpress page, accessible to members of a certain group. Is this at all possible with wordpress or is there another way to do so?

using wp 3.5 on linux system + mysql thanks

1

3 Answers 3

6

You can create a simple plugin and either add a shortcode to run your php, or filter the_content and add a conditional check for your specific page and inject your DB output. This way your code will be independent of the theme and more portable. Use the wpdb class to query any database /table.

0
3

What do you mean by "page" here?
You can throw whatever PHP you want into a page template. If this is a more or less one-off thing, what you should probably do is use the conditional tags to just embed it.

If you mean you want to do this within content arbitrarily ie. through the post editor, that's disallowed by core, but there are plugins that add the capability. The most recent one I'm aware of is Allow PHP in Posts and Pages, (there are others and you might want to look around) but this is something that's generally advised against unless you absolutely trust every single person that might have access.

1
  • 1
    Custom page templates are the way to go.
    – JCL1178
    Jan 7, 2013 at 23:47
0

There are plugins that allow you to run php code in the post content. Here are a couple:

http://wordpress.org/extend/plugins/php-code-for-posts/ http://wordpress.org/extend/plugins/allow-php-in-posts-and-pages/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.