add_ahortcode('shortcode_name','my_shortcode_function');
function my_shortcode_function($attr) {
ob_start();
$parametri = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts' => 1
);
$moi_zapros = null;
$moi_zapros = new WP_Query($parametri);
if ($moi_zapros->have_posts()):
print '<ol>';
while ($moi_zapros->have_posts()) : $moi_zapros->the_post();
$idt=get_the_ID();
$trip=get_post_meta($idt,"trip", true);?>
<li class="map"><a href="<?php the_permalink() ?>" title="Постоянный линк для:<?php the_title_attribute(); ?>" target="_blank"><?php the_title(); if ($trip) {echo " ", $trip, ". День ",get_post_meta($idt,"day", true), ". ";}?> (<?php print get_comments_number();?>)</a></li>
<?php
endwhile;
print '</ol>';
endif;
wp_reset_query();
return ob_get_clean();
}
$args = array(
'posts_per_page' => -1,
'category' => $categoryId,
'orderby' =>'meta_value_num',
'order' => 'ASC',
'meta_key' => 'ORDER',
'post_type' => 'post',
);
$posts = get_posts($args);
<?php $query = new WP_Query(array (
//параметры WP_Query в масиве
//post_type - название кастомной записи
'posts_per_page' => -1,
'post_type' => 'gallary',
'order' => 'ASC', //ASC c больших букв
));
$post_in_page = array_chunk($query->posts,6);
?>
<?php if ($query->have_posts()) : ?>
<div class="slick-1">
<?php foreach ($post_in_page as $_posts) : ?>
<div>
<?php foreach($_posts as $pst): ?>
<a href="<?php echo get_the_post_thumbnail_url($pst); ?>">
<img src="<?php echo get_the_post_thumbnail_url($pst); ?>" alt="">
</a>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
id="row-kkk"
$(document).ready(function(){
$("#top-nav").on("click","a", function (event) {
//отменяем стандартную обработку нажатия по ссылке
event.preventDefault();
//забираем идентификатор бока с атрибута href
var id = $(this).attr('href'),
//узнаем высоту от начала страницы до блока на который ссылается якорь
top = $(id).offset().top;
//анимируем переход на расстояние - top за 1500 мс
$('body,html').animate({scrollTop: top}, 1500);
});
});
<div class="bags_slider product_slider">
<?php
query_posts('cat=2');
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<div class="product_item">
<div class="product_circle">
<?php echo get_the_post_thumbnail(); ?>
</div>
<div class="colors">
<div class="dark_grey"></div>
<div class="red"></div>
<div class="black"></div>
</div>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
</div>
#menu-navmenu ul li {
display: inline-block;
}
add_action('wp_head',function(){
?>
<style>
#menu-navmenu ul li {
display: inline-block;
}
</style>
<?php
});
.menu-navmenu-container
находится в корне вашей темы в файле main.css
functions.php
add_action('wp_enqueue_scripts', 'enqueue_bootstrap_scripts');
function enqueue_bootstrap_scripts(){
wp_enqueue_style('webfonts', get_stylesheet_directory_uri() . '/fonts/icons.css');
wp_enqueue_style('webfonts');
wp_enqueue_style('bootstrap-grid', get_stylesheet_directory_uri() . '/css/bootstrap-grid.css');
wp_enqueue_style('bootstrap-grid');
wp_enqueue_style('header-min', get_stylesheet_directory_uri() . '/css/header.min.css');
wp_enqueue_style('header-min');
wp_enqueue_style('animate', get_stylesheet_directory_uri() . '/css/animate.css');
wp_enqueue_style('animate');
wp_enqueue_style('main-min', get_stylesheet_directory_uri() . '/css/main.min.css');
wp_enqueue_style('main-min');
wp_enqueue_script('hydr-lib', get_stylesheet_directory_uri() . '/js/libs.js', array('jquery'), '', true);
wp_enqueue_script('hydr-common', get_stylesheet_directory_uri() . '/js/common.js', array('jquery'), '', true);
}
<?php
if (!class_exists('Metabox_Handler')) {
/**
* @doc en https://developer.wordpress.org/reference/functions/add_meta_box/
* @doc ru http://wp-kama.ru/function/add_meta_box/
*
* @param string $this ->args->slug (string) (Required) Meta box ID (used in the 'id' attribute for the meta box).
* @param string $this ->args->title (string) (Required) Title of the meta box.
* @param mixed $this ->args->screen (string|array|WP_Screen) (Optional) The screen or screens on which to show the box (such as a post type, 'link', or 'comment'). Accepts a single screen ID, WP_Screen object, or array of screen IDs. Default is the current screen.
* Default value: null
* @param string $this ->args->context (string) (Optional) The context within the screen where the boxes should display. Available contexts vary from screen to screen. Post edit screen contexts include 'normal', 'side', and 'advanced'. Comments screen contexts include 'normal' and 'side'. Menus meta boxes (accordion sections) all use the 'side' context. Global
* Default value: 'advanced'
* @param string $this ->args->priority (string) (Optional) The priority within the context where the boxes should show ('high', 'low').
* Default value: 'default'
*
*/
abstract class Metabox_Handler
{
public $slug;
public $slug_nonce;
public $args;
private static $instance;
/**
*
* @example Using this Class
* class SomeClass extends Metabox_Handler {
*
*
* function __construct() {
* $this->args = new stdClass();
* $this->args->slug = 'fb_gallary_';
* $this->args->title = __('Album Bilden', 'pfalz');
* $this->args->screen = 'fb_gallary';
* $this->args->context = 'normal';
* $this->args->priority = 'high';
* parent::__construct();
* }
*
* public function backend($post) {
*
* }
*
* public function update($post_id) {
*
* }
*
* }
*
* new SomeClass();
*
*/
function __construct()
{
if (isset($_GET['post']) || isset($_POST['post_ID'])) {
$this->init_args();
$this->init_metabox();
}
}
private function init_args()
{
if (isset($_GET['post'])) {
$this->ID = $_GET['post'];
} else if (isset($_POST['post_ID'])) {
$this->ID = $_POST['post_ID'];
}
}
public function init_metabox()
{
global $current_screen;
$this->slug = $this->args->slug;
$this->slug_nonce = $this->args->slug . 'nonce';
add_action('add_meta_boxes', array($this, 'add'), 1);
add_action('save_post', array($this, 'privat_update'), 0);
add_action("admin_enqueue_scripts", array($this, 'admin_scripts'));
}
function add()
{
$defaults = array(
'id' => $this->args->slug . '_fields',
'title' => __('Some Title', 'pfalz'),
'screen' => 'any',
'context' => 'normal',
'priority' => 'default',
);
$args = wp_parse_args($this->args, $defaults);
add_meta_box(
$args['id'], $args['title'], array($this, 'private_backend'), $args['screen'], $args['context'], $args['priority']
);
}
function private_backend($post)
{
$this->backend($post);
?>
<input type="hidden" name="<?php echo $this->slug_nonce; ?>" class="widefat"
value="<?php echo wp_create_nonce(__FILE__); ?>"/>
<?php
}
function privat_update($post_id)
{
if (!wp_verify_nonce(@$_POST[$this->slug_nonce], __FILE__))
return false;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return false;
if (!current_user_can('edit_post', $post_id))
return false;
$this->update($post_id);
return $post_id;
}
function admin_scripts()
{
}
abstract public function backend($post);
abstract public function update($post_id);
}
}