Skip to content

Instantly share code, notes, and snippets.

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

Dmitry Bednyuk weblegko

🏠
Working from home
View GitHub Profile
@weblegko
weblegko / random_post.php
Created August 28, 2015 11:13
Wordpress - Output random custop posts
<ul>
<?php
global $post;
$args = array( 'post_type' => 'portfolio', 'numberposts' => 4, 'orderby' => 'rand'); $tmp_post = $post;
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach;
$post = $tmp_post;
?>
@weblegko
weblegko / response_video_youtube.css
Created August 27, 2015 16:59
CSS for response youtube video
/*for parent div*/
.myvideo {
position:relative;
margin: 20px 0;
padding-bottom:56.25%;
padding-top:30px;
height:0;
overflow:hidden;
border:1px solid #ccc;
}
@weblegko
weblegko / tags_category_meta.php
Created August 27, 2015 16:19
Output wordpress tags and category in standart loop
//Wordpress output category and tags in loop for standart post type
$category_list = get_the_category_list(', ');
$tag_list = get_the_tag_list('', ', ');
if($category_list != '' || $tag_list !='' ) echo '<div class="dizi-meta">';
if($category_list != '') echo $category_list;
if($tag_list !='' ) echo '<i class="fa fa-tags"></i>' . $tag_list;
if($category_list != '' || $tag_list !='' )echo '</div>';
@weblegko
weblegko / custom_taxonomy_tags.php
Last active August 27, 2015 14:29
Wordpress shortcode - output list of custom taxonomy of custom post type
<?php
// Wordpress shortcode custom taxanomy
// output list of custom taxonomy
// 'portfolio_tag' - custom taxanomy for custom post type
function portfolio_tags_function(){
global $post;
//$posttags = get_the_tags($post->ID);
$tax = '<b>Tags:</b>&nbsp;<span style="color: #fab702;"> ';
$cur_terms = get_the_terms( $post->ID, 'portfolio_tag' );
$n=0;
@weblegko
weblegko / gist:530535e7dd29aa1853d0
Last active September 7, 2016 08:14
Ограничение количества символов для анонса страницы UMI CMS
//Ограничение длины строки
public function truncString($pageId, $propName, $limit, $pTag = 0) {
$hierarchy = umiHierarchy::getInstance();
$page = $hierarchy->getElement($pageId);
if ($page === false)
return "";
$propVal = $page->getValue($propName);
@weblegko
weblegko / umi_custom.php
Last active May 12, 2020 10:05
Передача в кастомный макрос umi строки - переменной xslt
<?php // правим файл classes/modules/custom.php
class custom extends def_module {
public function cms_callMethod($method_name, $args) {
return call_user_func_array(Array($this, $method_name), $args);
}
public function __call($method, $args) {
throw new publicException("Method " . get_class($this) . "::" . $method . " doesn't exists");
}
//TODO: Write your own macroses here
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<link rel="stylesheet" href="stylesheets/screen.css">
</head>
<body>
<div class="container c1"></div>
<div class="container c2"></div>