Skip to content

Instantly share code, notes, and snippets.

@anatol06
anatol06 / customizer.js
Last active May 9, 2018 15:25
Customizer with basic controls sample
// Customizer with basic controls sample
function themename_customize_register($wp_customize){
$wp_customize->add_section('themename_color_scheme', array(
'title' => __('Color Scheme', 'themename'),
'description' => '',
'priority' => 120,
));
// =============================
@anatol06
anatol06 / customizer.php
Created May 8, 2018 10:18
Theme customize register for customize.php file - Empty
function mytheme_customize_register( $wp_customize ) {
//All our sections, settings, and controls will be added here
}
add_action( 'customize_register', 'mytheme_customize_register' );
@anatol06
anatol06 / front-page.php
Last active May 7, 2018 18:32
Insert post thumbnails
<?php if(has_post_thumbnail()) : ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?>
@anatol06
anatol06 / footer.php
Last active May 6, 2018 21:53
Insert the Widget in template
@anatol06
anatol06 / functions.php
Created May 6, 2018 18:16
Regeister and init Sidebar and 4 footer widgets
// Widget Locations
function fc_init_widgets($id){
register_sidebar(array(
'name' => 'Sidebar',
'id' => 'sidebar',
'before_widget' => '<div class="sidebar-widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
@anatol06
anatol06 / archive.php
Last active May 6, 2018 16:53
Get the title for Archive or Search pages
<!-- Get Archive Title -->
<?php if(is_category()) {
single_cat_title();
} else if (is_author()) {
the_post();
echo 'Archives By Author: ' .get_the_author();
rewind_posts();
} else if (is_tag()) {
single_tag_title();
@anatol06
anatol06 / index.php
Last active May 6, 2018 21:53
Get the list of categories to which the article belongs
<?php // Get the list of categories to which the article belongs
$categories = get_the_category();
$separator = ", ";
$output = '';
if($categories) {
foreach($categories as $category) {
$output .= '<a href="'.
get_category_link($category->term_id).'">'.
@anatol06
anatol06 / front-page.php
Created May 6, 2018 16:24
The time in format - MAY 6, 2018 2:47 PM
<?php the_time('F j, Y g:i a'); ?>
@anatol06
anatol06 / front-page.php
Last active May 6, 2018 16:20
Get a featured query with each even post floated Right
<?php
$i = 0; // Counter
?>
<?php $featured_query = new WP_query(array(
'category_name' => 'featured' )); ?>
<?php while ($featured_query->have_posts()) :
$featured_query->the_post(); ?>
@anatol06
anatol06 / index.php
Last active May 6, 2018 16:20
Get posts except specified cathegory
<?php // Get all posts except Featured
$no_featured_query = new WP_Query(array(
'cat' => '-3',
)); ?>
<?php while($no_featured_query->have_posts()) : ?>
<?php $no_featured_query->the_post(); ?>
<!-- HTML here-->