Skip to content

Instantly share code, notes, and snippets.

View flayder's full-sized avatar
🏠
Working from home

Artem flayder

🏠
Working from home
View GitHub Profile
$resultName = woocommerce_get_product_terms($product->id, 'pa_topping');
<?php
add_action( 'wp_ajax_do_something', 'get_posts_callback' ); // For logged in users
add_action( 'wp_ajax_nopriv_do_something', 'get_posts_callback' );
function get_posts_callback(){
echo(json_encode( array('status'=>'ok','request_vars'=>$_REQUEST) ));
wp_die();
}
function js_variables(){
$variables = array (
WOOF - WooCommerce Products Filter
function register_post_type() {
$args = array( 'public' => true, 'label' => 'Job Listing' );
register_post_type( 'job', $args );
}
add_action( 'init', 'register_post_type' );
<nav class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="row">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand visible-xs" href="http://1zaicev.ru/">Бизнес в Сети</a>
//хук в init action и вызов create_book_taxonomies когда хук сработает
add_action( 'init', 'create_topics_hierarchical_taxonomy', 0 );
//задаем название для произвольной таксономии Topics для ваших записей
function create_topics_hierarchical_taxonomy() {
// Добавляем новую таксономию, делаем ее иерархической вроде рубрик
// также задаем перевод для интерфейса
/*
* функция добавления редактора
*/
function true_double_editor() {
global $post;
echo '<h2>Галерея</h2>'; // заголовок ко второму редактору
wp_editor( get_post_meta($post->ID, '_true_editor_data', true), 'trueeditor' );
}
add_action( 'edit_form_advanced', 'true_double_editor' );
<?php
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
foreach( $attachment_ids as $attachment_id )
{
//Get URL of Gallery Images - default wordpress image sizes
echo $Original_image_url = wp_get_attachment_url( $attachment_id );
echo $full_url = wp_get_attachment_image_src( $attachment_id, 'full' )[0];
echo $medium_url = wp_get_attachment_image_src( $attachment_id, 'medium' )[0];
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
/** @var array $arParams */
/** @var array $arResult */
/** @global CMain $APPLICATION */
/** @global CUser $USER */
/** @global CDatabase $DB */
/** @var CBitrixComponentTemplate $this */
/** @var string $templateName */
/** @var string $templateFile */
/** @var string $templateFolder */
В section.php добавляем:
<?if ($_GET["sort"] == "name" ||
$_GET["sort"] == "catalog_PRICE_3" ||
$_GET["sort"] == "property_PRODUCT_TYPE" ||
$_GET["sort"] == "timestamp_x"){
$arParams["ELEMENT_SORT_FIELD"] = $_GET["sort"];
$arParams["ELEMENT_SORT_ORDER"] = $_GET["method"];
}else{}?>
В template.php:
<p>Сортировать по: