Заметки фрилансера

334 info Aвтор:
Рейтинг: 5/5 - 1 голосов

Заметки фрилансера

Подключаем  jQuery wordpress

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );

function my_scripts_method() {

    // отменяем зарегистрированный jQuery

    // вместо "jquery-core", можно вписать "jquery", тогда будет отменен еще и jquery-migrate

    wp_deregister_script( 'jquery-core' );

    wp_register_script( 'jquery-core', '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');

    wp_enqueue_script( 'jquery' );

}

 


Вставка шорткода в php

do_shortcode( );
<?php echo do_shortcode("[wpsm_comparison_table id='4' ]"); ?>

Перемещаем блоки при помощи jquery

// .div1 // куда перемещаем
// .div2// что перемещаем
$('.div1').append($('.div2'));

Медиа запросы css 

/* monitors and laptops */
@media screen and (min-width: 1240px)  {}

/* tablet */
@media screen and (min-width: 1024px) and (max-width: 1240px)  {}

@media screen and (min-width: 768px) and (max-width: 1024px) {}

/* mobile */
@media screen and (max-width: 768px) {}

/* iPad in portrait & landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px)  {}

/* iPad in landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {}

/* iPad in portrait */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {}

/* Retina iPad in portrait & landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (-webkit-min-device-pixel-ratio: 2) {}

/* Retina iPad in landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 2) {}

/* Retina iPad in portrait */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio: 2) {}

/* iPad 1 & 2 in portrait & landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (-webkit-min-device-pixel-ratio: 1){}

/* iPad 1 & 2 in landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio: 1)  {}

/* iPad 1 & 2 in portrait */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio: 1) {}

/* iPad mini in portrait & landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (-webkit-min-device-pixel-ratio: 1)  {}

/* iPad mini in landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio: 1)  {}

/* iPad mini in portrait */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio: 1)  {}

/* iPhone 5 in portrait & landscape */
@media only screen and (min-device-width : 320px) and (max-device-width : 568px) {}

/* iPhone 5 in landscape */
@media only screen and (min-device-width : 320px) and (max-device-width : 568px) and (orientation : landscape) {}

/* iPhone 5 in portrait */
@media only screen and (min-device-width : 320px) and (max-device-width : 568px) and (orientation : portrait) {}

/* iPhone 2G-4S in portrait & landscape */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {}

/* iPhone 2G-4S in landscape */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : landscape) {}

/* iPhone 2G-4S in portrait */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : portrait) {}

Ширина блока 

var widhfix = $('#main').width();
$(".fixtop").css("width",widhfix);

$(window).resize(function(){
     var widhfix = $('#main').width();
     $(".fixtop-action").css("width",widhfix);
    });


Замена id

это сработает только для первого встреченного элемента с id "old_id", // остальные элементы с таким id будут проигнорированы. $('#old_id').attr('id, 'new_id');


Вставка произвольных полей woocommerce


add_action( 'woocommerce_before_add_to_cart_form', 'art_get_text_field_before_add_card' );
function art_get_text_field_before_add_card() {
    global $post;
    echo get_post_meta($post->ID, 'catalog_turbin_automobil', true);
    

}

 

 


Добавляем слеш вконце url

RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

Редирект если есть большие буквы в url ( вставить ввверх страници)

if ( $_SERVER['REQUEST_URI'] != strtolower( $_SERVER['REQUEST_URI']) ) {
    header('Location: http://'.$_SERVER['HTTP_HOST'] . 
            strtolower($_SERVER['REQUEST_URI']), true, 301);
    exit();
}

ALT ДЛЯ ИЗОБРАЖЕНИЯ ТОВАРА В WOOCOMMERCE

add_filter('wp_get_attachment_image_attributes', 'change_attachement_image_attributes', 20, 2);

function change_attachement_image_attributes( $attr, $attachment ){
// Get post parent
$parent = get_post_field( 'post_parent', $attachment);

// Get post type to check if it's product
$type = get_post_field( 'post_type', $parent);
if( $type != 'product' ){
return $attr;
}

/// Get title
$title = get_post_field( 'post_title', $parent);

$attr['alt'] = $title;
$attr['title'] = $title;

return $attr;
}

Вывод значений из кастомных полей 

$field_key = "field_5b79806a93e16"; $field = get_field_object($field_key); if( $field ) { 
				echo '<select class="mo_select2" name="house_type"> <option value="any" selected="selected">Any</option>';

				 foreach( $field['choices'] as $k => $v ) { echo '<option value="' . $k . '">' . $v . '</option>'; } 
				echo '</select>'; }

Шорткод для contact form 7

function castom_cf7_func() {
 //code
  return 'ура все получилось!':
}

wpcf7_add_form_tag('castom_function', 'castom_cf7_func');

//castom_cf7_func - название функции
//castom_function - название шорткода [castom_function]

 

3 случайных Поста

Card image cap
Cron wordpress
Card image cap
Форма обратной связи в телеграм
Card image cap
Вывод модуля html в выбраных категориях opencart

коммент.

Контакти

Contact

info@pechenki.top

Начать чат со мной

© SiteBlog designer