audiolab-theme/functions.php

75 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2016-12-23 20:38:21 +01:00
<?php
if (function_exists('register_sidebar')) {
$args = array(
'name' => 'sidebar',
'id' => 'sidebar',
'description' => '',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>' );
register_sidebar($args);
$args2 = array(
'name' => 'top',
'id' => 'top',
'description' => '',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>' );
register_sidebar($args2);
}
if (function_exists('register_nav_menu')) {
register_nav_menu( 'primary', 'Primary Menu');
}
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150 ); // default Post Thumbnail dimensions
}
if ( function_exists( 'add_image_size' ) ) {
// add_image_size( 'featured-thumb', 300, 9999 ); //300 pixels wide (and unlimited height)
add_image_size( 'featured-image', 470, 300, true ); //(cropped)
add_image_size( 'featured-small', 150, 93, true ); //(cropped)
}
function audiolabLatest(){
$posts = get_featured_posts(array( 'method' => 'arr'));
$out ='';
$small = '';
if (count($posts)==0)
return;
$out .='<div id="featured-posts"><div id="featured-slider">';
$small .='<div id="featured-thumbs">';
foreach ($posts as $key => $post) {
$id = $post['id'];
$link = get_permalink($id);
$tid = get_post_thumbnail_id($id);
$url_img = wp_get_attachment_image_src($tid);
$out .='<div class="featured-single" id="single-'. $id . '"><div class="featured-wrapper"><div class="featured-single-image" style="width:470px;height:300px;background-size:cover;background-image:url(\''.$url_img[0].'\');">';
if(has_post_thumbnail($id)){
$out .= get_the_post_thumbnail($id,'featured-image') . '</div>';
$small .= '<a href="#" rel="single-' . $id . '" class="featured-thumb-image" style="width:150px;height:93px;background-size:cover;background-image:url(\''.$url_img[0].'\')"></a>';
//$small .= '<a href="#" rel="single-' . $id . '" class="featured-thumb-image">' . get_the_post_thumbnail($id,'featured-small') . '</a>';
}
$out .= '<div class="featured-single-title"><h2><a href="' . $link . '"><span>' . $post['title'] . '</span></a></h2></div>';
$out .= '</div></div>';
}
$small .='</div>';
$out .='</div>' .$small . '</div>';
return $out;
}