Community News – Custom Templates
Posted by Frank on May 21, 2011With the latest version of the Community News plugin, customizing the templates had been brought to a whole new level.
It is true that you are not able to simple edit the looks in your WP-Admin anymore, but instead there are simple PHP templates included with the plugin that you can easily modify.
Preparation
Before it is possible to start creating your own, custom, templates; a few things have to be done. This is necessary in order to keep your modifications while updating to a later version of the plugin.
Don’t worry, these steps are nothing more then copying, pasting and renaming a directory.
Preparation Steps
- First go to the plugin directory, usually /wp-content/plugins/fv-community-news/.
- Copy the Template directory.
- Go to your themes directory, usually /wp-content/themes/.
- Paste the Template directory here, and rename it to fvcn
- You can start editing the template files, located in the fvcn directory, now.
Template Files
Located in the directory you just created, there are a few PHP files. These are the template files you can modify. A brief description of each file will follow below:
form-widget.php
Displays the form in a widget.
form.php
Displays the form.
list-posts-widget.php
Displays the most recent posts in a widget.
list-posts.php
Displays the most recent posts.
posts-archive.php
Displays a complete archive of all the posts ever submitted.
So if, for example, you would like to change the looks of the recent posts in your sidebar widget; you will have to modify list-posts-widget.php.
Template Functions
With version 2.0 and up, the plugin has build-in template tags, very similar to the WordPress ones you use in your themes. You can use these functions to customize the default templates.
Post Functions
These functions can be used to render anything related to a submitted post.
fvcn_has_posts($args) |
|
|
|
fvcn_posts() |
|
|
|
fvcn_the_post() |
|
|
|
fvcn_get_post_id() |
|
|
|
fvcn_post_id() |
|
|
|
fvcn_get_post_author() |
|
|
|
fvcn_post_author() |
|
|
|
fvcn_get_post_author_email() |
|
|
|
fvcn_post_author_email() |
|
|
|
fvcn_get_post_status() |
|
|
|
fvcn_post_status() |
|
|
|
fvcn_get_post_author_ip() |
|
|
|
fvcn_post_author_ip() |
|
|
|
fvcn_get_post_title() |
|
|
|
fvcn_post_title() |
|
|
|
fvcn_get_post_content() |
|
|
|
fvcn_post_content() |
|
|
|
fvcn_get_post_excerpt() |
|
|
|
fvcn_post_excerpt() |
|
|
|
fvcn_get_post_url() |
|
|
|
fvcn_has_post_url() |
|
|
|
fvcn_post_url() |
|
|
|
fvcn_get_post_link($text) |
|
|
|
fvcn_post_link($text) |
|
|
|
fvcn_get_post_title_link() |
|
|
|
fvcn_get_post_date($format) |
|
|
|
fvcn_post_date($format) |
|
|
|
fvcn_get_post_views() |
|
|
|
fvcn_post_views() |
|
|
|
fvcn_get_post_approved() |
|
|
|
fvcn_post_approved() |
|
|
|
fvcn_get_post_approve_link() |
|
|
|
fvcn_post_approve_link() |
|
|
|
fvcn_get_post_unapprove_link() |
|
|
|
fvcn_post_unapprove_link() |
|
|
|
fvcn_get_post_edit_link() |
|
|
|
fvcn_post_edit_link() |
|
|
|
fvcn_get_post_spam_link() |
|
|
|
fvcn_post_spam_link() |
|
|
|
fvcn_get_post_unspam_link() |
|
|
|
fvcn_post_unspam_link() |
|
|
|
fvcn_get_post_delete_link() |
|
|
|
fvcn_post_delete_link() |
Form Functions
Use these functions to create the submission form.
fvcn_get_form() |
|
|
|
fvcn_form() |
|
|
|
fvcn_get_form_message() |
|
|
|
fvcn_form_message() |
|
|
|
fvcn_form_processed() |
Render Functions
These functions render a complete section.
fvcn_list_posts() |
|
|
|
fvcn_post_archives() |
Various Functions
Other functions.
fvcn_get_rss_url() |
|
|
|
fvcn_rss_url() |
More information on these functions will soon be available.
All these functions are located in the file fv-community-news/Includes/TemplateFunctions.php. You can view this file for more information on these functions as well.
I finally fixed the error, which was a problem caused by jQuery.
One more question though… I would like to place advertisement in between my resources. Let’s say I have 20 posts on 1 page and after the 10th I would like to show an ad. How can I make this work?
Hi Frank, thank you for your swift answer. It used to work just perfectly until I updated the FV Community News plugin. I will start to deactivate my plugins one by one and have an other look at it. Thanks!
Hi Frank, first of all I would like to thank you for updating this great plugin. Second of all, I had some problems configuring the plugin :-). When posting news (and everything is filled in), I receive the error “An error occured while processing your request, please try again later.”, but the submission is getting through.
Also, when I leave a field empty I get the same message but the message hasn’t actually being send over.
To me it looks like the file /Public/javascript/add-post.js is handling the error messages but I always get the same error.
Any idea of what the problem might be?
On of your plugins, or your theme, is generating output before the Community News plugin. This disallows it to modify the headers and thus it can’t send a response, causing the problem you have.
Pingback: Frank Verhoeven - Wordpress Plugin – FV Community News