Categories
WordPress

Create New Admin Account With PHP Code

Hey there! It has been a long long time since my last post! So here is my gem of the day ūüėČ

Personally, I use this code very frequently and it has saved me from a lot of trouble many times. There are times when I do not have access to a site’s with administrator privileges, nor to the phpMyAdmin to create a new user. In these cases, I use the following PHP code, in the functions.php file, of an active theme:

function add_admin_acct(){
	$login = 'mynewusername';
	$passw = 'mynewpassword';
	$email = 'my@email.com';

	if ( !username_exists( $login )  && !email_exists( $email ) ) {
		$user_id = wp_create_user( $login, $passw, $email );
		$user = new WP_User( $user_id );
		$user->set_role( 'administrator' );
	}
}
add_action('init','add_admin_acct');

This piece of code is not mine, I’ve found it on¬†George’s Stephanis website for which I am very grateful.

After this code is added, simply visit the front end of a site. Please always remember to remove this code once a user is created, for security reasons.

Do you have any other way to create an administrator with PHP code?

Categories
Blog WordPress

How To Add CSS Code In MU Plugin

A must-use plugin (also called a ‚Äėmu-plugin‚Äô) is a plugin that will always be activated by default, without you needing to do it yourself. To activate a mu-plugin, you just have to upload it in the right directory, and WordPress will automatically know that this plugin must be used. Moreover, a mu-plugin cannot be deactivated: it will always be executed, unless it is uninstalled.

Originally, mu-plugins were only available for WPMU, for those sites which used multiple (multisite) blogs. Back then, a mu-plugin was just a plugin activated for all blogs.

Fun fact, that the WordPress is loading mu-plugins in alphabetical order, before normal plugins.

All mu-plugins must be placed at wp-content/mu-plugins by default, in case /mu-plugins/ folder is not there, feel free to create it.

Add CSS code in mu-plugin

Create a file named style.php and add the following code inside.

<?php
add_action( 'wp_head', function() {
 ?>
 <style>
 
/* YOUR CSS CODE GOES HERE*/

 </style>
 <?php
} );

Add your CSS code between

<style></style>

tags.

 

 

Fell free to comment bellow if you have something new to add ūüôā

Categories
WordPress

Show the Featured Image Inside A Post On A Site Using Shortcode

If you are looking how to insert a featured image inside a post, you can try the following solution.

 Add the following code inside the functions.php of your theme:

add_shortcode('thumbnail','thumbnail_in_content');
function thumbnail_in_content( $atts ) {
global $post;
return get_the_post_thumbnail( $post->ID );
}

Control the features images with the shortcode:

[thumbnail size=medium align=right]

The side can be changed to small, medium and large values and/or align can be none, center, right or left.

Another way to control the thumbnail size with size=’array( 300, 200)’. It will look like this

[thumbnail size='array( 300, 200)']

Change the array value to a different number to achieve the result you need.

Categories
WordPress

Update URLs Through phpMyAdmin After Site Migration

So you’ve migrated a site to a new host with a new domain and forgot to change the site’s URLs. No worries a simple solution you can try is to change them¬†within the phpMyAdmin.

Go to your cPanel and locate the phpMyAdmin icon. Click on it and you will be redirected to it.

Default caption

 

Make sure you have the new database selected, then run some sql updates and replacement commands on the tables notably, wp_options, wp_posts, wp_postmeta.

Don’t forget to replace wp_ prefix with your own ūüėČ
‚Äč

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
Categories
WordPress WordPress beginner

Best CSS Code Generators

Web designers are always looking for shortcuts to save time in their routine. Many great dev tools ease the process, and it’s now easier than ever to jump in and get a finished product quickly. Free online code generators will help you iterate and build onto your code quickly. Once you know what code you need to generate, it’s just a matter of finding the right tool for the job. These are my 10 favorite tools for generating CSS, and they’re all completely free to use.

I have gathered in one place the best free online code generators that will help build faster the design you need. Once you know what code you need to generate, it’s just a matter of finding the right tool for the job.

uiGradients

uigradients

More than 100 developers contributed to create¬†uigradients.com, it’s a handpicked collection of beautiful colour gradients for design and code. You can even add your own gradient¬†from a single¬†gradients.json file.

Once you choose a gradient you like you can get the CSS code

Play with color hereuigradients.com

WAIT! Animate

wait-animate

One more great animate tool that is generating CSS  for your icons. It is based on the great Font Awesome Animation library by Louis LIN

With WAIT! Animate you can repeat animations indefinitely with a custom pause between each repetition. It’s truly a unique CSS code generator, and it offers a viable way to build animated effects without writing code from scratch.

WAIT! Animate

Color CSS Gradient Background Generator

colorful-css-gradient-background-generator

This Color CSS Gradient Background Generator makes it easy to create complex backgrounds gradients using CSS. Forget about simple two color gradients, and instead create gradients with up to four different layers!

