• Resolved theiconoclast31

    (@theiconoclast31)


    I’m creating a plugin using Devlounge’s How to Write a WordPress Plugin series.

    Is it possible to create a custom template tag that utilizes the database?

    There’s a catch! The Devlounge tutorial places the entire plugin inside a class, so my database information isn’t available outside of that class.

    And apparently, functions inside PHP classes aren’t available for use outside the class, so I can’t just place my <?php custom_template_tag() ?> inside my class iconoPlugins

    If I define the function within the class, it’s not possible to call the function from outside the class. If I define the function outside the class, it’s not possible to get my database information.

    I’m sure this is possible, but how? Something to do with get_option, perhaps? Or some tricky PHP wizardry?

    Thanks, guys.

Viewing 1 replies (of 1 total)
  • Thread Starter theiconoclast31

    (@theiconoclast31)

    Got it.

    For anybody curious, here’s the code I used:

    global $icono_plugin;
    	$settings = $icono_plugin->getAdminOptions();

Viewing 1 replies (of 1 total)
  • The topic ‘Custom template tags in my plugin’ is closed to new replies.