How to hide PHP Warnings and Notices in WordPress

Find this line in your wp-config file:

define('WP_DEBUG', false);

Replace that line with this:

ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
Tweet It. Share It.

See more Code Snippet, php, Wordpress

Add Custom Meta Box With WYSIWYG Editor In WordPress

This is an easy way add a custom meta box to wordpress with a WYSIWYG editor. Check the wordpress documentation to understand exactly what options are available but this should get you started with setting up your own editable metabox.

 *    Create Metabox With WYSIWYG Editor

//This function initializes the meta box.
 function custom_editor_meta_box() {    
           add_meta_box ( 
           	  __('Custom Editor', 'custom-editor') , 
 //Displaying the meta box
 function custom_editor($post) {          
          echo "<h3>Add Your Custom Links and Other Content</h3>";
          $content = get_post_meta($post->ID, 'custom_editor', true);
          //This function adds the WYSIWYG Editor 
          wp_editor ( 
          	$content , 
          	array ( "media_buttons" => true ) 
 //This function saves the data you put in the meta box
 function custom_editor_save_postdata($post_id) {
    if( isset( $_POST['custom_editor_nonce'] ) && isset( $_POST['portfolio'] ) ) {
        //Not save if the user hasn't submitted changes
        if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
        // Verifying whether input is coming from the proper form
        if ( ! wp_verify_nonce ( $_POST['custom_editor_nonce'] ) ) {
        // Making sure the user has permission
        if( 'post' == $_POST['portfolio'] ) {
               if( ! current_user_can( 'edit_post', $post_id ) ) {
    if (!empty($_POST['custom_editor'])) {
        $data = $_POST['custom_editor'];
        update_post_meta($post_id, 'custom_editor', $data);
add_action('save_post', 'custom_editor_save_postdata');
add_action('admin_init', 'custom_editor_meta_box');

Use this code to output the results

<?php echo get_post_meta( get_the_ID(), 'custom_editor', true );?>

Tweet It. Share It.

See more Code Snippet, php, Wordpress

Build Your Own WordPress Related Posts

This code will display related posts by finding posts with the same tags as the current post.
If no related posts are found, the “Related Posts” section will not display.

// Related Posts Function, matches posts by tags - call using joints_related_posts(); )
function joints_related_posts() {
    global $post;
    $tags = wp_get_post_tags( $post->ID );
    if($tags) {
        foreach( $tags as $tag ) {
            $tag_arr .= $tag->slug . ',';
        $args = array(
            'tag' => $tag_arr,
            'numberposts' => 3, /* You can change this to show more */
            'post__not_in' => array($post->ID)
        $related_posts = get_posts( $args );
        if($related_posts) {
        echo '<h4>Related Posts</h4>';
        echo '<ul id="joints-related-posts">';
            foreach ( $related_posts as $post ) : setup_postdata( $post ); ?>
                <li class="related_post">
                    <a class="entry-unrelated" href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
                    <?php get_template_part( 'partials/content', 'byline' ); ?>
            <?php endforeach; }
    echo '</ul>';

//Additional arguments

//You can use any of the WP Query args with this function


$args = array(
'post_type' => 'YOUR POST TYPE NAME HERE' //this is the line you need to add
'tag' => $tag_arr,
'numberposts' => 3, /* You can change this to show more */
'post__not_in' => array($post->ID)

Credit goes to JOINTSWP for posting an actual solution that worked: JOINTSWP

Tweet It. Share It.

See more Code Snippet, php, Wordpress

Unregister Custom Post Types In WordPress

* Unregister Custom Post Types

function custom_unregister_theme_post_types() {
global $wp_post_types;
foreach( array( 'portfolio', 'clients', 'team', 'testimonials' ) as $post_type ) {
if ( isset( $wp_post_types[ $post_type ] ) ) {
unset( $wp_post_types[ $post_type ] );
add_action( 'init', 'custom_unregister_theme_post_types', 20 );

Credit goes to Themify for posting an actual solution that worked: Themify

Tweet It. Share It.

See more Code Snippet, php, Programming, Wordpress

Easy Pagination In WordPress

Using the WP PageNavi Plugin ( you can easily achieve pagination in your theme. This plugin works right out of the box with the default settings.

Below is my archives.php template

 * Template Name: Archives Template

<?php get_header(); ?>

<div id="wrapper hentry">

  <div class="container">

    <div class="row push-down">
      <?php if ( function_exists('yoast_breadcrumb') ) {yoast_breadcrumb('<p id="breadcrumbs">','</p>');} ?>

      <div class="col-sm-8 special-page-bg">


          while($wp_query->have_posts()) : $wp_query->the_post(); ?>
            <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">

            <span><?php the_time('F j, Y'); ?></span><br/>

            <p class="entry-title"><a class="cta-link-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>


          <?php endwhile; ?>
          <?php wp_pagenavi(); ?>

          <?php wp_reset_postdata(); // reset the query ?>


      </div><!-- .col-sm-8 -->

            <?php get_sidebar(); ?>

    </div><!-- .row -->

  </div><!-- .container -->

</div><!-- .wrapper -->

<?php get_footer(); ?>

Just add the $paged variable to your wp_query():


Then add this right after your main loop before resetting your query:

    <?php wp_pagenavi(); ?>

That’s all it takes to get functional pagination. You can add css and style this any way you like and there are also options within the plugin settings to customize even further.

Tweet It. Share It.

See more Code Snippet, Wordpress

WordPress Functions

For this tutorial I am going to cover some of the most common WordPress functions that developers use on a regular basis.

Header Tags

Display the blog name

<?php bloginfo('name'); ?>

Display the blog url

<?php bloginfo('url'); ?>

The stylesheet location

<?php bloginfo('stylesheet_url'); ?>

The location of the theme files directory

<?php bloginfo('template_directory'); ?>

The atom url for the blog

<?php bloginfo('atom_url'); ?>

Display the Rss2 url for the blog

<?php bloginfo('rss2_url'); ?>

The charset of the blog

<?php bloginfo('charset'); ?>

Pingback url of the blog

<?php bloginfo('pingback_url'); ?>

WordPress version of the blog

<?php bloginfo('version'); ?>

HTML version of the website

<?php bloginfo('html_type'); ?>

Template Tags

Display the page title

<?php the_title(); ?>

Display the content

<?php the_content(); ?>

Display the exerpt

<?php the_exerpt(); ?>

Display the published date

<?php the_date(); ?>

Display the published time

<!--?php the_time(); ?-->

Display the category


Display the url link for the page/post


Display the number ID of the post

<?php the_ID(); ?>

Display the author of the post

<?php the_author(); ?>

Display the previous page and next page links

<?php posts_nav_link(); ?>

Display the newer posts link

<?php next_post_link(); ?>

Display the previous posts link


Display a link to edit the post

<?php edit_post_link(__('Edit Post')); ?>

Display the search form value

<?php the_search_query(); ?>

Display the pages

<?php wp_list_pages(); ?>

Display the tag cloud

<?php wp_tag_cloud(); ?>

Display the categories

<?php wp_list_cats(); ?>

Display the calendar

<?php get_calendar(); ?>

Display the archives by date

<?php wp_get_archives(); ?>

Display the blogroll link

<?php get_links_list(); ?>

Display a register link

<?php wp_register(); ?>

Display a login/logout link

<?php wp_loginout(); ?>

Displays the admin meta

<?php wp_meta(); ?>


These are the most common Template tags used in WordPress Development. It is not intended to be a complete list of WordPress functions, just the common ones for someone just getting started developing with WordPress.

Many of the template tags are meant to be used within the WordPress loop but I have also included some like login/logout, calendar and some other ones that are commonly placed in the sidebar or footer.

Tweet It. Share It.

See more Wordpress

10 Great Free WordPress Themes Of 2012



Get This Theme
Great clean looking responsive theme that would be great for small business websites.



Get This Theme
Great Drag and Drop framework theme for designers or bloggers that don’t want to dive into html/css.



Get This Theme
Great theme for craftmakers or anyone else interested in making an extra income

Xena Store

xena store

Nice clean Ecommerce theme



Get This Theme
Nice clean newspaper theme



Get This Theme
Modern Portfolio Theme

Imbalance 2


Get This Theme
Great Portfolio theme for showcasing graphic design or photography work



Portfolio, video or gaming theme



Modern and clean portfolio theme



Nice dark business theme from WooThemes

Tweet It. Share It.

See more Wordpress