Writing a plugin
-
Here’s another guy trying to learn how to write a plugin. I am VERY new to writing a plugins and this is the only method in which I can get my function to work.
In the world of plugins, is it ok to write a function like this.
function my_function() { ?> <div id="box"> <div id="myLoop"> <?php query_posts('showposts=5');?> <?php while (have_posts()) : the_post(); ?> <div> <div class="title"><a href="<?php the_permalink() ?>"> </a></div> <a href="<?php the_permalink() ?>" rel="bookmark" title="Link to <?php the_title(); ?>"> <h3><strong><?php the_title(); ?></strong></h3> </a> <?php the_excerpt(); ?> </div> <?php endwhile; ?> //Reset Query <?php wp_reset_query(); ?> </div> </div> <?php } ?>And then include the function on a page with:
<?php if (function_exists("my_function")) { my_function(); } ?>Should I code this differently when working with pluin API?
Thanks for any help.
The topic ‘Writing a plugin’ is closed to new replies.