Category: Code Snippets
-

Identify Mobile / Tablet / Desktop Using Screen-size in CSS
[ad_1] By OutsourcedContent — on October 20, 2017 Add these to your CSS stylesheet as necessary. CSS to be used only on Mobile devices This CSS will be used when the screen width is less than 576px. @media screen and (max-width: 576px) { .selector { property: value; } } CSS to be used on anything…
-

Add Odd And Even Class to WordPress Posts
[ad_1] Often when designing a WordPress theme, designers choose to have different styling for odd/even comments. But recently while working on a project, I required to style odd and even blog posts differently. To do this, I needed to add odd and even class to WordPress posts. While searching for a solution, I found many…
-

Translate WordPress Programmatically With Gettext (Without .PO/.MO)
[ad_1] By OutsourcedContent — on October 23, 2017 Add this to the functions.php of your theme. This example is to be used with my Ask Me Anything (Anonymously) WordPress plugin. To use it with other themes and plugins, change the text domain of the theme or plugin in the highlighted areas. /** * Translate text…
-

Load Bootstrap 4 CSS And JS From MaxCDN – The Right Way
[ad_1] By OutsourcedContent — on October 25, 2017 Add this to the functions.php of the active theme. /** * Load Bootstrap CSS and JS from MaxCDN – the right way * * @refer https://millionclues.com/wordpress-tips/load-css-and-js-the-right-way/ */ function mcabl1226_load_css_and_js() { // Load Boostrap CSS wp_enqueue_style( ‘bootstrap-css’, ‘https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css’ ); // Load Theme’s style.css wp_enqueue_style( ‘style’, get_stylesheet_uri() ); …
-

Automatically Delete Users After 7 Days In WordPress
[ad_1] This is not the type of function you would require to use very often because it offers very specific feature toautomatically delete users after predefined time. I was looking to implement this feature in a past project where my client was offering temporary access to a section on his website to many users, but…
-

A Bookmarklet To Load WordPress Dashboard For Any Website
[ad_1] Divi is a WordPress theme that web designers do not want you to know. It comes with a drag-and-drop theme builder. You can build beautiful looking unique websites without touching a line of code. Just choose from one of the many pre-made layouts, or pick elements and arrange them any way you like. Divi…
-

Find All Posts Containing Given Image In WordPress
[ad_1] By OutsourcedContent — on November 9, 2017 Pass the id of the image to the function and it will return an array with the id’s of all the posts that use the given image. /** * Find all posts that uses the given image * * @param $image_id Integer ID of the image to work on *…
-

Prevent WordPress From Checking Update For Plugins
[ad_1] Many developers were concerned about the data WordPress should send back to WordPress.org when checking update for plugins and themes. Some have expressed concern that private plugins developed for a specific client or website may contain some sensitive information in their headers, like contact information for the developer, etc and it should not be…
-

Get Raw Unfiltered Post Title In WordPress
[ad_1] By OutsourcedContent — on November 10, 2017 To retrieve the post title of a post as saved in the wp_posts table in the WordPress database use this <?php echo get_post_field( ‘post_title’, $post_id, ‘raw’ ); ?> If you use get_the_title() function, WordPress applies the ‘the_title‘ filter before returning the value. [ad_2]
-

Sanitize And Escape Text Input In WordPress
[ad_1] By OutsourcedContent — on November 13, 2017 For general sanitization of text input fields and text areas for plugin options and such, use: sanitize_text_field( string $string ) For escaping in general for text input fields, use: esc_attr( string $string ) @refer https://wordpress.stackexchange.com/a/66323/90061 [ad_2]