Using WordPress Menu As Bootstrap 4 Navbar

Using WordPress Menu As Bootstrap 4 Navbar

By OutsourcedContent — on September 29, 2017 This tutorial will help you use a WordPress menu with the Navbar component of Bootstrap 3 and Bootstrap 4. Please refer this guide for how to do it directly with Bootstrap. Here is the code to use WordPress navigational menu as the Navbar component. <nav class=”navbar navbar-expand-lg navbar-light…

Get First Category By Post ID In WordPress (Outside The Loop)

Get First Category By Post ID In WordPress (Outside The Loop)

By OutsourcedContent — on September 29, 2017 Use this code snippet to display the first category of a WordPress post. <?php $smello = (array) get_the_category($post_ID])[0]; echo $smello[‘cat_name’]; ?> where $post_ID is the ID of the post whose category is required. Change [0] to [1] to get the second category. Not all posts will…

Add Post Category Slug to Body Class in WordPress

Add Post Category Slug to Body Class in WordPress

By default WordPress adds many useful classes to body and posts, to help theme developers to style their sites effectively with only CSS and without needing to edit theme files unnecessarily. For example, WordPress adds the category name when you’re viewing an archive page so you can style archive pages differently for each category. But…

Remove Website/URL From WordPress Comment Form

Remove Website/URL From WordPress Comment Form

By OutsourcedContent — on October 5, 2017 Add this to the active theme’s functions.php. /** * Remove Website From Comments Form * * @since 1.0 * @refer https://millionclues.com/wordpress-tips/remove-websiteurl-from-wordpress-comment-form/ */ function mc_disable_comment_url ($fields) {   unset($fields[‘url’]);   return $fields; } add_filter(‘comment_form_default_fields’,’mc_disable_comment_url’);

Using Google Fonts In WordPress – The Right Way

Using Google Fonts In WordPress – The Right Way

By OutsourcedContent — on October 6, 2017 Add this in functions.php replacing the font of course. /** * Adding Goolge Fonts To WordPress – The Right Way * * @refer  https://wp-mix.com/right-way-include-google-fonts-wordpress/ */ function right_way_to_include_google_fonts() {   if (!is_admin()) {     wp_register_style(‘google’, ‘https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700’, array(), null, ‘all’);     wp_enqueue_style(‘google’);   } } add_action(‘wp_enqueue_scripts’, ‘right_way_to_include_google_fonts’);