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
@flayder
flayder / product-woocomerce
Created October 2, 2015 12:02
Вывод товаров из категории woocomerce
<ul class="products">
<?php
$args = array( 'post_type' => 'product',
'posts_per_page' => 5,
'product_cat' => 'addit',
'orderby' => 'rand'
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
@flayder
flayder / product-cart-thumb
Created October 3, 2015 09:38
Вывод картинок из карточки товаров "галерея товара"!
<?php
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
foreach( $attachment_ids as $attachment_id )
{
echo $image_link = wp_get_attachment_url( $attachment_id );
}
?>
@flayder
flayder / gist:6c69c22a0b09a5949182
Created October 12, 2015 13:30
Оптимизация сайта
<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="ru"> <!--<![endif]-->
<head>
<meta charset="utf-8">
if( get_field( "text_field" ) ): ?>
<p><?php the_field( "text_field" ); ?></p>
<?php endif; ?>
// фильтр передает переменную $template - путь до файла шаблона. Изменяя этот путь мы изменяем файл шаблона.
add_filter('template_include', 'my_template');
// функция фильтрации
function my_template( $template ) {
# аналог второго способа
// если это страница со слагом portfolio, используем файл шаблона page-portfolio.php
// используем условный тег is_page()
if( is_page('portfolio') ){
define('DB_HOST', '127.0.0.1:3351');
<?php
if ( !empty($cat) ) :
$parent_cat = get_category($cat);
$output = "<p>Дочерние рубрики раздела {$parent_cat->name}($cat):</p>";
$args = array(
'title_li' => null,
'child_of' => $cat,
'depth' => 1,
'echo' => 0,
'hide_empty' => 0,
Для главной - Тип условия "без условия", для всех остальных Тип условие "Выражение PHP", условие - $GLOBALS["APPLICATION"]->GetCurPage(true) != "/index.php"
<? if ($arSection["PICTURE"]["SRC"]){?><img src="<?=$arSection["PICTURE"]["SRC"]?>" title="<?=$arSection["NAME"]?>" border="0"/><br><?}?>
<? $curt=$APPLICATION->GetCurPage();?>