Category: Code Snippets
-

How to Add CSS Styles to WordPress Admin
[ad_1] By OutsourcedContent — on April 16, 2012 WordPress has obviously grown from a personal blogging tool to a collaborative blogging environment with multiple authors and multiple blogs in a network with the WordPress multisite. This sometimes call for styling not only your front end for your visitors, but also the backend of your WordPress…
-

Auto Link Featured Post Thumbnails to The Post Permalink
[ad_1] Without any doubts, featured post thumbnails are one of the best features of WordPress. That’s why we are always trying to customize them and use them in unique ways on WordPress websites. For example, in previous articles we posted about how to add featured post thumbnails into blog RSS feeds, create an intuitive image…
-

Automatically Add Image Caption, Description And Alt Text From Image Title
[ad_1] I do not use that many images in my posts, but when I do, I do it right. By that I mean, I make sure the image is cropped and optimized for the web (I use Kraken.io) and I rename the image to mean something rather than it saying IMG_0507.img. While naming stuff, I…
-

Query Anything On WordPress Anywhere
[ad_1] By OutsourcedContent — on August 27, 2017 <?php $args = array( ‘posts_per_page’ => ‘3’, ‘post_status’ => ‘publish’, ); $recent_posts = wp_get_recent_posts( $args ); // Loop each post foreach( $recent_posts as $recent ) { echo get_the_title($recent[“ID”]); echo $recent[“post_content”]; } wp_reset_query(); ?> Refer the WP_Query class reference for a complete list of arguments. Another Approach <?php…
-

Display Top 10 Authors on Your WordPress Blog
[ad_1] You might have seen, many websites and blogs displays top 10 authors in sidebar of their website, to give proper recognition to contributing authors for their work. And you might be wondering how to add such neat feature on your blog too. Well, to be honest it’s not that difficult to list top 10…
-

Display First Few Characters Of A WordPress Post Outside The Loop
[ad_1] By OutsourcedContent — on August 27, 2017 <?php echo apply_filters( ‘the_content’, wp_trim_words( strip_tags( get_post_field(‘post_content’, $recent[“ID”]) ), 55 ) ); ?> where$recent[“ID”]is of the ID of the post. If you are already querying the post and already have a WP_Post object, you can simply use this: <?php echo apply_filters( ‘the_content’, wp_trim_words( strip_tags( $recent[“post_content”] ), 55…
-

Load CSS and JS the right way
[ad_1] By OutsourcedContent — on August 27, 2017 /** * Load CSS and JS the right way * * @since 1.0 * @refer https://developer.wordpress.org/reference/functions/wp_enqueue_style/#comment-340 */ function firerooster_load_css_and_js() { // Load Boostrap CSS wp_enqueue_style( ‘bootstrap-css’, get_template_directory_uri() . ‘/includes/bootstrap4/css/bootstrap.min.css’ ); // Load style.css wp_enqueue_style( ‘style’, get_stylesheet_uri() ); // Load Boostrap JS wp_enqueue_script( ‘bootstrap-js’, get_stylesheet_directory_uri() . ‘/includes/bootstrap4/js/bootstrap.min.js’, array(‘jquery’),…
-

Auto Link Keywords in Post Content And Excerpt
[ad_1] If you are a blogger and make some cash from affiliate marketing then you probably insert affiliate links into the articles on your website, so that you get paid when a visitor purchase a product that you recommended. But if you are just starting out on affiliate marketing and want to insert affiliate link…
-

Escaping Text With Links In WordPress – The Right Way
[ad_1] By OutsourcedContent — on August 29, 2017 Escaping a text with links can be replaced if escaped with __() during localization. This not ideal since the person writing the localizing file could replace links with their own. The proper way to do this is explained with an example below: sprintf( __( ‘If you like…
-

Embed YouTube Videos On Bootstrap 4 Popup Modals With AutoPlay
[ad_1] By OutsourcedContent — on August 30, 2017 Bootstrap 4 does not natively support embedding videos on its modal popup windows. Here is how to embed YouTube videos on modal windows. Code from this Stack Overflow post has been modified for this tutorial. Features Video will start playing once the modal window loads. This can…