php 自己的WordPress钩子
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 自己的WordPress钩子相关的知识,希望对你有一定的参考价值。
// page tags
<?php get_header(); ?>
<?php get_footer(); ?>
<?php bloginfo('template_url'); ?>/
<?php /* Template Name: Index */ ?>
<?php get_template_part('partname'); ?>
<?php get_template_part('template-parts/content-post', get_post_type()); ?>
<?php wp_head(); ?>
<?php wp_footer(); ?>
// post gats
<?php the_title(); ?>
<?php the_permalink(); ?>
<?php the_content(); ?>
<?php the_excerpt(); ?>
<?php the_post_thumbnail('medium'); ?>
<?php the_time('d.m.Y') ?>
<?php the_author(); ?>
// bloginfo tags
<?php bloginfo('title'); ?>
<?php bloginfo('charset'); ?>
<?php bloginfo('description'); ?>
<?php bloginfo('home').'/' ?>
<?php body_class(); ?>
<?php language_attributes(); ?>
// fileds tags
<?php the_field('blog-logo'); ?>
<?php the_field('blog-logo', 9); ?>
<?php the_field('blog-logo', get_the_ID()); ?>
// loops tags
<?php while (have_posts()) { the_post(); ?>
<?php } ?>
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$oftenBuy = new WP_Query(array(
'numberposts' => 6,
'cat' => 15,
'orderby' => 'date',
'order' => 'ASC',
'paged' => $paged
));
if ($oftenBuy->have_posts()) { ?>
<?php while ($oftenBuy->have_posts()) { $oftenBuy->the_post(); ?>
<?php the_field('card-photo_1', get_the_ID()); ?>
<?php } ?>
<?php } else { ?>
<?php echo 'hello'; ?>
<?php } wp_reset_postdata(); ?>
<?php wp_nav_menu(array(
'menu' => 'header_menu',
'menu_id' => 'headerNav',
'menu_class' => 'nav',
'container' => '',
)); ?>
<?php wp_nav_menu(array(
'menu' => 'menu2',
'container' => '',
'items_wrap' => '%3$s'
)); ?>
<?php $phone = get_field('blog-phone', 9); ?>
<a href="tel:<?php echo str_replace(" ", "", $phoneBot);?>"><?php echo $phone; ?></a>
<?php $phones = get_field('blog-phones', 9);
if ($phones) {
foreach($phones as $phone) { ?>
<p><?php echo $phone['field']; ?></p>
<? }
}
?>
<?php $categories = get_categories(array(
'order' => 'DESC',
'child_of' => 0,
'hide_empty' => 0,
'pad_counts' => 1,
'hierarchical' => true,
'exclude' => [1, 3]
));
if($categories) {
foreach($categories as $cat) {
if ($cat->parent == 0) { ?>
<li>
<a href="<?php echo bloginfo('home').'/'.$cat->slug; ?>" class="category">
<span class="category_icon"><img src="<?php the_field('cat_icon', 'category_' . $cat->term_id); ?>?20022017" alt=""></span>
<span class="category_name"><?php echo $cat->name; ?></span>
<span class="category_posts"><?php echo $cat->count; ?></span>
</a>
</li>
<?php }}
} ?>
以上是关于php 自己的WordPress钩子的主要内容,如果未能解决你的问题,请参考以下文章