Skip to content

Instantly share code, notes, and snippets.

@Scordavis
Scordavis / Wordpress breadcrumbs
Created November 22, 2017 09:50
Простой пример хлебных крошек для статических страниц. Глубина - 2 уровня. (WP-Kama)
Примеры
Простой пример хлебных крошек для статических страниц. Глубина - 2 уровня.
<div class='breadcrumb'>
<?php
// если есть родительская запись, показать ссылку на нее
$parent_title = get_the_title($post->post_parent);
if( $parent_title != the_title(,,false) ){
echo '<a href=\"' . get_permalink($post->post_parent) .
/* ----------------------------------------------------------------------------------------------------
Super Form Reset
A couple of things to watch out for:
- IE8: If a text input doesn't have padding on all sides or none the text won't be centered.
- The default border sizes on text inputs in all UAs seem to be slightly different. You're better off using custom borders.
- You NEED to set the font-size and family on all form elements
- Search inputs need to have their appearance reset and the box-sizing set to content-box to match other UAs
<?php
$tags = get_tags();
if ($tags) {
foreach ($tags as $tag) {
echo '<p>Tag: <a href="' . get_tag_link( $tag->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag->name ) . '" ' . '>' . $tag->name.'</a> </p> ';
}
}
?>
<?php
//Аякс отправка форм
//Документация: http://api.jquery.com/jquery.ajax/
$("#form, #form2").submit(function(e) {
e.preventDefault;
$.ajax({
type: "POST",
url: "mail.php",
data: $(this).serialize()
}).done(function() {
alert("Спасибо за заявку!");
@Scordavis
Scordavis / php, wordpress
Last active May 1, 2017 19:26
Запрет вывода отрывка поста если цитата не задана / stop view begining of post if cite is undefined
<?php if ( have_posts() ) : query_posts('p=181');
while (have_posts()) : the_post(); ?>
<?php if(has_excerpt($id)){
the_excerpt();
} else {} ?>
<? endwhile; endif; wp_reset_query(); ?>
@Scordavis
Scordavis / WordPress
Created April 29, 2017 21:59
<?php get_cat_name(5); ?>
<?php get_cat_name(5); ?>
<?php
$idObj = get_category_by_slug('s_about');
$id = $idObj->term_id;
echo get_cat_name($id);
?>
или
<?php
$idObj = get_category_by_slug('sto_section');
//In Template
<?php
$options = get_option('sample_theme_options');
echo $options['phone1'];
?>
//in functions.php
require_once ( get_stylesheet_directory() . '/theme-options.php' );
//remove class from the_post_thumbnail
function the_post_thumbnail_remove_class($output) {
$output = preg_replace('/class=".*?"/', '', $output);
return $output;
}
add_filter('post_thumbnail_html', 'the_post_thumbnail_remove_class');
@Scordavis
Scordavis / Adding classes
Last active April 29, 2017 13:06
jquerry
$( "p" ).addClass( "myClass yourClass" );
$( "p" ).removeClass( "myClass noClass" ).addClass( "yourClass" );