WordPress Core Contributor, WordPress Kaunas Meetup co-organizer, WordCamp, WordSesh, TEDx speaker and one of the editors of the Lithuanian WordPress translation team.
Free, premium and custom WordPress plugin developer
Engineering Team Lead at
Puikus įskiepis, sukurtas
John Blackbourn
Privalomas bet kuriam WordPress developeriui
/*
Theme Name: WordPress Theme101
Theme URI: https://arunas.co/
Description: A hello world theme
Author: Arūnas Liuiza
Version: 0.1
*/
<?php get_header(); ?>
<?php get_footer(); ?>
<!DOCTYPE html>
<html>
<head>
<title>WordPress Theme101</title>
<meta charset="UTF-8" />
<link
href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css"
rel="stylesheet"
/>
</head>
<body>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
</body>
</html>
<?php wp_footer(); ?>
</body>
</html>
Universali funkcija - get_template_part()
<?php get_header(); ?>
<?php get_template_part( 'part', 'hero' ); ?>
<?php get_template_part( 'part', 'cta' ); ?>
<?php get_template_part( 'part', 'footer' ); ?>
<?php get_footer(); ?>
Pradžia
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
Turinio bloko HTML
Pabaiga
<?php endwhile; endif; ?>
<?php get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php get_footer(); ?>
page-apie.php // slug=apie
page-15.php // ID=15
page.php // visiems puslapiams
index.php // bendras
category-sportas.php
category-15.php
category.php
archive.php
index.php
post-thumbnails (featured image)
post-formats (image/quote/video/aside/kt...)
automatic-feed-links (RSS)
title-tag (vietoj <title>)
// functions.php
// add_image_size( $name, $width, $height, $crop );
add_image_size( 'temos-didelis', 800, 600, true );
// loop.php
the_post_thumbnail( 'temos-didelis' );
// style.css - theme headeryje
Text Domain: temos-katalogas
// visur kitur
__( 'Translatable text', 'temos-katalogas' );
_e( 'Translatable text', 'temos-katalogas' );
add_action( 'wp_enqueue_scripts', 'theme101_assets' );
function theme101_assets() {
wp_register_style(
'theme-style',
'https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css'
);
wp_enqueue_style( 'theme-style' );
}
// functions.php
add_shortcode( 'vardas', 'vardas_shortcode' );
function vardas_shortcode( $args, $content ) {
return 'Petras';
}
// įrašo/puslapio tekste
[vardas]
// functions.php
add_shortcode( 'kitas', 'kitas_shortcode' );
function kitas_shortcode( $args, $content ) {
$defaults = array(
'title' => __( 'Some Title', 'temos-katalogas' ),
'description' => '',
);
$args = wp_parse_args( $args, $defaults );
$result = "<strong>{$args['title']}</strong>";
if ( $args['description'] ) {
$result .= "- <em>{$args['description']}</em>";
}
if ( $content ) {
$result .= '<br />' . do_shortcode( $content );
}
return $result;
}
// įrašo/puslapio tekste
[kitas title="Vardas" description="kardas"]tekstas[/kitas]
// functions.php
register_nav_menu( 'header-menu', 'Header Menu' );
// header.php
$args = array(
'theme_location' => 'header-menu',
'container' => 'nav',
'container_class' => 'my-menu-class',
);
wp_nav_menu( $args );
// Custom walker
// https://gist.github.com/kosinix/5544535
// loop-main.php
echo get_post_meta( get_the_id(), 'field_name, true );
<?php
// The Query
$query1 = new WP_Query( $args );
// The Loop
while ( $query1->have_posts() ) {
$query1->the_post();
echo '<li>' . get_the_title() . '</li>';
}
wp_reset_postdata();