Wordpress Custom Themes

From KOP KB
Revision as of 18:31, 17 January 2017 by ReMaster (talk | contribs) (Admin Color Scheme)
Jump to: navigation, search

Intro

Basically some simple info about making and starting to create your own Wordpress template.

Basic Requirements

The files that you can use with a Wordpress Template that are integrated are listed here: https://codex.wordpress.org/Theme_Development

The ones that are absolutely required for wordpress admin panel to recognize it is below:

style.css index.php

This is a very basic one and if you feel like you need more functionality you can look through the link above.

Functions and Styles

Now there is definitely other ways to do these things but this is the way I managed.

Simple Header Image

Basically just adding a header image option for the top of each page. Lets you set the height and width was well where the default image gets set. This code would be within the functions.php file within your Theme folder. Pretty much the function is all the dirty work and the them support part says start it up.

function register_my_menu() {
  register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_my_menu' );
$args = array(
	'width'         => 960,
	'height'        => 198,
	'default-image' => get_template_directory_uri() . '/images/header.jpg'
);
add_theme_support( 'custom-header', $args );

Login Page

Login related functions and edits

Locking it Down

Pretty much only time you really want login errors to show is when your testing something out, otherwise wordpress lets on too much. This command in the functions.php hides them. You can use css to hide it completely or just null the message and still have the red bar show up.

add_filter('login_errors',create_function('$a', "return null;"));

Basically this is a set of three things needed to do:
- Set the style so it switches out the wordpress logo for your own
- Set the link of the image to go back to your homepage
- Set the Text that shows up when hovering to show your brand

function my_login_logo() { ?>
    <style type="text/css">
        .login h1 a {
            background-image: url(https://www.ragtagbunch.ca/logosmall.png);
            padding-bottom: 30px;
        }
       
    </style>
<?php }
add_action( 'login_enqueue_scripts', 'my_login_logo' );

function my_login_logo_url() {
    return home_url();
}
add_filter( 'login_headerurl', 'my_login_logo_url' );

function my_login_logo_url_title() {
    return 'RagTagBunch';
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );

Admin Color Scheme

Getting Started

function additional_admin_color_schemes() {
    //Get the theme directory
    $theme_dir = get_template_directory_uri();
 
    //Ocean
    wp_admin_css_color( 'RagTagBunch', __( 'RagTagBunch' ),
        $theme_dir . '/admin-colors/ocean/colors.min.css',
        array( '#222', '#333', '#444', '#888' )
    );
}
add_action('admin_init', 'additional_admin_color_schemes');

Admin Menu Bar