开发者

Content elements for wordpress

I'm looking for a plugin (or better yet, not a plugin) for wordpress that lets me generate standard content elements, or includes for posts and pages.

For example, my_content_1 could be:

buy it now for开发者_如何学Go $23!!

Which could then be included in posts and pages using some kind of syntax (or whatever) like:

Welcome to my site, blah blah blah.. check out this product - %my_content_1%

Not looking for anything fancy, anything that does this sort of thing would be awesome.

The point of this being much like a regular php include I could have the same information updated in one place and applied over many pages/posts.

I found something that is pretty much what I'm looking for: http://wordpress.org/extend/plugins/reusables/

However, other suggestions would be good as I'm not too confident in the quality of the code for that plugin.


Not sure about a plugin, but how about simply creating something yourself? If you created a PHP page and set up variables such as

$content->title = "This is a title"
$content->smallText = "Insert some short paragraph here"

And then just include it in your header? You could store it in your theme directory and then call it like so

<?php $themeFolder = get_bloginfo("template_url"); ?>
<?php include($themeFolder."/content.php") ?>

Would that be suitable?


How about creating a few files and link them in using shortcode? ie: open your themes/functions.php file add this..

<?php
function wp_my_shortcodes($atts) 
{
    extract(shortcode_atts(array(
                            'type' => '',  //author, rss, adverts
                            ), $atts));
    switch($type) {
        case 'author'   : $display = wp_display_author_info(); break;
        case 'rssview'  : $display = wp_display_rss_info(); break;
        case 'adverts'  : $display = wp_display_adverts(); break;
        default     : $display = wp_display_author_info(); break;
    }
    return $display ;                       
}
add_shortcode('mycontent', wp_my_shortcodes);


function wp_display_author_info()
{
    include(TEMPLATEPATH.'/my_author_info.php');    
}
function wp_display_rss_info()
{
    include(TEMPLATEPATH.'/my_rss_info.php');   
}
function wp_display_adverts()
{
    include(TEMPLATEPATH.'/my_adverts.php');    
}
?>

using shortcodes inside your posts you can then bring in which ever piece of content that you want.. in the example above I've created 3 pages in the template root folder called my_author_info.php, my_rss_info.php, my_adverts.php all of which speak for themself..

my_author_info.php
this page could use the the_author_meta() to populate a div box with included author info,

my_rss_info.php
include your subscription box to let users subscribe to your blog

my_adverts.php
include 4x 125x125 adverts?

so in the post i could use

[mycontent type='author']
[mycontent type='rssview']
[mycontent type='adverts']

if no argument is added to the shortcode then the default view is shown, in this case..

[mycontent]

would return the authorview as default... this would then include that file in the content...

just remember to create the included files :)


I found something that is pretty much what I'm looking for:

http://wordpress.org/extend/plugins/reusables/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