Color CSS Gradient Background Generator

 

the-ultimate-css-generator

It generates most commonly used CSS codes , like animation, backgrounds, layouts transitions and much more. A really useful tool to create a quick page stylesheet

 

CSS GRADIENT ANIMATOR

css-gradient-animator

The CSS Gradient Animator created by a wed designer and developer¬†Ian Forrest¬†. The Gradient Animator is a CSS generator used to create animated backgrounds, with the option to export as a GitHub gist and the inspiration came from the MailChimp’s¬†Email Design Guide.

CSS Gradient Animator

 

CSS3 Factory

css-gradient-generator

Currently it under development but it looks promising. Right now you will find only the CSS Gradient Generator.

CSS3 Factory

How to Center in CSS

how-to-center-in-css

How to Center in CSS makes it super easy to generate the code you need to center your content according to parameters you set. It provides many options to center the content type, div or text. It calculates the container size, width and height and a big plus it is providing CSS code for the minimum version of Internet Explorer. You can also generate code to align the content horizontally and vertical

How to Center in CSS

 

There are a lot more CSS generators if you know any other cool CSS generators feel free to share in the comments below.

 

Categories
WordPress WordPress beginner

How to embed videos to your WordPress Site

With video, there are so menu thing that you can explain to your visitors. You can upload your videos on Youtube, Vimeo, depending on your preference and how long your video is.

You should never upload videos to your WordPress site. But this will be analysed in another article. In this article I explain how to use the  standard method, embedding to place videos in WordPress

Once you create an account, upload a video to Youtube or Vimeo sites, let’s see how to embed it into your WordPress page or post

 

Simply paste the link URL

WordPress now supports oEmbed to make embedding videos into your blog post even easier. oEmbed is a format which allows URLs to point to embedded content automatically. It will take a standard link, extract media from it, and embed it on a webpage. This has been integrated into WordPress fully for several versions.

All you need is to copy the video link URL from the browser, place its URL into the content area. Switch to “Text” tab before pasting the Youtube URL.

Your post editor will render a preview of the video. That way, you can see what it looks like without having to preview the post.

Let me know if you have any questions.

Categories
WordPress

Best WordPress themes for blogs [September 2016]

Upon its inception, WordPress was a blogging platform. Though it has grown to be so much more than that, it is still the best option for personal or professional bloggers anywhere in the world.

That said, if you‚Äôre looking to start the next “Hello Giggles”, you will want a theme that makes content king. These four¬†themes put the focus on your writing and gets rid of the distraction. Three of them are free and three are premium so a blogger at any level can get involved.

Clean Magazine

clean-magazine

As the name suggest, Clean Magazine is a Clean and Responsive WordPress Theme, designed and developed for Magazine and Blog Websites. It is based on Catch Base theme which uses HTML5, CSS3 and Responsive design where each element has been carefully configured for perfect display on all devices and platforms.

Download Clean Magazine

Gillie

This theme from WPMUDEV is a great option if you want to showcase your writing and your art or photos at the same time. Panino offers a great way to combine many different mediums in one seamless design.

The theme is free and completely customizable. Galleries look stunning next to the simple typography. Everything is drag and drop so users of all backgrounds will be able to make the most of it.
blog-gillie-2016-09-11-19-01-54

Download Gillie

 

CleanBlog

clean

CleanBlog theme is designed for all kind of blogs such as personal blog, simple magazine, diaries or any other blogging website.CleanBlog theme is clean, latest design, easy to customizable, SEO friendly, bootstrap based fully responsive for any devices and it has powerful custom widgets and customizer theme options.

Download CleanBlog

 

 Moon

Moon is a Clean Responsive Magazine and Blog Theme beautifully designed especially for storytellers.

Download Moon 

 

What theme are you using on your site?

Categories
WordPress

How can We Increase Maximum File Upload Size In WordPress

WordPress is growing blogging platform, every day many peoples join WordPress or create a self-hosted WordPress blog. In this tutorial I am going to cover that How can We Increase Maximum File Upload Size In WordPress, You just have to follow the simple steps to Increase Maximum File Upload Size for your blog. I will discuss different ways but you just have to apply only one, not all.

Theme Functions File

There are cases where we have seen that just by adding the following code in the theme function’s file, you can increase the upload size:
view source print?

@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );

2. Create or Edit an existing PHP.INI file

In most cases, if you are on a shared host, you will not see a php.ini file in your directory. If you do not see one, then create a file called php.ini and upload it in the root folder. In that file add the following code:

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300

This method is reported to work for many users. Remember if 64 doesn’t work. Try 10MB (sometimes that work).

3. htaccess Method

Some people have tried using the .htaccess method by modifying the .htaccess file in the root directory, you can increase the maximum upload size in WordPress. Open or create the .htaccess file in the root folder and add the following code:

