General Function used in wordpress
<?php
is_front_page(); // front page
is_home(); // home page
get_template_directory(); //
get_template_directory_uri(); // access absolute path
get_post_type_archive_link('post_type'); // this will take you back to whatever post type you want to link back
?>
\!h // Tell web browsers what language the site is using.
<head <?php language_attributes(); ?>
\!h // Tell browser what character to use on the web page
<meta charset="<?php bloginfo( 'charset' )?>">
\!h // Tell web browsers and devices to just to be true to themselves and ise their own native device size or device width
<meta name="viewport" content="width=device-width", initial-scale=1>
\!h // Tell web browsers what language the site is using.
<head <?php language_attributes(); ?>
\!h // Print out body class for current screen viewing
<body <?php body_class(); ?>
\!h // WordPress - Icons
https://developer.wordpress.org/resource/dashicons/#palmtree
\!h // Hand Craft Excert
if (has_excerpt()) {
echo get_the_excerpt();
} else {
echo wp_trim_words(get_the_content(), 18);
}
\!h //display title - General Settings, Site Title
<?= bloginfo( 'title' ); ?>
\!h // display description - General Settings, Tagline
<p class="lead"><?php bloginfo('description'); ?></php>
\!h // Site title
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
\!h //
<?php $description = get_bloginfo( 'description', 'display' ); ?>
<?php if ( $description || is_customize_preview() ) : ?>
<p class="site-description"><?php echo $description; /* WPCS: xss ok. */ ?></p>
<?php endif; ?>
\!h //
<link href="<?php bloginfo('stylesheet_directory');?>/assets/css/bootstrap.min.css" rel="stylesheet">
<script src="<?php bloginfo('template_directory'); ?>/assets/js/jquery-2.1.1.min.js"></script>
\!h //
<?php bloginfo('stylesheet_directory'); ?>
// These 2 functions are the same!
<?php bloginfo('template_directory'); ?>
\!h // Add margin to admin menu when logged in. This will allows us to be able to see our navigation properly
.logged-in .navbar-fixed-top {
top: 32px;
}
\!h // Display custom post
<?php while ($loop->have_posts() ) : $loop->the_post(); ?>
<?php
if( has_post_thumbnail() )
{
the_post_thumbnail( array(200,200) );
}
?>
<?= the_title() ?>
<?= the_content() ?>
<?php endwhile; ?>
\!h // function-admin.php
// Create a Custom Admin Page - Custom Menu in The Admin Bar
function sunset_add_admin_page(){
// add_menu_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '', string $icon_url = '', int $position = null )
// Generate Sunset Admin Page
add_menu_page( 'Sunset Theme Options', 'Sunset', 'manage_options', 'joe_sunset', 'sunset_theme_create_page', get_template_directory_uri() . '/img/sunset-icon.png', 110 );
// Generate Sunset Admin Sub Menu
add_submenu_page( 'joe_sunset', 'Sunset Theme Options', 'General', 'manage_options', 'joe_sunset', 'sunset_theme_create_page' );
add_submenu_page( 'joe_sunset', 'Sunset CSS Options', 'Custom CSS', 'manage_options', 'joe_sunset', 'sunset_theme_settings_page' );
// Activate Custom Settings
// Bu putting this action inside the function is for a safety precauution because puttin the
// action inside the function of the generation of the menu prevents the system to generate a custom settings to call the function to generate a custom settings if you're not actually creating the page.
add_action( 'admin_init', 'sunset_custom_settings' );
}
add_action( 'admin_menu', 'sunset_add_admin_page');
function sunset_custom_settings () {
}
function sunset_theme_create_page () {
// Create an admin Sunset admin page and include it in here.
require_once( get_template_directory() . '/inc/templates/sunset-admin.php' );
}
function sunset_theme_settings_page () {
}