Skip to content

Instantly share code, notes, and snippets.

@sharkyak
sharkyak / index.php
Last active December 23, 2015 10:58
Wordpress вывод основных полей
<?php echo get_bloginfo('name'); ?>
<?php echo get_bloginfo('description'); ?>
<?php echo get_cat_name(4);?>
<?php echo category_description( $category_id ); ?>
<?php $category = get_the_category( $custompost ); echo $category[0]->cat_name; ?>
<?php $url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' ); $url = $url['0']; ?>
src="<?php echo $url; ?>"
@sharkyak
sharkyak / index.php
Last active November 18, 2015 06:14
Wordpress get posts
<?php if ( have_posts() ) : query_posts('p=1');
while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php the_post_thumbnail(array(100, 100)); ?>
<?php endwhile; endif; wp_reset_query(); ?>
@sharkyak
sharkyak / functions.php
Created November 18, 2015 14:35
wordpress get image form post
function get_post_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){
$img_dir = get_bloginfo('template_directory');
@sharkyak
sharkyak / index.html
Created November 21, 2015 09:14
parallax
data-parallax="scroll" data-image-src=""
http://pixelcog.github.io/parallax.js/
@sharkyak
sharkyak / cmd.exe
Last active June 23, 2016 07:19
wget
wget -p -r -l 10 -e robots=off http://autoservis55.ru/
@sharkyak
sharkyak / common.js
Created December 17, 2015 06:55
smooth scroll
$('a.scroll').click(function () {
elementClick = $(this).attr("href");
destination = $(elementClick).offset().top;
$('html,body').animate( { scrollTop: destination }, 800 );
return false;
});
@sharkyak
sharkyak / functions.php
Created December 17, 2015 07:25
wp widget
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name'=> 'ТОП_1',
'id' => 'top1',
'before_widget' => '<div class="hero-egg-wrap">',
'after_widget' => '</div>',
'before_title' => '<div class="hero-egg1">',
'after_title' => '</div>',
));
}
@sharkyak
sharkyak / contact_me.php
Created April 15, 2016 06:11
Contact form file send
<?php
if($_POST)
{
$to_email = "[email protected]"; //Recipient email, Replace with own email here
$from_email = "[email protected]"; //From email address (eg: [email protected])
$subject = "subject";
//Sanitize input data using PHP filter_var().
$phone1 = filter_var($_POST["phone1"], FILTER_SANITIZE_STRING);
$phone2 = filter_var($_POST["phone2"], FILTER_SANITIZE_STRING);
<?php echo esc_url( get_template_directory_uri() ); ?>/
<?php /* Template Name: Example Template */ ?>