WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom template tags in my plugin (2 posts)

  1. theiconoclast31
    Member
    Posted 7 years ago #

    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.

  2. theiconoclast31
    Member
    Posted 7 years ago #

    Got it.

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

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

Topic Closed

This topic has been closed to new replies.

About this Topic