Archive for the ‘coding’ Category
How To Control Your List of URL Links or Blogroll
I read these resouces:
http://www.wpbeginner.com/wp-tutorials/how-to-organize-your-wordpress-blogroll-links/ which shows the actual example code that really works.
http://codex.wordpress.org/Function_Reference/wp_list_bookmarks which made me understand a little bit more of the parameters.
And I came up with these:
wp_list_bookmarks(‘title_li=&category_name=programs&before=<li>&after=</li>&orderby=id’);
It works! I hope this is useful to you guys too! Cheerz!
How to embed videos from Facebook into WordPress
I’ve seen the embed code before but I just could not remember where. So I searched it again on the web and Shoutpedia has a facebook note that explains how you can embed videos from Facebook into a WordPress post.
I can’t seem to paste the code here. So check out Shoutpedia note in Facebook.
Hope this helps. That’s all. =)
How to display post links from WordPress.com to WordPress.org blog
I needed a way to show post links from my WordPress.com blog into my custom-designed WordPress.org site.
I was searching high and low on the web and finally I managed to read this post. Really help me to understand with his detailed explanation of using the code.
The trick is that if you are inserting this code in an already existing unordered list, it will not work and instead your site will give an error.
Just plainly insert the code without the unordered list
- .
Hope this helps! Cheerz!
How to display post count from a category
I am just recording my work right now. I found this to work really well.
function wt_get_category_count($input = '') {
global $wpdb;
if($input == '')
{
$category = get_the_category();
return $category[0]->category_count;
}
elseif(is_numeric($input))
{
$SQL = "SELECT $wpdb->term_taxonomy.count FROM $wpdb->terms, $wpdb->term_taxonomy WHERE $wpdb->terms.term_id=$wpdb->term_taxonomy.term_id AND $wpdb->term_taxonomy.term_id=$input";
return $wpdb->get_var($SQL);
}
else
{
$SQL = "SELECT $wpdb->term_taxonomy.count FROM $wpdb->terms, $wpdb->term_taxonomy WHERE $wpdb->terms.term_id=$wpdb->term_taxonomy.term_id AND $wpdb->terms.slug='$input'";
return $wpdb->get_var($SQL);
}
}
Place above in your function.php file.
And then add below inside the regular php begin and end to any location you want the count to be displayed.
echo wt_get_category_count(categoryid);
Thanks to WPCode.net for the post here.
Reusable Code for Custom Categories/Post Template
I was looking out for WordPress websites from Singapore and somehow this page got my attention. The codes should still be working as it should when creating templates for categories and posts.
http://fthrwght.com/2008/05/22/custom-category-post-template-plugin/
Do check it out and see if this works at your side. Enjoy! =)
How To Make WordPress More Social
How To Allow Contributor User Role Upload Images
One of the many questions people asked me is how do you allow a contributor in WordPress to upload images and files.
The Contributor User Role allows you to write a post and submit it for pending review by the Administrator to approve and publish. That’s by default and the big disadvantage here is that you don’t have the ability to upload images or files in the post.
There is a way. Add the following code to the file functions.php:
if ( current_user_can('contributor') && !current_user_can('upload_files') )
add_action('admin_init', 'allow_contributor_uploads');
function allow_contributor_uploads() {
$contributor = get_role('contributor');
$contributor->add_cap('upload_files');
}
That’s it. Now your Contributors should be able to upload images or files in the post and submit it for pending review.
Hope this helps. =D
How To Use WordPress Custom Fields Easily In Your Post
Easy-To-Understand Introductory Video Tutorial About Using Custom Fields
A few things to take note about using Custom Fields:
- Use it in the loop
- Make sure to use the <?php if so that custom fields with no value for that particular key name will not show in the post
- In order to show the values, you need to use echo
The video below from WordPress.tv helps you to understand how a custom field is used. Do take note of the coding. You can pause the video tutorial and click full-screen so that you can study the codes, practise and keep it as your own code snippet which will be useful in the future when you need to code fast.
WordPress Post Thumbnail Revisit
In WordPress 3+, the post-thumbnail is replace with featured image. But don’t sweat! Everything else is the same.
Which means you can still use the following guidelines from these super-mentors:
http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/
http://wpengineer.com/1930/the-ultimative-guide-for-the_post_thumbnail-in-wordpress-2-9/
Have fun! =D
