Quantcast
Channel: Topic Tag: plugin | WordPress.org
Viewing all articles
Browse latest Browse all 26892

bcworkz on "How to display information on a page"

$
0
0

Displaying information at a particular spot on a page from a plugin can be tricky or simple, depending on where that spot is. Various themes display different things differently, but there are often common elements you can use to at least have a decent chance of your plugin working on various themes.

Start by learning which templates output the content you are interested in adding to with the default theme, or your chosen theme if the plugin is for yourself. Many themes will work off the same default theme organization. It can be difficult to identify which template is actually generating the output. I've resorted to putting html comments at the top of each template identifying it. The comments stand out nicely when one views the browser's page source of the output.

Once you've found the right template, view its PHP code and see which WP functions are being called to output information near where you want your information to appear. Locate the source code of these functions and look for any calls to apply_filters() and do_actions(). These are where the hooks are initiated that you may want to hook on to. Look at what the function passes to any hooks and what it does with the returned values, if anything. If you are developing for your own site only, things are much easier. Start a child theme and simply call you own functions on the child template where ever you want.

Based on this research, you can hopefully develop a scheme to display your information where and how you want. To actually begin a plugin, use FTP to create a plugin folder in wp-content/plugins/. In this folder, place you new main plugin php file. Beside containing your code and includes to other files, this file needs to have a particularly formatted comment at the top. After that, you can do pretty much whatever you need to do.

That should get you started, have fun!


Viewing all articles
Browse latest Browse all 26892

Trending Articles