The way I’d do it is using options: add_option, update_option, get_option.
In your plugin, use add_option/update_option to change the values of “teaser.” Then in the loop you show above, use get_option to retrieve the value and echo it.
I don’t think filters are going to work for you in this instance.
Yeah planned to do the actual stuff with filters just hoped I’d be able to somehow place it directly into the template.
Well so echo it is, if it can’t be done with filters 🙂
THanks.
Create your own action or filter hook?
In your template.. do an action (or create a filter if you like)..
Example..
<?php do_action( 'my_intro' ); ?>
Then in your theme’s functions file add an action to the hook..
add_action( 'my_intro', 'my_intro_callback' );
function my_intro_callback() {
?>
<!-- Your HTML, or whatever you want can go here -->
<?php
}
Of course taking care with those opening and closing PHP tags, careful not to nest them.. add or remove them as appropriate..
Thanks Mark,
this solution is at least a little better than to call the plugin-class directly in the template. Sadly this still leaves me with PHP-Code in the template but well, can’t help it, it’s not THAT bad 😉
You’re welcome.. 😉
Something to note is that you can put these action calls throughout your theme, in various places, using the same action name (my_intro in the example) and the function you’ve hooked onto that action will execute whenever a page calling that action is loaded.. so in effect what you have is some static content that can be called in various places, but only needs to edited or added to in one place(the function that defines the text/html)..
If the above wasn’t the exact solution you were after, you’re welcome to clarify/expand the original question, and i’ll do what i can to help.. 🙂
it’s not the most exact one. What i was after directly was something like the following:
Take some gallery-plugin as an example. You write a news-post and to display that news-post you write something like ‘[gallery id=3]‘
To replace that you add_filter(‘the_content’, ‘someFunction’) to replace that tag with the corresponding html, etc…
Now what i wanted to do is exactly that – simply outside the loop within my template files. But this isn’t really needed that badly, as the above do_action() works just fine.
I don’t really know why I’m such a crybaby for having one more PHP-Tag inside a template (as php is a templating engine itself..) but well, i don’t know 😛 It’s just about feeling of having a
teaser
against a
<?php do_action(‘teaser’);?>
inside the templates 😀
I’m not sure i entirely follow what it is you want still unfortunately, but code displayed in this form [tag] is usually referred to as a shortcode, these typically get run and included inside the content of a post, are you wanting this code to interact with the content of a post/page?
There’s a shortcode API available if you want to add your own shortcodes..
http://codex.wordpress.org/Shortcode_API
The primary design of the shortcodes is to interpret shortcodes inside content placed inside the WordPress editor, so any shortcodes you add are only executed on the content of posts(pages, etc) by default(although it is possible to execute shortcodes on other data).
I hope that answers what you’re asking, if not i’d appreciate you trying to break down the details of the desired functionality a little more please.. 😉
Regardless, i’m happy to help.. 🙂