0

new user to WP. I am dynamically creating HTML tables with SQL data in my PHP. WordPress pages do not allow PHP code, and I've been hounded by individuals not to use a PHP plugin due to security reasons.

Now if i just needed to run a PHP file i would simply include it inside of my custom page-template. Since the code needs to be displayed inside the "content container" (which is dynamically loaded) I don't fully understand where to place my code.

<?php get_template_part( 'content', 'page' ); ?>

I've noticed this code above is calling the content container for that page. Should i be loading a different page here? or should i be directly modifying the page data inside the DB to reflect my php? will this work? whats the best thing to do in my situation?

2
  • "I've been hounded by individuals not to use a PHP plugin due to security reasons." If you are refering to Wordpress plugins (PHP plugins, basically), I don't know why someone told you that, but it's wrong.
    – Tomás Cot
    Commented Sep 2, 2014 at 2:16
  • I was told not to use php plugins because it enables users to enter potentially harmful php code into user inputs/ comments. Do you have a plugin you recommend?
    – 4554545434
    Commented Sep 2, 2014 at 2:52

1 Answer 1

0

The best way to create dynamic data outputs really depends on the what, why, and how.

For example, if you're creating a theme that creates its own custom post type, say, to store information about the head honchos that run the business behind the site, then just create a "single-$CPTNAME.php" template that has the code that you want.

Another method of doing this would be to create a custom template, and simply select that for a given page. See the WordPress Page Templates documentation for more information on how to create the custom templates and make them selectable in the WordPress admin UI.

3
  • I need a page that will take SQL data, create custom fields, display those custom fields in a HTML table. no user input. Need this data displayed in the content container area of default template. that is not possible? so what you are saying is basically i need to modify a custom template to create the HTML table/ sql calls on my wordpress page?
    – 4554545434
    Commented Sep 2, 2014 at 2:00
  • Of course I don't have a full picture of what you need: I can't give you a perfect answer on so little info. I can say that there are ways to do it; but if this is to pull from another system altogether then a plugin that creates a widget or WP shortcode which can be embedded into a page or post seems best. Commented Sep 2, 2014 at 16:35
  • I was aware of using a custom templates before hand i just thought there could be a different way that would involve less design work. I've decided to go with the custom template method, less coding for me, more work for the design guys :P thanks anyway dude.
    – 4554545434
    Commented Sep 2, 2014 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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