Categories
Wordpress

Simple way to create a custom layout in wordpress theme

I was always thinking how some people create completely different looking pages on their WordPress theme. Currently we see that from an static page to ecommerce site is developed using WordPress package. Many sites has different layout for different pages. WordPress provide a simple solution to create custom layout for our website built on wordpress. A custom layout of wordpress page is helpful if we want to have a layout that looks completely different than rest of our blog but still executes on WordPress CMS.

In this tutorial I will try to describe you how we can create a custom page in WordPress using the custom page template snippet.

Lets create a custom page by opening a blank file in an editor. In the very beggining of the page paste the following code:

<?php /* Template Name: MyCustomLayout1 */ ?>

For example:

<?php /* Template Name: Alternative Home Design */ ?>

Lets save the page as: custom_layout_1.php. The above code is simply giving a name to the template. so we can call our template MyCustomLayout1, but you can call it whatever you like for example: archive,

Share with:

Categories
Wordpress

Protect wordPress special files from direct access

Block access to backup and source files. The below script in .htaccess tells the server to look for files with any of this extensions: [filename].config, [filename].sql, [filename].bak and so on, and if so, deny processing requests for such files.It will return a 403 Forbidden error instead.

<FilesMatch "(\.(config|sql|bak|ini|log|sh|inc)|~)$">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>

For extra security we should block access to the WordPress readme.html file and other default WordPress files which publicly display your current WordPress version number. Rather than deleting these files, it’s better to add the following directive to our .htaccess file to block public access to these files.
[manage_adv width=”486″ height=”60″ sponsor=”affiliate” type=”image”]

<FilesMatch "^(wp-config\.php|readme\.html|readme\.txt|license\.txt)">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>

Share with:

Categories
Wordpress

Lets start with the ultimate guide to wordPress multisite part -4

Previous three articles of this series:

Managing Your Network: Updates, Users and Settings

As well as managing the individual sites in your network, you’ll need to manage the network itself. This will include:

  • Updating WordPress
  • Updating themes and plugins
  • Managing users
  • Customizing the settings.

Let’s take a look at each of these in turn.

Updating WordPress

Updating themes, plugins and WordPress itself via the network admin screens is straightforward: you’ll see a notification if any of your code needs updating and you simply update it in the same way as you would for a normal site. Updating WordPress is a two step process: you need to install the update and then update the network of sites. This is just a case of clicking a couple of extra links which WordPress will guide you through.

Users

The Users screen works in the same way as for a standard WordPress site: it will list all of the users on your network and let you edit and delete them. This will include users that site admins have added to your site as well as users who’ve signed up for a site.

The one main difference is that the Users screen tells you which sites a user has access to. If you want to add a user to a site, you do so via the Users tab in the site settings.

multisite-network-admin-users

 

Settings

You use the Network Settings screen to customise the way your network is used:

multisite-network-settings

Settings you can customise are:

  • The title of your network
  • The network admin’s email address
  • Registration settings: whether users can register accounts and/or sites, whether site admins can add new users, and email domains and site names which are banned.
  • New site settings: the content of the welcome email for site admins and users and the first page, post and comment created on new sites.
  • Upload settings: file types permitted and maximum file size
  • Language settings: the default language
  • Menu settings: enable or disable the plugins menu item for site admins. If you disable this they won’t be able to activate or deactivate plugins.

 Managing and Maintaining a Huge Network of Sites

Share with:

Categories
Wordpress

Lets start with the ultimate guide to wordPress multisite part -3

Previous two articles of this series:

Installing and Activating Themes

Only the super administrator of a network can install themes and make them available for sites to use. You can do this in one of two ways: you can allow them for individual sites or you can network activate them. A theme can only be activated on a site if it’s been network enabled or enabled for that site.

Here’s how you install a theme and network enable it:

  • In the Network admin screens, go to Themes > Add New and install the theme in the same way as you would for a standard WordPress site.
  • On the ‘Installing Theme’ screen that appears, click the Network Enable link.

