Get all wordpress custom fields from a page or a post

October 10, 2009

Sometimes you may need to get all custom fields from a specific post or page. How can we do that? Just paste the following functions on the functions.php files from your theme. Note: The function have lots of comments so it will help you to understand how it works. function all_my_customs($id = 0){ //if we want to run this function on a page of our choosing them the next section is skipped. //if not it grabs the ID of the current page and uses it from now on. if ($id == 0) : global $wp_query; ... [Read the full story]

Choose which wordpress sidebar to use

September 26, 2009

WordPress always have to display the same boring sidebar on each page? What can we do? Don’t worry, just create a few sidebar files, upload it to your wordpress theme directory. Then the code follow will do the rest. open single.php and find the call to the get_sidebar() function: <?php get_sidebar(); ?> Replace it by: <?php $sidebar = get_post_meta($post->ID, "sidebar", true); get_sidebar($sidebar); ?> Now when you’ll write a post, create a custom field name sidebar. As a value, give it the name... [Read the full story]

Hide wordpress login page error feedback

September 25, 2009

Is your blog secure? Normally when you try to login and mess something up, WordPress dishes out a helpful sentence or two either explaining that your username or your password is incorrect. While this is helpful for you and your site’s members, it’s also helpful for anyone trying to do bad things to your site. Here is a quick tip that you can easily implement to prevent displaying useful message to potential wordpress hackers. To remove theses error messages, simply open your functions.php file and paste the... [Read the full story]

Tell WordPress to Use the Default Theme

September 24, 2009

The $theme variable of wordpress control the apparence of your wordpress, its value is the name of your wordpress theme. We’ll show you how you can switch themes using a simple code snippet. Just paste the following code in the functions.php file. When this code will be executed, the “default” theme will replace your current theme. add_filter('option_template', 'themechoose'); add_filter('template', 'themechoose'); add_filter('option_template', 'themechoose'); add_filter('option_stylesheet', 'themechoose'); function... [Read the full story]

Display the loop using wordpress shortcode

September 23, 2009

The loop is the easiest way to display WordPress posts, perfect for those sites who are using WordPress as a CMS. But we can create a shortcode that will make post displaying simpler. Use this shortcode below to create a loop on a page, post or sidebar. Just use template tags and html like you would in a normal loop to create your layout. The sample below displays an unordered list with titles and links to the post. Just paste code in your functions.php file. Or if you want, you can use it in a plugin. // The Loop /* *... [Read the full story]