Skip to content

Instantly share code, notes, and snippets.

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

Edward Veraxo edveraxo

🏠
Working from home
View GitHub Profile
//ACF Radio options
<?php $value = get_field('view_block'); if (($value) == 'yes') : ?>
...
<?php endif; ?>
<?php $value = get_field('view_block'); if (($value) == 'no') : ?>
...
<?php endif; ?>
<?php echo get_field('tab_01_image'); ?>
<?php if(get_field('slider')): ?>
<?php while(has_sub_field('slider')) : ?>
<?php the_sub_field('slide_html'); ?>
<?php endwhile; ?>
<?php endif; ?>
//В файл functions.php добавить
if( function_exists('acf_add_options_page') ) {
acf_add_options_page();
}
@edveraxo
edveraxo / ACF image size
Last active April 22, 2023 18:26 — forked from crondeau/ACF-img-size
Display different image size using ACF
//To display an image using ACF, one would set the image custom field to image url and call the img as follows:
<?php if( get_field( 'field_name' ) ): ?>
<?php while( has_sub_field( 'field_name' ) ): ?>
<img src="<?php the_sub_field( 'image' ); ?>" alt="">
<?php endwhile; ?>
@edveraxo
edveraxo / ACF Rule All children cats from parent
Created April 22, 2023 18:24 — forked from antiden/ACF Rule All children cats from parent
ACF Rule for all children categories from parent
/*ACF taxonomy parent*/
// category ancestor location rule
add_filter('acf/location/rule_types', 'acf_location_types_category_ancestor');
function acf_location_types_category_ancestor($choices)
{
if (!isset($choices['Post']['post_category_ancestor'])) {
$choices['Post']['post_category_ancestor'] = 'Post Category Ancestor';
}
return $choices;
}
// Добавляем в functions.php шаблона
// Открываем FancyBox 3 после отправки сообщений
add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
?>
<script type="text/javascript">
jQuery(document).ready(function($){
document.addEventListener( 'wpcf7mailsent', function( event ) {
$.fancybox.open('<div class="popup ok-send animated-modal"><h2>Сообщение отправлено!</h2><p>Спасибо за Ваше сообщение. Оно успешно отправлено!</p></div>');
// ---- Добавить в functions.php темы
function cg_revert_jquery_version_admin() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
add_action( 'admin_enqueue_scripts', 'cg_revert_jquery_version_admin' );
@edveraxo
edveraxo / Картинка-заглушка для ролика YouTube
Last active July 17, 2023 16:51
Для верстки - Запускаем ролик при клике на заглушку
// HTML
<div class="spawnElement">
<div class="overflow"></div>
<span class="play_video">
<svg width="83" height="59" viewBox="0 0 83 59" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M81.1683 9.32124C80.6922 7.56574 79.7635 5.96531 78.4748 4.67932C77.186 3.39333 75.582 2.46664 73.8227 1.99153C67.3816 0.23877 41.4586 0.23877 41.4586 0.23877C41.4586 0.23877 15.5343 0.291825 9.09326 2.04459C7.33385 2.51972 5.72989 3.44646 4.4411 4.73251C3.15231 6.01857 2.22366 7.61906 1.74763 9.37461C-0.200632 20.7938 -0.956399 38.1939 1.80113 49.1563C2.27721 50.9118 3.20588 52.5122 4.49467 53.7982C5.78345 55.0842 7.38739 56.0109 9.14675 56.486C15.5878 58.2388 41.5115 58.2388 41.5115 58.2388C41.5115 58.2388 67.4348 58.2388 73.8755 56.486C75.6349 56.0109 77.239 55.0843 78.5278 53.7983C79.8166 52.5123 80.7454 50.9118 81.2215 49.1563C83.2764 37.721 83.9096 20.3315 81.1683 9.32124Z" fill="#FF0000"/>
<path d="M33.2074 41.6671L54.7126 29.2386L33.2074 16.8101V41.6671Z" fill="white"/>
</s
// Добавить в functions.php
// Сохранение UTM метки в COOKIES сайта
add_action('init', 'save_utm_to_cookie');
function save_utm_to_cookie() {
$day = 30;
$date = time()+3600*24*$day;
if(isset($_GET["utm_source"])) setcookie("utm_source",$_GET["utm_source"],$date,"/");
if(isset($_GET["utm_medium"])) setcookie("utm_medium",$_GET["utm_medium"],$date,"/");
if(isset($_GET["utm_campaign"])) setcookie("utm_campaign",$_GET["utm_campaign"],$date,"/");
@edveraxo
edveraxo / Advanced Custom Filed (ACF) разрешаем использовать шорткоды
Last active November 15, 2023 16:41
Advanced Custom Filed (ACF) разрешаем использовать шорткоды
add_filter('acf/format_value/type=text', 'do_shortcode');