Skip to content

Instantly share code, notes, and snippets.

@Zeindelf
Last active September 21, 2016 04:38
Show Gist options
  • Save Zeindelf/66b3733f4df3bdc0557e2cd9792ae4eb to your computer and use it in GitHub Desktop.
Save Zeindelf/66b3733f4df3bdc0557e2cd9792ae4eb to your computer and use it in GitHub Desktop.
WP
<?php
/**************************************
* THEME SUPORT
**************************************/
function add_suport_theme(){
add_theme_support( 'post-thumbnails' );
}
add_action('after_setup_theme','add_suport_theme');
/**************************************
* Registro Menu Personalizado
**************************************/
add_theme_support('menus');
/**************************************
* SCRIPTS / CSS
**************************************/
function wp_responsivo_scripts() {
// Carregando CSS header
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css' );
wp_enqueue_style( 'style', get_stylesheet_uri() );
// Carregando Scripts header
wp_enqueue_script('bootstrap-js', get_template_directory_uri().'/assets/js/bootstrap.min.js', array('jquery') );
//Carregando no footer
//wp_enqueue_script('functions-js', get_template_directory_uri().'/assets/js/functions.js', array('jquery'), '', true );
}
add_action( 'wp_enqueue_scripts', 'wp_responsivo_scripts' );
/**************************************
* SCRIPTS /MENU BOOTSTRAP
**************************************/
require_once('assets/includes/wp_bootstrap_navwalker.php');
/**************************************
* Registro Custom Post type Slider
**************************************/
add_action('init', 'slider_registrer');
function slider_registrer(){
$labels = array(
'name' => _x('Slider', 'post type general name'),
'singular_name' => _x('Slider', 'post type singular name'),
'add_new' => _x('Adicionar slider', 'slider'),
'add_new_item' => __('Adicionar slider'),
'edit_item' => __('Editar slider'),
'new_item' => __('Novo slider'),
'view_item' => __('Ver slider'),
'search_items' => __('Procurar slider'),
'not_found' => __('Nada encontrado'),
'not_found_in_trash' => __('Nada encontrado no lixo'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-media-code',
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 6,
'supports' => array('title','thumbnail'),
);
register_post_type('slider',$args);
}
/**************************************
* Registro Custom Post type Serviços
* Plugin: Advanced Custom Fields
**************************************/
add_action('init', 'servicos_registrer');
function servicos_registrer(){
$labels = array(
'name' => _x('Serviços', 'post type general name'),
'singular_name' => _x('Serviços', 'post type singular name'),
'add_new' => _x('Adicionar serviço', 'serviço'),
'add_new_item' => __('Adicionar serviço'),
'edit_item' => __('Editar serviço'),
'new_item' => __('Novo serviço'),
'view_item' => __('Ver serviço'),
'search_items' => __('Procurar serviço'),
'not_found' => __('Nada encontrado'),
'not_found_in_trash' => __('Nada encontrado no lixo'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-media-code',
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug'=>'servicos'),
'menu_position' => 6,
'supports' => array('title','thumbnail'),
);
register_post_type('servicos',$args);
}
/**************************************
* Registro de sidebar
**************************************/
if ( function_exists('register_sidebar'))
register_sidebar(array(
'name' => 'Sidebar footer',
'id' => 'sidebar-footer',
'before_widget' => '<div class="col-md-4 col-lg-4">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
/*CHAMADA*/
<?php if ( !function_exists('dynamic_sidebar')
|| !dynamic_sidebar('Sidebar blog')): ?>
<?php endif; ?>
<?php echo FrmFormsController::get_form_shortcode(array('id' => 2, 'key' => '', 'title' => false, 'description' => false, 'readonly' => false, 'entry_id' => false)); ?>
<?php
/**************************************
* Breadcrumbs
**************************************/
function wp_custom_breadcrumbs() {
$showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
$delimiter = '&raquo;'; // delimiter between crumbs
$home = 'Home'; // text for the 'Home' link
$showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
$before = '<span class="current">'; // tag before the current crumb
$after = '</span>'; // tag after the current crumb
global $post;
$homeLink = get_bloginfo('url');
if (is_home() || is_front_page()) {
if ($showOnHome == 1) echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a></div>';
} else {
echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';
if ( is_category() ) {
$thisCat = get_category(get_query_var('cat'), false);
if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' ');
echo $before . 'categoria "' . single_cat_title('', false) . '"' . $after;
} elseif ( is_search() ) {
echo $before . 'Resuldados de busca "' . get_search_query() . '"' . $after;
} elseif ( is_day() ) {
echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
echo $before . get_the_time('d') . $after;
} elseif ( is_month() ) {
echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
echo $before . get_the_time('F') . $after;
} elseif ( is_year() ) {
echo $before . get_the_time('Y') . $after;
} elseif ( is_single() && !is_attachment() ) {
if ( get_post_type() != 'post' ) {
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a>';
if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
} else {
$cat = get_the_category(); $cat = $cat[0];
$cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
if ($showCurrent == 0) $cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats);
echo $cats;
if ($showCurrent == 1) echo $before . get_the_title() . $after;
}
} elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
$post_type = get_post_type_object(get_post_type());
echo $before . $post_type->labels->singular_name . $after;
} elseif ( is_attachment() ) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID); $cat = $cat[0];
echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>';
if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
} elseif ( is_page() && !$post->post_parent ) {
if ($showCurrent == 1) echo $before . get_the_title() . $after;
} elseif ( is_page() && $post->post_parent ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
for ($i = 0; $i < count($breadcrumbs); $i++) {
echo $breadcrumbs[$i];
if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' ';
}
if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
} elseif ( is_tag() ) {
echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
} elseif ( is_author() ) {
global $author;
$userdata = get_userdata($author);
echo $before . 'Articles posted by ' . $userdata->display_name . $after;
} elseif ( is_404() ) {
echo $before . 'Error 404' . $after;
}
if ( get_query_var('paged') ) {
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
echo __('Page') . ' ' . get_query_var('paged');
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
}
echo '</div>';
}
} // end wp_custom_breadcrumbs()
/**
* Use
*/
<?php
$args = array('post_type'=>'servicos', 'showposts'=>3);
$my_servicos = get_posts( $args );
if($my_servicos) : foreach($my_servicos as $post) : setup_postdata( $post );
?>
<div class="col-md-4 col-lg-4">
<i class="<?php the_field('icones'); ?>"></i>
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
</div>
<?php
endforeach;
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment