background preloader

10 Useful WordPress Loop Hacks

10 Useful WordPress Loop Hacks
The loop is a very important aspect of WordPress blogs. In fact, the loop is what allows you to get posts from your WordPress database and print them on the screen. A set of useful and user-friendly functions, the loop is incredibly powerful. In this article, we’ll show you 10 useful things you can do with the WordPress loop to make your blog even more powerful than it is right now. You may be interested in the following related posts: 1. Image source: Shutterstock The problem. The solution. <? Code explanation. As a result, the “WHERE” clause contained in the filter_where() function is added to the end of the SQL query contained in the post_where() function, which means that the loop will return posts published only between the two dates specified in the filter_where() function. Source WordPress loop: Get posts published between two particular dates6 2. The problem. The solution. Let’s start with the first loop. Code explanation. 3. The problem. The solution. <? Code explanation. 4. 5. <? 6. <?

WordPress-Gear WordPress Plugin Framework | theantichris.com View the repository on GitHub or download the source. This is an OOP framework for developing WordPress plugins. The main class uses the Singleton pattern to make sure that only one instance of the plugin is ever created. I have included blank methods for activation, deactivation, and registering scripts and styles. The base class sets up the text domain for internationalization and localization. I have included a blank uninstall file that is setup to make sure it can only be called from the WordPress dashboard. All custom plugin functionality should be started in the run_plugin() method. Instantiating Objects When instantiating an object such as Custom_Post_Type or Taxonomy save it to the proper array property on the main class. $this->custom_post_types[ 'new_custom_post_type' ] = Custom_Post_Type( $plural_post_type_name, $capabilities, $support, $menu_icon ) Custom Post Types You can create a custom post type through the CustomPostType object. Taxonomies Terms $new_taxonomy->add_terms( $terms );

WP-Quick-Pages WordPress plugin that lets you quickly create blank pages with hierarchies. Useful if you use WordPress as a CMS for simple sites that make use of pages. This plugin will add a submenu item called "WP Quick Pages" underneath "Pages" section of your admin area. On this age you can quickly enter pages, one per line, like this: About the Plugin FAQ Links Examples Contact When you're finished click the Create these pages button. The cool part is you can quickly show hierarchies as well: About the Plugin - Donate - Open Source -- Github -- Help Develop FAQ Links Examples - Example one -Example two Contact The example is probably pretty obvious, but the parent of the page is dictated by the number of hyphens in front of the title. If you find yourself working on sites where the structure gets decided upon before the content is necessarily ready (ahem) then you may find this useful.

How To Make Twenty Fourteen (Or Any Other WP Theme!) Super In a recent review of WordPress’ latest default theme, WPMU DEV’s Chris Knowles called Twenty Fourteen a “flawed beauty.” In that article, Chris recommended a number of potential improvements, and together we’ve put together this ultimate guide to addressing those flaws. And what’s more, these tips and techniques can be used in practically any WordPress theme. So, break out the cape, fire up your favorite editor, and give Twenty Fourteen a superhero makeover. Featured Plugin - WordPress Facebook Plugin Would you like to add Facebook comments, registration, 'Like' buttons and autoposting to your WP site? Find out more In this article, we are going to build a child theme that implements the improvements that Chris recommended in his review of Twenty Fourteen, namely: And to make your life even easier we’ve given you two paths to glory: 1. Still here? Before We Begin : Create a Child Theme As we know, if we want to customize a theme, then it’s essential to use a child theme. 1. What’s The Problem?

How to Improve Your 404 Page Template in WordPress 404 errors are not good for user experience. We showed you how to get email alerts for 404 errors on your site so that you can quickly fix them. In this article, we will show you how to improve your 404 page template in WordPress, so you can create a more useful 404 page that actually help users. How Most WordPress 404 Page Looks Like? 404 page is often the most neglected page on most sites. Often a lot of WordPress themes 404 page looks like this: This 404 page in WordPress is handled by a template file called 404.php. If your configuration is really messed up, then the 404 page would look like this: Neither of the above 404 pages are really useful. When a user lands on a 404 page, they’re already frustrated. You need to help the user find the right page. This can be done by showing them other sections of your sites they can visit, give them a way to contact you, etc. How to Create a Custom 404 Page in WordPress First thing we need to do is start by creating a custom 404 page template.

Optimizing Contact Form 7 for Better Performance Contact Form 7 is one of the most used free contact form plugins. At the time of this article, it has more than 16 million downloads. I think it is just right to consider it the most used contact form plugin. With this large of an audience, optimizing the usage of Contact Form 7 seems like optimizing a significant number of WordPress users. This redundant & wasteful inclusion should be addressed. An extra CSS and/or JavaScript file on every page will be like extra baggage which you don't want to pick up when you are walking on foot. If you have read my Beginners Guide to WordPress SEO by Yoast, you are aware of the fact, Google loves to rank the sites which have page load time below 1s. You might want to load these CSS & JavaScript files only on the pages where you are using the Contact Form 7 plugin to create a form. According to the plugin's author, Takayuki Miyoshi: First of all, we need to check which pages have contact forms. Let's find the slug of your page with contact form.

WPCandy | A blog all about WordPress. Yes, we're a bit meta. Creating a Custom WordPress Shortcode Creating your own WordPress shortcodes is a nifty way to build dynamic elements into your website without relying on 3rd party developers or plugins. This tutorial offers a beginner’s guide to creating your first WordPress plugin which will be referenced by a custom shortcode. In this example we’ll be creating a basic random quote generator plugin. This can just as easily be achieved through your themes but I prefer to be able to turn items on and off in WordPress without having to edit blocks of code. Creating the WordPress Plugin File If you’re familiar with WordPress plugins and have installed them before, you’ve probably seen folders chock full of complicated PHP classes. <? This is the required plugin info which will be used to populate the WordPress plugins page, and the license information. Creating the Plugin Function Although WordPress supports classes (and encourages their use to prevent naming clashes) it’s too big a subject for the scope of this plugin. <? <? Altogether now:

How To Add A New Yorker Style Header To Your WordPress Site The New Yorker does it and so does The New York Times, so perhaps it’s just a Big Apple thing. But changing and then fixing the page header as the reader scrolls up seems like an entirely sensible approach to not only maintaining branding but also to providing consistent and easy access to the primary navigation. In this post, I’ll show you how to do the same with your WordPress site, even if you don’t live in New York. There’s been quite a bit of coverage about the recently relaunched The New Yorker website in the WordPress community because, of course, it is powered by your favorite open-source content management system. The design is actually quite conservative but one of the features I really like is the treatment of the header. When a page first fires up, this is what you see: A full-header (there’s also a banner-ad above the title) with a large title and the main navigation. Adding the feature to your own WordPress site is relatively easy thanks to the myStickymenu plugin.

Related: