WP LOGBOOK

Little adventures building sites with Wordpress…

Archive for the ‘coding’ Category

How To Control Your List of URL Links or Blogroll

leave a comment »

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!

Written by Yahya Ayob

March 14, 2011 at 1:16 am

Posted in coding, tutorial, WordPress

How to embed videos from Facebook into WordPress

leave a comment »

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. =)

Written by Yahya Ayob

January 7, 2011 at 8:11 pm

How to display post links from WordPress.com to WordPress.org blog

leave a comment »

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!

Written by Yahya Ayob

December 6, 2010 at 11:24 am

Posted in coding, tutorial, WordPress

How to display post count from a category

with 4 comments

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.

Written by Yahya Ayob

December 5, 2010 at 7:48 pm

Posted in coding, tutorial, WordPress

Reusable Code for Custom Categories/Post Template

leave a comment »

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! =)

Written by Yahya Ayob

November 9, 2010 at 11:37 pm

Posted in coding, plugin, WordPress

How To Make WordPress More Social

leave a comment »

Written by Yahya Ayob

November 7, 2010 at 12:06 am

How To Allow Contributor User Role Upload Images

with 4 comments

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

Written by Yahya Ayob

November 2, 2010 at 7:18 am

Posted in coding, WordPress

How To Use WordPress Custom Fields Easily In Your Post

leave a comment »

Written by Yahya Ayob

November 1, 2010 at 7:30 am

Easy-To-Understand Introductory Video Tutorial About Using Custom Fields

leave a comment »

A few things to take note about using Custom Fields:

  1. Use it in the loop
  2. 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
  3. 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.

Written by Yahya Ayob

October 29, 2010 at 7:00 am

WordPress Post Thumbnail Revisit

leave a comment »

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://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature

http://wpengineer.com/1930/the-ultimative-guide-for-the_post_thumbnail-in-wordpress-2-9/

Have fun! =D

Written by Yahya Ayob

October 28, 2010 at 5:21 pm

Posted in coding, tutorial, WordPress

Follow

Get every new post delivered to your Inbox.