Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
2  
This has already been answer on StackOverflow stackoverflow.com/questions/2810124/… –  Steve Jan 8 '13 at 3:24
add comment

migrated from webmasters.stackexchange.com Jan 8 '13 at 0:28

This question came from our site for pro webmasters.

3 Answers

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.

share|improve this answer
1  
+1 for shortcode. –  webaware Jan 8 '13 at 7:38
add comment

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.

share|improve this answer
1  
Custom page templates are the way to go. –  JCL1178 Jan 7 '13 at 23:47
add comment

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/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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