What is the correct way to update both WP/plugins/themes without breaking the site?

This is the reason I always recommend to use the least amount of plugins. This obviously easier to say then do, but if you are a developer you should strive to eliminate all plugins by incorporating the relevant code into a site specific plugin or theme. Integrators obviously have less ability to achieve this. The … Read more

Menu item added in wp_nav_menu_items filter is never highlighted

@AlexanderFarber, there are many way to attach attribute class under wp_nav_menu link. I agree with @Sumit, adding page links in Appearance > Menu WordPress take care of current-menu-item class or current_page_item class. Also, this way is best practice to handle your nav menu in the future. Create dynamic link in wp_nav_menu Since your question related … Read more

Display recent posts with thumbnail

the_post_thumbnail() can only be used in “the Loop”. What you need is get_the_post_thumbnail(). (See details and code examples on the code reference page). So something like: foreach( $recent_posts as $recent ){ echo ‘<li>’; echo get_the_post_thumbnail( $recent[‘ID’], ‘size’, array( ‘class’ => ‘alignleft’ ) ); echo ‘<a href=”‘ . get_permalink($recent[“ID”]) . ‘”>’ . ( __($recent[“post_title”])).'</a></li> ‘; } … Read more

Load a page into a div with Ajax

My philosophy is that if you use a system like WP then you embrace it and do things the WP way. WP has plenty of hooks that let you override functionality and the flexible theme structure gives you almost total control over the output. So, I’d advise using a WP theme and WP built in … Read more

Custom metabox for custom page template

<? // Check: // 1. If you are editing post, CPT, or page // 2. If post type IS NOT SET if( ‘post.php’ == basename($_SERVER[‘REQUEST_URI’], ‘?’ . $_SERVER[‘QUERY_STRING’]) && !isset($_GET[‘post_type’]) ) { // get post ID $postid = $_GET[‘post’]; // check the template file name if (‘my_template.php’ == get_page_template_slug($postid) ) { // add your metabox … Read more