php_value upload_max_filesize 64M 

php_value post_max_size 64M 

php_value max_execution_time 300 

php_value max_input_time 300

Again, it is important that we emphasize that if you are on a shared hosting package, then these techniques may not work. In that case, you would have to contact your web hosting provider to increase the limit for you. Some hosts completely turn down their users. We recommend that you use HostGator. Their support folks are very helpful in these situations.

Categories
WordPress

How to Fix the 500 internal server error on WordPress

The 500 Internal Server error it is most common and general error, that will be shown when there’s a problem with the server or with the WordPress file system. It is the most unhelpful and nondescript bane of web developers everywhere. It’s a catchall error message that can literally mean anything.

500-Internal-Server-Error-PHP

Let’s have a look how to troubleshoot¬†this error.

Backup your site

I am highly recommending to backup your site before proceeding this troubleshooting.  To find the core of the issue we will make changes in the root directory of the site. So if something will go wrong, you can always restore it.

 

Deactivate all your plugins

If you have access to your site from the back end, go to Plugins > All Plugins. Select all your plugins, choose “Deactivate” from Bulk Options and Apply changes.

Plugins Deactivate

Check if the 500 Internal Server error is gone from the front page. If it is gone, activate one plugin at the time to find out which one is causing this error.

If you don’t have access to the backend¬†of your site, use FTP client of File Manager on your cPanel to access WordPress directory files.

Using FTP client

If you are already familiar with the FTP client, please skip this section.

If you are a PC user, please download FileZilla FTP Client from here.

For Mac Users try:

1.  Cyberduck; free FTP software designed for Macs
2.¬† Transmit ‚Äď FTP software you purchase designed for Macs

Once you install FileZilla, use your domain name, username and password to access your host’s file manager.

And you are ready to go!

Access your site from the cPanel

First, log into cPanel. In the Files section, click on the File Manager icon.

cPanel > File ManagerClick to expand the public_html folder, nad you will see your WordPress site directory root.

 

Deactivate your plugins manually

Navigate to the /wp-content/plugins folder and rename the plugins folder to plugins.deactivate. All the plugins will be deactivated after this.

Check your front end if it is working, if it is working, if it is, rename back the plugins.deactivate to plugins. Open the plugins folder and start renaming each plugin folder one by one till the error disappears from your site. This will allow you to reactivate each plugin individually to isolate the offending plugin and resolve the 500 Internal Server Error.

 

Check the .htaccess file

Open your WordPress root directory in FileZilla or your preferred FTP client. This is typically called public_html. Locate the .htaccess file, download it to your computer to have a backup and delete it from your directory. Try to load your site again, if your site is back, congratulations!

Now, go into your WordPress admin area. Hover over Settings, and select Permalinks. Scroll down to the bottom of the page, and click Save Changes.

 

Increase your PHP Memory Limit

Sometimes this error can happen if you are exhausting your PHP memory limit.  To solve this issue, edit the wp-config.php file that is located in your WordPress directory, along with wp-admin and wp-include folders.

First, check if you have already the following code added:

define('WP_MEMORY_LIMIT', '64M');

if it already there changed the 64M to 256, if it is not, place the following line inside the file:

define('WP_MEMORY_LIMIT', '256M');

Save the file, and re-upload it to your root directory, overwriting the original file. Refresh the client, and refresh your site. If you still see the error, you are not having PHP memory limit issues. Remove the above code from the wp-config.php file on your computer, save it, and re-upload it to your root directory.

 

Ask your Hosting Provider

If nothing works, then you need to get in touch with your hosting provider. By looking at the server logs, they should be able to get to the bottom of things.

Categories
WordPress

How to resize images in WordPress

WordPress by default compresses and optimizes images for web-use. Usually, the max width and height in WordPress Media settings do not exceed 1024 px. What happens if the dimensions are greater than 1024px?

After testing for page speed with PageSpeed Insights, recommendation to re-size the website’s images.

This could affect the site’s page ranking in Google, especially when you are¬†you running a multi-author site.¬†It’s¬†difficult to monitor images uploaded by other users.

Also, large image files may be slowing down your site without you even knowing it.

 

To scale the image dimensions, you can try the following plugins

 

Imsanity

Imsanity

The plugin automatically scales the images upon upload. You can bulk resize images or select to resize one image at the time.

 

smush

WP Smush

My personal choice, it’s the WP Smush plugin. Bulk re-sizing and¬†optimizing images. Saved my ass and my time several times (sorry for the language ūüėČ ). The best part is that WPMU DEV server doing all the job, it’s resizing and optimizing images on.

This plugin can automatically resize images upon upload, or bulk resize all the images in the media library.

You can try the WP Smush Pro, it’s even better.

 

What plugins are you using on your site to re-size images?