da Ragnar Lodbrock mancano 7 anni
2128
Più simili a questo
arguments for The loop
$arg = array(...);
$user_full_name = "Rollo Lothbrock";
usefull only when you writing your custom code
Filters
add_filter()
Let you modify existing content in WordPress
limit the number of post characters displayed
add custom footer to the bottom of a post
Actions
add_action( 'after_setup_theme', 'tweentyfevteen_theme' );
Your custom code that run when some specific action is takingl place
run some code when
whene menu is loaded
post is saved
inside every theme there are specific functions for the theme
Custom functions
Custom Loops
WP_Query
$query = new WP_Query( $args );
$args = ( array { 'post_type' => 'post', 'order' => 'DES' })
"list of specification for the WP_Query"
dispaly a list of links to your posts on a custom page
Enables you to writes loop that do anything you want on a custom pages
all the code inside
+ simple loop
IF (There are post) WHILE (There are posts) ECHO post title ECHO post content ELSE ECHO "Sorry no post yet..."
get_template_part( 'content', none )
displays "No post published yet" part of a template
get_header()
pre-made functions to use in WordPress themes
Coding standards
HTML makup with PHP
rather outside the blocks
one php block for a file
you don't need to close this block
server will do this for you
exclusivly writen php
types of PHP files in WP
plugin files
inside wp-content/plugins
PHP (HTML+CSS+JS)
theme files
dont make changes directly in theme folder
make an chlid-theme folder instead
inside wp-content/themes
HTML + PHP
core files
all WP files besides wp-content folder
only PHP
normal method
short method
it can be closed at the end of the file
then with WHILE loop over it to display content on the website
to get header and footer
footer.php
dynamic copyright year
all the footer code
header.php
instead of all links to css, and scripts
all from to
including js files in the template
?>
add_action( 'wp_enqueue_scripts', 'name_theme_js' );
function name_theme_js() {
wp_enqueue_script( 'name_js', get_template_directory_uri() . 'path.js', 'dependency(array(''))', 'version', do we wanna this in the footer(true/false) );
wp_enqueue_script( 'modernizr_js', get_template_directory_uri() . '/js/modernizr.js', '', '', false );
wp_enqueue_script( 'foundation_js', get_template_directory_uri() . '/js/foundation.js', 'array('jQuery')', '', true );
WordPress already has jQuery
to run jQuery code with $ sign
jQuery(document).ready(function($) { $code goeas here });
wrap it into noConflict wrapper
including css in the template
add_action( 'wp_enqueue_scripts' , 'name_theme_styles' );
function name_theme_styles() {
wp_enqueue_style( 'name_css', get_template_directory_uri() . 'path.css' );
}
ex.
wp_enqueue_style( 'foundation_css', get_template_directory_uri() . '/css/foundation.css' );
wp_enqueue_style( 'font_css', 'http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic' );
include metainformations of a template