Alternatively, to network enable a theme you’ve already installed, click on Themes to go to the Themes screen, then click the Network Enable link below a theme.

[manage_adv size=”responsive” sponsor=”amazon” type=”image”]

You can also enable a theme just for one site. This can be useful if your network runs lots of sites each of which will need a different theme, for example if you’re hosting client sites. Enabling themes by site means that other themes won’t be available to sites which don’t have them enabled, so there’s no risk of site admins accidentally activating the wrong theme.

To do this, follow these steps:

  • In the Network admin, click on Sites to view all of your sites.
  • Hover over the name of the site you want to enable the theme for and click the Edit link that appears.
  • Click the Themes tab to view the themes settings screen for the site:multisite-enable-theme-for-site
  • Under the theme you want to enable, click the Enable link.

Now when you go to the site administration screens for that site and click on Appearance > Themes, you’ll see the theme you’ve enabled included in the available themes for activation:

multisite-site-themes-screen

Installing and Activating Plugins

Plugins also have to be installed by the network administrator, but they work slightly differently with regard to the sites on the network. You can’t enable a plugin for an individual site: instead you can network activate it, so it runs on every site on the network, or you can just install it, so that individual sites can choose to activate it.

Network activating plugins is useful if you’ve written or downloaded a plugin to provide features which you want all of your sites to have, for example on my network of client sites I’ve installed the Snapshot plugin to ensure that all of the sites are backed up regularly. Here’s how to install and network activate a plugin:

  • In the network admin screens, got to Plugins > Add New and install the plugin as you would in a normal WordPress site.
  • In the Installing Plugin screen, click the Network Activate link.

That’s it! The plugin will now run on all the sites in your network and site admins won’t be able to disable it.

But what if you want to just activate the plugin on one site? That’s done by installing the plugin as a network admin and then activating the plugin if you have site admin privileges for the site.

  • In the network admin screens, got to Plugins > Add New and install the plugin as you would in a normal WordPress site.
  • In the Installing Plugin screen, click the Return to Plugin Installer link.
  • Visit the site admin screens for the site you want to activate the plugin for and click the Plugins link in the admin menu.
  • Under the plugin you want to activate, click the Activate link as you would in a normal WordPress site.

You’ll notice that in the Plugins screen for a site admin, there’s only the option to activate or deactivate plugins, not to delete or update them:

Share with:

Categories
Wordpress

Lets start with the ultimate guide to wordPress multisite

In this article I’m going to show you everything you need to know to get started with Multisite and create your own network of blogs or sites.

I’ll cover:

  • What is Multisite and how is it different from regular WordPress?
  • Uses for Multisite (with some examples)
  • When not to use Multisite
  • How to activate Multisite on a new or existing WordPress installation
  • Creating blogs in your network
  • Managing your network, including installing themes and plugins, creating sites and setting up domain mapping
  • Plugins to make Multisite even better.

But first, let’s get some terminology straight. In this post I’m going to use the word network and site to refer to two different things:

  • Network refers to the entire Multisite network, i.e. your WordPress installation
  • Site refers to one of the blogs or sites created as part of the network.

So when I refer to your site, I don’t mean your whole network of sites, but just one of the sites on it. Each network will have a main site, which is created when you install WordPress and which will probably use the main domain for your WordPress installation: that’s still a site. I’ll explain this in more detail as we go along.

So now we’ve got that sorted, let’s take a look at Multisite!

What is Multisite?

The Codex defines WordPress Multisite as:

A feature of WordPress 3.0 and later versions that allows multiple virtual sites to share a single WordPress installation.

This means that by installing WordPress just once on your server, you can run as many sites as you want, and I really mean as many as you want. At the time of writing, WordPress.com hosts approximately 37 million sites, and our own Edublogs.org hosts nearly 3 million educational sites. You won’t be able to host millions of sites on a standard Multisite installation though – later in this post I’ll cover some plugins and techniques you can use to host large numbers of sites.

