třída pro aktuální stránku
.page-activetřída pro aktuální článek
.current-post-parentúprava vyhledávání (sidebar)
app/public/wp-includes/theme-compat/sidebar.php
získání hlavičky stránky
soubor se musí jmenovat
header.phpa musí být v rootu šablony (template)
get_header()napojení na WP pomocí hlavičky <head>
wp_head()zobrazení WP menu
- musí se definovat přímo ve WP
wp_nav_menu(
array(
'menu' => 'primary',
'container' => '',
'theme_location' => 'primary',
)
);získání PHP obsahu
get_template_part('template-parts/contact/contact', 'index')získání patičky stránky
soubor se musí jmenovat
footer.phpa musí být v rootu šablony (template)
get_footer()zobrazí se pokud se nacházím na hlavní stránce
if (is_home()) {
}zobrazí se pokud se nacházím v kategorii
if (is_category()) {
}zobrazí se pokud se nacházím na dané stránce
if (is_page('kontakt', 'domu')) {
}zobrazení shortoce podle jednotlivých obsahů
- k obahům se dostávám pomocí indexace
$content[]
$var = get_the_content();
$content = explode('<!-- wp:shortcode /-->', $var);
echo do_shortcode($content[0]);zobrazení tagů
$post_tags = get_the_tags();
if ($post_tags) {
echo $post_tags[0]->name, $post_tags[1]->name;
}titulek článkuu
the_title()popis článku
get_content()výňatek článku
the_excerpt()obrázek článku
the_post_thumbnail()název kategorie
single_cat_title()název kategorie s odkazem <a href="">
the_category()popis kategorie
kategorie nemá výňatek (excerpt), ale popis (description)
echo category_description()odkaz na upravení článku
vidí pouze přihlášený
edit_post_link('upravit')čas a autor článku
the_time('F jS, Y'); ?> by <?php the_author_posts_link()obsah vidící pouze admin
if (current_user_can('administrator')) {
}titulek (title) stránky
bloginfo('name')Tagline
bloginfo('description')<?php
// category loop
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php endwhile; else : ?>
<p><?php esc_html_e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?><?php
// CSS import
function tension_scripts() {
wp_enqueue_script( 'scripts', get_template_directory_uri() . '/assets/js/script.js', array(), '1.0.0' );
wp_enqueue_style( 'stylesheets', get_template_directory_uri() . '/assets/css/style.css', array(), '1.0.0' );
}
add_action( 'wp_enqueue_scripts', 'tension_scripts' );
// allow SVG pics
add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
global $wp_version;
if ( $wp_version !== '4.7.1' ) {
return $data;
}
$filetype = wp_check_filetype( $filename, $mimes );
return [
'ext' => $filetype['ext'],
'type' => $filetype['type'],
'proper_filename' => $data['proper_filename']
];
}, 10, 4 );
function cc_mime_types( $mimes ){
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );
// remove admin bar
add_filter('show_admin_bar', '__return_false');
// add menu types (to show in wp menu)
function snytbrno_menu(){
$locations = array(
'primary' => 'Top Menu',
'secondary' => 'Side Menu',
'footer' => 'Footer Menu'
);
register_nav_menus($locations);
?>složky
- template-files (page, frontpage, category)
- inc
- assets (css, js, img)
soubory
front-page.phppage.phpfuntions.phpcategory.phpsingle.phpsearch.php404.phpstyle.css
front-page.php
/**
* The main template file
*
* Template file for czech restaurant snyt-brno
*
* @link http://snytbrno.local/wp-content/themes/snyt-brno
*
* @package Wordpress
* @subpackage snyt-brno
* @since snyt-brno 1.0
*/
style.css
/*
Theme Name: Wordpress Talk
Theme URI: wordpresstalk.com
Author: wordpress talk company
Author URI: http://wordpresstalkcompany.com
Description: This is a place we can talk about wordpress stuff.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, brown, orange, tan, white
Text Domain: wordpress
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/