Displaying Posts From A Category In WordPress

It may happen that you are designing some sort of archive pages or a front page and you want to list all posts belonging to some specific category. In this case you can go for following code.

<?php
    $idObj = get_category_by_slug('category_slug_here');
    $id = $idObj-&gt;term_id;
    $posts = get_posts('category='.$id.'&amp;orderby=asc&amp;numberposts=10');
    while(have_posts()) {
        the_post();
        /* Do what ever you want with your posts */
    }
?>

One of the best thing about this code is, it lists all the posts from the specified category and if that specified category has child categories, then the code also lists the posts from child categories. That simply means you will have all posts from specified category and its all child category. You have to replace the ‘/* Do what ever you want with your posts */‘ with appropriate code to handle the post listing on the page.

Git: Delete Last Commit

Many times like you, even professional programmers do mistakes. A lot of times it happens that you commit something junk in hurry and then you start looking out for reverting it back. Like you even I have done such mistakes many times and finally I thought to write down a few useful git commands which will help me to revert back to stable copy of project.

Using ‘git reset’

So, if you have committed something junk, not useful but you have not pushed it to remote repository then you can go with


git reset --soft HEAD~1

git reset‘ command will reset your current commit. The ‘HEAD~1‘ mentioned here is nothing but shorthand for your last commit and the ‘–soft’ option specified in the command will keep all the changes in working copy.
Continue reading Git: Delete Last Commit

Working With wp_register_script()

WordPress allows you to register your own script files with theme. This allows you to link the script file to WordPress generated page according to the dependencies and at right time. The traditional way of including scripts, i.e. by adding <script> tag in head or footer have some drawbacks. In traditional way, we hardcode the script and load it every time with page, even though it is not needed. But once you register the script with theme, it can be loaded dynamically. This allows you to improve your performance and make your website more faster.

So how to register a script?

Quite simple. Just use following syntax for registering your scripts.

<?php wp_register_script( $handle, $src, $deps, $ver, $in_footer ); ?>
Continue reading Working With wp_register_script()

Switching On Inbox Tabs In Gmail

If you are having lots of mail in your mailbox then it is harder to find a particular mail. If you are receiving 20+ mails daily then you might need to spend huge time to check which messages are important and which are not. As the number of mails increases, complexity also increases. Of-course Gmail have tried each and every way to make your mailbox more and more manageable. Gmail introduced labels along with folders. You can use labels to categorize messages. But still working with label is not so simple and not that much complex. A few days ago Gmail developer found a new way to manage growing inbox and they named it as “Inbox Tabs“.

Gmail: Inbox Tabs
Gmail: Inbox Tabs

What are those tabs?

Gmail inbox tabs are somewhat similar to tabs in your browser. Gmail by default provides 5 tabs viz Primary, Social, Promotions, Updates and Forums. Since this is newest feature introduced by Google, still you cannot have custom tabs. Whenever a new email arrives to your inbox Gmail automatically detects the sender, classifies it and place it in appropriate tab. So you will find all your generic and primary communications in ‘Primary’ tab, social emails (which arrives from Google+ and Facebook) in ‘Social’ tab.  Even there are dedicated tabs for promotions, updates and forum emails.
Continue reading Switching On Inbox Tabs In Gmail

Creating Your Own Themes For Google Chrome

Of-course for most of you Google Chrome is just like a friend on internet. As you know, you can customize Google Chrome by adding several addons and themes from Chrome Web Store or form internet. Ya! those addons and themes are not customizable. Somebody has built it and you are consuming it. It may happen that, you may fall in love with a theme, but sometimes since it is your bad luck, when you download that theme, you find that it not having proper resolution! So here is one best option for you, Create your own theme.

Each one thinks in different way. Hence choices are different. Accounting such requirements of Google Chrome users, Google have developed an extension to create your own themes. You can navigate to Chrome Web Store and look for “My Chrome Theme” or else you can simply click here. You might need to sign in to Chrome Web Store to add this extension to your browser.

Getting Started

Create Your Own Theme:Chrome
Create Your Own Theme:Chrome (Introduction)

Creating themes with My Chrome Theme is quite easy. You just have to launch the app & click on “Start Making New Theme”.

Continue reading Creating Your Own Themes For Google Chrome

{developer} > Java > PHP > WordPress > HTML-CSS-JS