Skip to content

Instantly share code, notes, and snippets.

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

Fedorenko Sergey ralfostin

🏠
Working from home
View GitHub Profile
@ralfostin
ralfostin / functions.php
Created June 9, 2021 13:23 — forked from Roman52/functions.php
Фильтр по значению произвольного поля.
<?php
//(значение поля) >= (что я ввел)
$args = [
'posts_per_page' => -1,
'meta_query' => [
[
'key' => '_rz_loan_fields|rz_loan_max_summ|0|0|value',
'value' => (int) $_GET['summ'], // это что я ввел в форме фильтра (что я ввел) - это значение будет сравниваться с значением поля так (значение поля) >= (что я ввел)
'type'=> 'numeric',
'compare' =>',
@ralfostin
ralfostin / widget.php
Created June 9, 2021 13:11 — forked from Roman52/widget.php
Виджет популярные статьи|-|&tag=Gists
<?php
# Виджет популярные статьи
class Popular_Morkovin_Widget extends WP_Widget {
function __construct() {
parent::__construct(
'popular_morkovin',
__( 'Популярные статьи', 'text_domain' ),
array('description' => __( 'Популярные статьи Морковина', 'text_domain' ), )
);
}
@ralfostin
ralfostin / functions.php
Created May 16, 2021 20:13 — forked from Roman52/functions.php
ссылки к содержанию для toc+
<?php
//Вот код для function.php выводящий ссылки «к оглавлению» для h2 (кроме первой)
add_filter( 'the_content', 'add_link_to_toc', 100, 1 );
function add_link_to_toc( $content ) {
$toc_container_position = strpos($content, 'toc_container');
if ($toc_container_position) {
$h2_pos = array();
$offset = 0;
@ralfostin
ralfostin / fields.php
Created May 16, 2021 19:35 — forked from Roman52/fields.php
Все опции для сайта плагином carbon fields
<?php
# получить комплексное поле записи
$rz_cards_fields = carbon_get_post_meta(get_the_ID(), 'rz_single_slider');
# получить опцию темы
$home_title = carbon_get_theme_option('rz_page_home_title');
use Carbon_Fields\Container;
use Carbon_Fields\Field;
<?php
/**
* Class Name: your_themename_top_menu
* Description: A custom WordPress nav walker class to implement UIkit menu markup
*/
class your_themename_top_menu extends Walker_Nav_Menu {
/**
* @see Walker::start_lvl()
* @since 3.0.0
@ralfostin
ralfostin / function.php
Created May 12, 2020 16:22 — forked from muks999/function.php
откл и вкл полезностей WP
/*-----Убираем показ лишней информации----------------------****/
add_filter('login_errors', create_function('$a', "return null;"));
remove_action('wp_head', 'wp_generator');
/**
* Закрытие страниц пагинации от индексирования
*/
/*add_action( 'wpseo_head', 'art_noindex_paged', 0 );
function art_noindex_paged() {
@ralfostin
ralfostin / wordpress_while_loop.php
Created March 22, 2020 15:12 — forked from cristianstan/wordpress_while_loop.php
Create a WordPress While Loop
<?php
/* Create a WordPress While Loop
-------------------------------------------------- */
$wordpress_loop_argument = array(
'post_type' => 'custom_post_type',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'ASC'
);
@ralfostin
ralfostin / wp_alt_title_thumb.php
Created November 16, 2019 21:27 — forked from fjaguero/wp_alt_title_thumb.php
Wordpress: Get ALT and TITLE for the post thumbnail
<?php if ( has_post_thumbnail() ) :?>
<a href="<?php the_permalink() ?>" class="thumb"><?php the_post_thumbnail('thumbnail', array(
'alt' => trim(strip_tags( $post->post_title )),
'title' => trim(strip_tags( $post->post_title )),
)); ?></a>
<?php endif; ?>
@ralfostin
ralfostin / wp-query-ref.php
Created September 4, 2019 13:56 — forked from luetkemj/wp-query-ref.php
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/