Share with:

Categories
Wordpress

Lets start with the ultimate guide to wordPress multisite part -2

This is second article of Lets start with the ultimate guide to wordPress multisite. You should read the first article to start from the beginning of the ultimate guide to wordPress multisite.

Activating Multisite on a Fresh WordPress Installation

Activating Multisite when you install WordPress involves a few extra steps. Firstly, you need to install WordPress and allowing a network.

  • Install WordPress in the normal way. Download WordPress and use the ‘famous 5 minute install’ to install it on your server or local machine.
  • Open your wp-config.php file which you’ll find in the folder where you installed WordPress. Find the line that reads: /* That’s all, stop editing! Happy blogging. */
  • Immediately above that line, create a new line that reads as follows:define( ‘WP_ALLOW_MULTISITE’, true );
  • Now save your wp-config.php file.

[manage_adv size=”responsive” sponsor=”amazon” type=”image”]

The next step is to visit the WordPress admin screens and install Multisite.

  • In the WordPress admin, go to Tools >Network Setup. You’ll be prompted to choose subdomains or subdirectories for your installation: choose the one that works for your network.
  • Edit the title of your network and email address of the network administrator when prompted, or leave them as they are.
  • Click the Install button.

The final step is to copy some code provided by WordPress into your wp-config.php and .htaccess files.

  • You will be taken to the Network Install screen:
    installing-wordpress-multisite-network
  • Open each of your wp-config.php and .htaccess files and edit them in line with the text provided on the screen. If you can’t find .htaccess on your server, it may because hidden files aren’t visible: change the settings in your code editor if you’re using one to access your files.
  • Save both files.

WordPress Multisite will now be installed. You’ll need to log in again, and when you do so you’ll see the dashboard:

Share with:

Categories
Wordpress

Add author bio with social links to blog post

Often we like to add a author bio at the bottom of blog post. To do so we use external plugins. By adding few script to our theme function file we can easily create our own custom author bio for our blog post. Lets see what type of field we need to get user/author social links:

author links field screenshot

What we need to add in function file:

<?php
if ( is_admin() ) {
    add_filter('user_contactmethods', 'author_bio_social_links');

    function author_bio_social_links( $data ){
        $data['author_twitter_url'] = __( 'Twitter', 'msbd-theme' );
        $data['author_facebook_url'] = __( 'Facebook', 'msbd-theme' );
        $data['author_github_url'] = __( 'Github', 'msbd-theme' );
        $data['author_wp_url'] = __( 'Wordpress', 'msbd-theme' );

        return $data;
    }
}
?>

[manage_adv size=”responsive” sponsor=”amazon” type=”image”]

Now we will show the author bio with the social links we have added to admin section:

Share with:

Categories
Wordpress

Get the authors list who submitted highest number of posts in wordpress

Now a days the use of wordpress content management system is not limited to a blog or a portfolio website, it is also used as a eCommerce website platform. No matter how we use it, we often need the highest post submitted author list. Using below script you can get the list of authors who submitted highest number of posts in WordPress.

<?php
    function top_authors_list($number = 10) {
        $html = '';
        $uc = array();
        $blogusers = get_users();

        if ($blogusers) {
            $html .= '<ul>';
            foreach ($blogusers as $bloguser) {
                $post_count = count_user_posts($bloguser->ID);
                $uc[$bloguser->ID] = $post_count;
            }
            arsort($uc);

            $i = 0;
            foreach ($uc as $key => $value) {
                $i++;
                if ($i <= $number) {
                    $user = get_userdata($key);
                    $author_posts_url = get_author_posts_url($key);
                    $post_count = $value;
                    if ($post_count > 0) {
                        $html .= '<li><a href="' . $author_posts_url .'">' . $user->display_name . '</a> (' . $post_count . ')</li>';
                    }
                }
            }
            $html .= '</ul>';
        }

        return $html;
    }
?>

 

 

Share with: