diff --git a/assets/js/main.js b/assets/js/main.js index aaad63d..d823c35 100755 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -180,7 +180,8 @@ jQuery(document).ready(function($) { $('.btn-loadmore').on('click',function(e){ var data = { 'action': 'midia_load_posts', - 'paged': $(this).attr('data-paged') + 'paged': $(this).attr('data-paged'), + 'category': $(this).attr('data-category') }; var default_html = $(this).html(); $(this).html($(this).attr('data-loading')); @@ -197,6 +198,37 @@ jQuery(document).ready(function($) { } }); - }) + }); + $('.btn-ajax-categoria').on('click',function(e){ + var data = { + 'action': 'midia_load_category', + 'category': $(this).attr('data-category') + }; + console.log(data); + var elem = this; + $('.btn-ajax-categoria.active').removeClass('active'); + $('.btn-loadmore').show(); + $.ajax({ + type: 'POST', + url: odin_main.ajaxurl, + data: data, + dataType: 'json', + complete: function(response){ + var obj = $.parseJSON(response.responseText); + var selector = $('.btn-loadmore').attr('data-selector'); + $(elem).addClass('active'); + $('.btn-loadmore').attr('data-max-paged',obj.max_paged); + $('.btn-loadmore').attr('data-paged',2); + $('.btn-loadmore').attr('data-category',$(elem).attr('data-category')); + var paged = parseInt($('.btn-loadmore').attr('data-paged')); + var max_paged = parseInt($('.btn-loadmore').attr('data-max-paged')); + if(paged > max_paged){ + $('.btn-loadmore').fadeOut('slow'); + } + $(selector).html(obj.html); + }, + }); + }); + }); diff --git a/inc/custom-post.php b/inc/custom-post.php index be431e7..92ceefe 100644 --- a/inc/custom-post.php +++ b/inc/custom-post.php @@ -242,4 +242,45 @@ function disco_cpt() { register_post_type( 'disco', $args ); } - ///////////////////////////////////////// \ No newline at end of file + ///////////////////////////////////////// +if ( ! function_exists( 'custom_tax_categoria' ) ) { + +// Register Custom Taxonomy +function custom_tax_categoria() { + + $labels = array( + 'name' => _x( 'Categorias', 'Taxonomy General Name', 'odin' ), + 'singular_name' => _x( 'Categoria', 'Taxonomy Singular Name', 'odin' ), + 'menu_name' => __( 'Categorias', 'odin' ), + 'all_items' => __( 'Todas Categorias', 'odin' ), + 'parent_item' => __( 'Categoria Parente', 'odin' ), + 'parent_item_colon' => __( 'Categoria Parente:', 'odin' ), + 'new_item_name' => __( 'Adicionar nova Categoria', 'odin' ), + 'add_new_item' => __( 'Adicionar nova Categoria', 'odin' ), + 'edit_item' => __( 'Editar categoria', 'odin' ), + 'update_item' => __( 'Atualizar categoria', 'odin' ), + 'view_item' => __( 'Ver Categoria', 'odin' ), + 'separate_items_with_commas' => __( 'Categorias separadas por virgula', 'odin' ), + 'add_or_remove_items' => __( 'Adicionar ou remover categorias', 'odin' ), + 'choose_from_most_used' => __( 'Escolha pelos mais usados', 'odin' ), + 'popular_items' => __( 'Categorias populares', 'odin' ), + 'search_items' => __( 'Buscar Categoria', 'odin' ), + 'not_found' => __( 'Não encontrado', 'odin' ), + ); + $args = array( + 'labels' => $labels, + 'hierarchical' => true, + 'public' => true, + 'show_ui' => true, + 'show_admin_column' => true, + 'show_in_nav_menus' => true, + 'show_tagcloud' => true, + ); + register_taxonomy( 'categoria', array( 'midia' ), $args ); + +} + +// Hook into the 'init' action +add_action( 'init', 'custom_tax_categoria', 0 ); + +} \ No newline at end of file diff --git a/inc/shortcodes.php b/inc/shortcodes.php index d161dea..f3a6634 100644 --- a/inc/shortcodes.php +++ b/inc/shortcodes.php @@ -12,7 +12,8 @@ function short_query_func( $atts ) { $a = shortcode_atts( array( 'post_type' => 'flauta', - 'paged' => get_query_var( 'paged', 1 ) + 'paged' => get_query_var( 'paged', 1 ), + 'category' => false ), $atts ); switch ($a['post_type']) { case 'flauta': @@ -25,15 +26,32 @@ function short_query_func( $atts ) { case 'projeto': $per_page= '99999'; $thumb='thumb-projeto'; - $class_container = "col-sm-8"; - - + $class_container = "col-sm-8"; break; case 'midia': $per_page= '3'; $thumb='thumb-midia'; $class_item = 'col-sm-4'; $class_container = "row"; + if(!defined('DOING_AJAX')){ + $antes_interno = '