ACC SHELL

Path : /srv/www/vhosts/dovastex/wp-content/themes/web_dovastex/
File Upload :
Current File : /srv/www/vhosts/dovastex/wp-content/themes/web_dovastex/functions.php

<?php

/********** NAVIGATIONS *********** */
function register_my_menus() {
  register_nav_menus(
    array(
      'header-menu' => __( 'Header Menu' ),
      'footer-menu' => __( 'Footer Menu' )
    )
  );
}
add_action( 'init', 'register_my_menus' );
add_theme_support( 'post-thumbnails' );


/********** BREADCRUMB *********** */
 function the_breadcrumb() {
    global $post;
    echo '<ul class="breadcrumbs">';
    if (!is_home()) {
        echo '<li><a href="';
        echo get_option('home');
        echo '">';
        echo 'Hlavní stránka';
        echo '</a></li><li class="separator"> <i class="fa fa-angle-right"></i> </li>';
        if (is_category() || is_single()) {
            echo '<li>';
            the_category(' </li><li class="separator"> <i class="fa fa-angle-right"></i> </li><li> ');
            if (is_single()) {
                echo '</li><li class="separator"> <i class="fa fa-angle-right"></i> </li><li>';
                the_title();
                echo '</li>';
            }
        } elseif (is_page()) {
            if($post->post_parent){
                $anc = get_post_ancestors( $post->ID );
                $title = get_the_title();
                foreach ( $anc as $ancestor ) {
                    $output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator"><i class="fa fa-angle-right"></i></li>';
                }
                echo $output;
                echo $title;
            } else {
                echo '<li>'.get_the_title().'</li>';
            }
        }
    }
    elseif (is_tag()) {single_tag_title();}
    elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
    elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
    elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
    elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
    elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
    elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
    echo '</ul>';
}


/******* SHORTCODES ******/

function offers($atts) {
        $offer .= '<div class="homepage-boxes clearfix">';
        $count = 0;
        query_posts('category_name=nabidka&posts_per_page=4');
        while (have_posts()) : the_post(); $fimg = get_post_meta($post->ID, "thumb", TRUE);

            if ($count==3){
                $offer .= '<div class="homepage-box last-homepage-box">';
            } else {
                $offer .= '<div class="homepage-box">';
            }
            $offer .= '<div class="homepage-box__image"><a href="'.get_the_permalink().'">'.get_the_post_thumbnail().'</a></div>';
            $offer .= '<div class="homepage-box__content">';
            $offer .= '<div class="homepage-box__title"><h4><a href="'.get_the_permalink().'">'.get_the_title().'</a></h4></div>';
            $offer .= '<div class="homepage-box__link"><a href="'.get_the_permalink().'"><i class="fa fa-angle-right"></i> Více informací</a></div>';
            $offer .= '</div>';
            $offer .= '</div>';
                
            $count++;

            endwhile;
            wp_reset_query();
        $offer .= '</div>';

        return $offer;
}
add_shortcode('offers', 'offers');


function myposts($atts) {

  $atts = shortcode_atts( array(
      'category' => ''
  ), $atts );

    $myposts .= '<div class="offers">';
        query_posts('category_name="'.$atts['category'].'"');
        while (have_posts()) : the_post(); $fimg = get_post_meta($post->ID, "thumb", TRUE);  
            $myposts .= '<div class="offer-box">';
                $myposts .= '<div class="offer-box__image"><a href="'.get_the_permalink().'">'.get_the_post_thumbnail().'</a></div>';
                $myposts .= '<div class="offer-box__content">';
                $myposts .= '<div class="offer-box__content__title"><a href="'.get_the_permalink().'">'.get_the_title().'</a></div>';
                $myposts .= '<div class="offer-box__content__text">'.get_field("perex").'</div>';
                $myposts .= '<div class="offer-box__content__link"><a href="'.get_the_permalink().'"><i class="fa fa-angle-right"></i> Více informací</a></div>';
                $myposts .= '</div>';
            $myposts .= '</div>';
        endwhile;
        wp_reset_query();

    $myposts .= '</div>';
    return $myposts;
}
add_shortcode('myposts', 'myposts');
?>

ACC SHELL 2018