// Shortcode for projects [projects-list posts="3"]
function projects_listing_parameters_shortcode( $atts ) {
ob_start();
$args = shortcode_atts( array (
'type' => 'projects',
'posts' => 6,
'cat' => ''
), $atts );
$options = array(
'post_type' => $args['type'],
'posts_per_page' => $args['posts'],
'tax_query' => array(
array (
'taxonomy' => 'project',
'field' => 'slug',
'terms' => $args['cat'],
)
),
);
$query = new WP_Query( $options );
if ( $query->have_posts() ) $item = 0; {
while ( $query->have_posts() ) : $query->the_post(); $item++;
echo '<div class="item item-' . $item . '">';
get_template_part( 'template-parts/project-cards', get_post_format() );
echo '</div>';
endwhile;
wp_reset_postdata();
$myvariable = ob_get_clean();
return $myvariable;
}
}
add_shortcode( 'projects-list', 'projects_listing_parameters_shortcode' );
Page Template — If the page has a custom template assigned, WordPress looks for that file and, if found, uses it.
page-{slug}.php — If no custom template has been assigned, WordPress looks for and uses a specialized template that contains the page’s slug.
page-{id}.php — If a specialized template that includes the page’s slug is not found, WordPress looks for and uses a specialized template named with the page’s ID.
page.php — If a specialized template that includes the page’s ID is not found, WordPress looks for and uses the theme’s default page template.
singular.php — If page.php is not found, WordPress looks for and uses the theme’s template used for a single post, irregardless of post type.
index.php — If no specific page templates are assigned or found, WordPress defaults back to using the theme’s index file to render pages.
Technical note
Since the plugin hooks into the theme on client-side to intercept the comment form submit process, and to add new comments without reloading the page, the plugin needs to access the DOM nodes using jQuery selectors. The plugin comes with default values for these selectors that were successfully tested with WordPress’ default themes «Twenty Ten», «Twenty Eleven», «Twenty Twelve», «Twenty Thirteen», «Twenty Fourteen», «Twenty Fifteen», «Twenty Sixteen». If required, the selectors can be customized to match your theme in the plugin’s settings.
Google Translate:
Техническое примечание
Поскольку плагин подключается к теме на стороне клиента, чтобы перехватить процесс отправки формы комментария и добавить новые комментарии без перезагрузки страницы, плагину необходимо получить доступ к узлам DOM с помощью селекторов jQuery. Плагин имеет значения по умолчанию для этих селекторов, которые были успешно протестированы с темами WordPress по умолчанию «Двадцать десять», «Двадцать одиннадцать», «Двадцать двенадцать», «Двадцать тринадцать», «Двадцать четырнадцать», «Двадцать пятнадцать», «Двадцать». Шестнадцать". При необходимости селекторы можно настроить в соответствии с вашей темой в настройках плагина.
function comfort_item_shortcode() {
if ( have_rows( 'comfort' ) ) :
while ( have_rows( 'comfort' ) ) : the_row(); ?>
<div class="item">
<?php if ( get_sub_field( 'icon' ) ) : ?>
<img class="icon" src="<?php the_sub_field( 'icon' ); ?>" />
<?php endif ?>
<span class="text"><p><?php the_sub_field( 'text' ); ?></p></span>
</div>
<?php endwhile;
endif;
}
add_shortcode( 'comfort_item', 'comfort_item_shortcode' );
//Returns All Term Items for "my_taxonomy"
$term_list = wp_get_post_terms($post->ID, 'my_taxonomy', array("fields" => "all"));
print_r($term_list);
//Returns Array of Term Names for "my_taxonomy"
$term_list = wp_get_post_terms($post->ID, 'my_taxonomy', array("fields" => "names"));
print_r($term_list);
//Returns Array of Term ID's for "my_taxonomy"
$term_list = wp_get_post_terms($post->ID, 'my_taxonomy', array("fields" => "ids"));
print_r($term_list);
//Echo a single value - $term_list is an array of objects. You must select one of the
// array entries before you can reference its properties (fields).
$term_list = wp_get_post_terms($post->ID, 'my_taxonomy', array("fields" => "all"));
echo $term_list[0]->description ;
//Do something if a specific array value exists within a post
$term_list = wp_get_post_terms($post->ID, 'product_features', array("fields" => "all"));
foreach($term_list as $term_single) {
echo $term_single->slug; //do something here
}
https://evro-brend.ru/wp-content/themes/woodmart/js/functions.min.js
(woodmartThemeModule.ajaxFilters = function () {
if (a("body").hasClass("woodmart-ajax-shop-on") && void 0 !== a.fn.pjax && !a("body").hasClass("single-product")) {
var c = this,
d = !1;
a(".products");
a("body").on("click", ".post-type-archive-product .products-footer .woocommerce-pagination a", function (a) {
e(!0);
}),
a(document).pjax(b.ajaxLinks, ".main-page-wrapper", { timeout: woodmart_settings.pjax_timeout, scrollTo: !1 }),
"click" == woodmart_settings.price_filter_action
? a(document).on("click", ".widget_price_filter form .button", function () {
var b = a(".widget_price_filter form");
return a.pjax({ container: ".main-page-wrapper", timeout: woodmart_settings.pjax_timeout, url: b.attr("action"), data: b.serialize(), scrollTo: !1 }), !1;
})
: "submit" == woodmart_settings.price_filter_action &&
a(document).on("submit", ".widget_price_filter form", function (b) {
var c = a(".main-page-wrapper");
a.pjax.submit(b, c);
}),
a(document).on("pjax:error", function (a, b, c, d) {
console.log("pjax error " + c);
}),
a(document).on("pjax:start", function (b, c) {
a(".site-content").removeClass("ajax-loaded"), a(".site-content").addClass("ajax-loading"), woodmartThemeModule.hideShopSidebar();
}),
a(document).on("pjax:complete", function (b, d, f) {
c.shopPageInit(),
e(!1),
a(document).trigger("wood-images-loaded"),
a(".woodmart-sidebar-content").scroll(function () {
a(document).trigger("wood-images-loaded");
}),
a(".site-content").removeClass("ajax-loading");
}),
a(document).on("pjax:beforeReplace", function (b, c) {
a(".filters-area").hasClass("filters-opened") && "yes" == woodmart_settings.shop_filters_close && ((d = !0), a("body").addClass("body-filters-opened"));
}),
a(document).on("pjax:end", function (b, c, e) {
d && (a(".filters-area").css("display", "block"), woodmartThemeModule.openFilters(200), (d = !1)), a(".site-content").removeClass("ajax-loading"), a(".site-content").addClass("ajax-loaded");
});
var e = function (b) {
if ("no" == woodmart_settings.ajax_scroll && 0 == b) return !1;
var c = a(woodmart_settings.ajax_scroll_class),
d = c.offset().top - woodmart_settings.ajax_scroll_offset;
a("html, body").stop().animate({ scrollTop: d }, 400);
};
}
}),
a(document).on("pjax:start", function (b, c) {
a(".site-content").removeClass("ajax-loaded"), a(".site-content").addClass("ajax-loading"), woodmartThemeModule.hideShopSidebar();
}),
a(document).on("pjax:start", function (b, c) {
a(".site-content").removeClass("ajax-loaded"), a(".site-content").addClass("ajax-loading");
}),
<?php
if ( !current_user_can( 'subscriber' ) ) { ?>
<button>Кнопка для всех (кроме подписчиков)</button>
<?php } ?>
<?php
// Видно будет только администраторам
if ( current_user_can( 'administrator' ) ) { ?>
<button>Кнопка для администратора</button>
<?php } ?>
current_user_can('administrator') // false
current_user_can('editor') // true
current_user_can('contributor') // false
current_user_can('subscriber') // false
function my_theme_archive_title( $title ) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>';
} elseif ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
} elseif ( is_tax() ) {
$title = single_term_title( '', false );
}
return $title;
}
add_filter( 'get_the_archive_title', 'my_theme_archive_title' );
<ul>
<?php while ( have_rows( 'taby' ) ) : the_row(); $i++ ?>
<li data-tab="tab-<?php echo $i; ?>"><a href="#"><?php the_sub_field( 'zagolovok_taba' ); ?></a></li>
<?php endwhile; ?>
</ul>
<?php $i = 0; ?>
<?php while ( have_rows( 'taby' ) ) : the_row(); $i++ ?>
<div id="tab-<?php echo $i; ?>"></div>
<?php endwhile; ?>
function simple_spoiler_shortcode($atts, $content) {
if ( ! isset($atts['title']) ) {
$sp_name = __( 'Спойлер', 'simple-spoiler' );
} else {
$sp_name = $atts['title'];
}
$sp_icon='';
if(!empty($atts['icon'])){
$sp_icon = '<div class="icon"><img src="'.$atts['icon'].'" alt="" /></div>';
$sp_class = 'icon';
}
return '<div class="spoiler">
<div class="head '.$sp_class.'">'.$sp_icon.$sp_name.'</div>
<div class="cont">'.$content.'</div>
</div>';
}
add_shortcode( 'spoiler', 'simple_spoiler_shortcode' );
'meta_key' => 'project_sort_project',
case 'data_starta' :
if ( have_rows( 'data_raspisanie_grafik' ) ) :
while ( have_rows( 'data_raspisanie_grafik' ) ) : the_row();
$start = get_sub_field( "date_start", $post->ID );
if ( empty( $start ) )
echo __( 'Дата не указана' );
else
printf( $start );
endwhile;
endif;
break;
function my_shortcode_function() {
global $wp_query;
$wp_query = new WP_Query(array(
'category_name' => 'portfolio',
'post_type' => 'page',
'posts_per_page' => '1',
'paged' => get_query_var('paged') ?: 1
));
ob_start();
if ( have_posts() ) :
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_format() );
endwhile;
else :
get_template_part( 'template-parts/content', 'none' );
endif;
posts_nav_link();
wp_reset_query();
$out = ob_get_clean();
return $out;
}
https://github.com/ineagu/wp-menu-item-custom-fields
https://wpbeaches.com/adding-data-attribute-menu-l...
/**
* Register meta boxes.
*/
function hcf_register_meta_boxes() {
add_meta_box( 'hcf-1', __( 'Сайдбар для данной записи', 'hcf' ), 'wporg_custom_box_html', 'post', 'side' );
}
add_action( 'add_meta_boxes', 'hcf_register_meta_boxes' );
function wporg_custom_box_html($post)
{
$value = get_post_meta($post->ID, '_wporg_meta_key', true);
/* format setting outer wrapper */
echo '<div class="format-setting type-sidebar-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
/* description */
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
/* format setting inner wrapper */
echo '<div class="format-setting-inner">';
/* build page select */
echo '<label for="clinics_sidebar">Выберите Сайдбар</label><select name="clinics_sidebar" id="clinics_sidebar" class="components-select-control__input">';
// Кастомный список
echo '<option value="">-- ' . __( 'Выберите сайдбар', 'dart' ) . ' --</option>';
echo '<option value="sidebar-1" id="sidebar-1"' . selected($value, 'sidebar-1') . '>' . __( 'Сайдбар #1', 'dart' ) . '</option>';
echo '<option value="sidebar-2" id="sidebar-2"' . selected($value, 'sidebar-2') . '>' . __( 'Сайдбар #2', 'dart' ) . '</option>';
echo '<option value="sidebar-3" id="sidebar-3"' . selected($value, 'sidebar-3') . '>' . __( 'Сайдбар #3', 'dart' ) . '</option>';
echo '<option value="sidebar-4" id="sidebar-4"' . selected($value, 'sidebar-4') . '>' . __( 'Сайдбар #4', 'dart' ) . '</option>';
echo '<option value="sidebar-5" id="sidebar-5"' . selected($value, 'sidebar-5') . '>' . __( 'Сайдбар #5', 'dart' ) . '</option>';
echo '<option value="sidebar-6" id="sidebar-6"' . selected($value, 'sidebar-6') . '>' . __( 'Сайдбар #6', 'dart' ) . '</option>';
echo '<option value="sidebar-7" id="sidebar-7"' . selected($value, 'sidebar-7') . '>' . __( 'Сайдбар #7', 'dart' ) . '</option>';
echo '<option value="sidebar-8" id="sidebar-8"' . selected($value, 'sidebar-8') . '>' . __( 'Сайдбар #8', 'dart' ) . '</option>';
echo '<option value="no-sidebar" id="no-sidebar"' . selected($value, 'no-sidebar') . '>' . __( 'Без сайдбара', 'dart' ) . '</option>';
// Кастомный список
// /* get the registered sidebars */
// global $wp_registered_sidebars;
// $sidebars = array();
// foreach( $wp_registered_sidebars as $id=>$sidebar ) {
// $sidebars[ $id ] = $sidebar[ 'name' ];
// }
// /* filters to restrict which sidebars are allowed to be selected, for example we can restrict footer sidebars to be selectable on a blog page */
// $sidebars = apply_filters( 'recognized_sidebars', $sidebars );
// $sidebars = apply_filters( 'recognized_sidebars_' . $field_id, $sidebars );
// /* has sidebars */
// if ( count( $sidebars ) ) {
// echo '<option value="">-- ' . __( 'Выберите сайдбар', 'dart' ) . ' --</option>';
// foreach ( $sidebars as $id => $sidebar ) {
// echo '<option value="' . esc_attr( $id ) . '"' . selected( $value, $id, false ) . '>' . esc_attr( $sidebar ) . '</option>';
// }
// } else {
// echo '<option value="">' . __( 'No Sidebars', 'dart' ) . '</option>';
// }
echo '</select>';
echo '</div>';
echo '</div>';
?>
<?php
}
function wporg_save_postdata($post_id)
{
if (array_key_exists('clinics_sidebar', $_POST)) {
update_post_meta(
$post_id,
'_wporg_meta_key',
$_POST['clinics_sidebar']
);
}
}
add_action('save_post', 'wporg_save_postdata');
<?php
$custom_sidebar = esc_attr( get_post_meta( get_the_ID(), '_wporg_meta_key', true ) );
if($custom_sidebar == 'sidebar-1'){
?>
<nav id="sidebar" class="course">
<div>
<?php if ( function_exists('dynamic_sidebar') )
dynamic_sidebar('sidebar-1'); ?>
</div>
</nav>
<?php
} elseif ($custom_sidebar == 'sidebar-2') {
?>
<nav id="sidebar" class="course">
<div>
<?php if ( function_exists('dynamic_sidebar') )
dynamic_sidebar('sidebar-2'); ?>
</div>
</nav>
<?php
} elseif ($custom_sidebar == 'sidebar-3') {
?>
<nav id="sidebar" class="course">
<div>
<?php if ( function_exists('dynamic_sidebar') )
dynamic_sidebar('sidebar-3'); ?>
</div>
</nav>
<?php
} elseif ($custom_sidebar == 'sidebar-4') {
?>
<nav id="sidebar" class="course">
<div>
<?php if ( function_exists('dynamic_sidebar') )
dynamic_sidebar('sidebar-4'); ?>
</div>
</nav>
<?php
} elseif ($custom_sidebar == 'sidebar-5') {
?>
<nav id="sidebar" class="course">
<div>
<?php if ( function_exists('dynamic_sidebar') )
dynamic_sidebar('sidebar-5'); ?>
</div>
</nav>
<?php
} elseif ($custom_sidebar == 'sidebar-6') {
?>
<nav id="sidebar" class="course">
<div>
<?php if ( function_exists('dynamic_sidebar') )
dynamic_sidebar('sidebar-6'); ?>
</div>
</nav>
<?php
} elseif ($custom_sidebar == 'sidebar-7') {
?>
<nav id="sidebar" class="course">
<div>
<?php if ( function_exists('dynamic_sidebar') )
dynamic_sidebar('sidebar-7'); ?>
</div>
</nav>
<?php
} elseif ($custom_sidebar == 'sidebar-8') {
?>
<nav id="sidebar" class="course">
<div>
<?php if ( function_exists('dynamic_sidebar') )
dynamic_sidebar('sidebar-8'); ?>
</div>
</nav>
<?php } else { ?>
<nav id="sidebar" class="course">
<div>
<?php if ( function_exists('dynamic_sidebar') )
dynamic_sidebar('news-sidebar'); ?>
</div>
</nav>
<?php
}?>