WordPress Article Template plugin fix
Scenario:
A week ago, I upgraded my blog version to the latest version 3.0 and installed few plugins into this blog.
Found a very useful plugins call Article Templates that contribute by Binny V A.
Enables template support for posts and pages. You can see all existing templates in the Manage Templates page.
But found that the plugin does not work as expected. It does not save the template and the whole plugin is not usable.
No choices, I have to debug into WordPress & Article Template plugin in order to make it work for me.
Found the problem due to the “template” does not register as a post type.
So I added in the a line command in order to make it works.
Solution:
<?php include('wpframe.php'); wpframe_stop_direct_call(__FILE__); if(isset($_POST['action'])) { //FIX BY myhow2guru.com // Some Correction that point out by b. murphy. Appreciate that. register_post_type( 'template', array( 'public' => false, '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ ) ); //FIX BY myhow2guru.com END if($_POST['action'] == 'edit') { if(!isset($_POST['menu_order'])) $_POST['menu_order'] = 0; else { //If the post of any template is set to 1, that is the default template. Set all others to 0 $wpdb->get_results("UPDATE {$wpdb->posts} SET menu_order='0' WHERE post_type='template' AND post_author='{$current_user->ID}'"); } edit_post(); } elseif($_POST['action'] == 'new') { wp_write_post(); } } ?><div class="wrap"> <h2><?php e("Manage Templates"); ?></h2> <?php wp_enqueue_script( 'listman' ); wp_print_scripts(); ?> <table class="widefat"> <thead> <tr> <th scope="col"><div style="text-align: center;">ID</div></th> <th scope="col">Title</th> <th scope="col">Author</th> <th scope="col">Created on</th> <th scope="col" colspan="3">Action</th> </tr> </thead> <tbody id="the-list"> <?php // Retrieve the templates $templates = templates_get_users_templates($current_user->ID); if (count($templates)) { $bgcolor = ''; $class = ('alternate' == $class) ? '' : 'alternate'; foreach($templates as $template) { print "<tr id='post-{$template->ID}' class='$class'>\n"; $user_info = get_userdata($template->post_author); ?> <th scope="row" style="text-align: center;"><?=$template->ID ?></th> <td><?=$template->post_title ?></td> <td><?=apply_filters('the_author', $user_info->display_name) ?></td> <td><?=date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($template->post_date)) ?></td> <td><a href='post-new.php?template=<?=$template->post_name?>' class='edit' title='<?=__('Create a new post using this template')?>'><?=__('New Post')?></a></td> <td><a href='edit.php?page=article-templates/template_form.php&action=edit&template=<?=$template->ID?>' class='edit'><?= __('Edit'); ?></a></td> <td><?php $link = "post.php?action=delete&post=$template->ID"; if (function_exists('wp_nonce_url')) { $link = wp_nonce_url($link, 'delete-post_' . $template->ID); } ?><a href='<?=$link?>' class='delete' onclick="return confirm('<?php e(addslashes("You are about to delete this template '{$template->post_title}'. Press 'OK' to delete and 'Cancel' to stop."))?>');"><?=__('Delete')?></a></td> <?php } ?> </tr> <?php } else { ?> <tr style='background-color: <?php echo $bgcolor; ?>;'> <td colspan="4"><?php e('No templates found.') ?></td> </tr> <?php } ?> </tbody> </table> <a href="edit.php?page=article-templates/template_form.php&action=new"><?php e("Create New Template")?></a> </div> |
11 Comments to “WordPress Article Template plugin fix”
Leave a Reply
[…] This post was mentioned on Twitter by Quavario, myhow2guru. myhow2guru said: WordPress Article Template plugin fix http://bit.ly/c4dskH […]
[…] this link: WordPress Article Template plugin fix | How 2 Guru Tags: article, latest, plugin, programming, […]
I have made as you have written. The plug-in doesn’t save all the same
Thanks for the info, but I know exactly where I put this
code as the WP3.0 upgrade this plugin stopped working
I had the same issue @MrBoris. Move the myhow2guru fix up out of the if/elseif clause. This takes care of editing and creation.
Hi b.murphy,
Thanks for pointing out the problem and the solutions.
Cheers.
klasse! ich habe deinen code als neue manage.php gespeichert und hochgeladen- nun kann ich templates speichern. vielen dank
Hi Christiane,
Great to hear that.
Cheers.
Thanks for the fix!
I am the author of this plugin. Thanks for the fix. Its now in the plugin code base. You saved me a lot of work. 🙂
Hi Binny,
You are welcome.
Just to contribute back the solution to a useful plugin.
Cheers.