Last active
December 18, 2015 16:16
-
-
Save ondoheer/88c13fd5d943dbebf94b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Función para convertir el custom_field('xx') en un excerpt de 50 palabras máximo | |
function get_athelas_custom_field_excerpt($title, $chars) { | |
global $post; | |
$text = get_field($title); | |
if ( '' != $text ) { | |
$text = strip_shortcodes( $text ); | |
$text = apply_filters('the_content', $text); | |
$text = str_replace(']]>', ']]>', $text); | |
$excerpt_length = $chars; // in words | |
$excerpt_more = apply_filters('excerpt_more', ' ' . '...'); | |
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); | |
} | |
return apply_filters('the_excerpt', $text); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// featured image activation and then sizing | |
add_action( 'init', 'athelas_image_support' ); | |
function athelas_image_support(){ | |
add_theme_support( 'post-thumbnails' ); | |
// Just add an image name, the width, the height, and a boolean that defines if WP should crop the images or not | |
// add as many as the project might require | |
// smaller images do not get resized, but largeones will get cropped. | |
// name width height crop? | |
add_image_size( 'image_size_name', 400, 400, true); | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
//Type & Status Parameters | |
'post_type' => array('posttype'), //change thisone to your cpt-slug | |
); | |
$query = new WP_Query( $args ); | |
?> | |
<?php if($query->have_posts()): ?> | |
<?php while($query->have_posts()): $query->the_post(); ?> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
<?php wp_reset_postdata(); ?> | |
<!-- End of loop --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if(have_posts()): ?> | |
<?php while(have_posts()): the_post(); ?> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
<?php wp_reset_postdata(); ?> | |
<!-- End of loop --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', 'athelas_register_product' ); | |
function athelas_register_product() { | |
$labels = array( | |
"name" => "Products", | |
"singular_name" => "Product", | |
"menu_name" => "Products", | |
"all_items" => "All Products", | |
"add_new" => "Add new", | |
"add_new_item" => "Add new Product", | |
"edit" => "Editar", | |
"edit_item" => "Edit Product", | |
"new_item" => "New Product", | |
"view" => "view", | |
"view_item" => "See Product", | |
"search_items" => "Search Products", | |
"not_found" => "Products not found", | |
"not_found_in_trash" => "Products not found in the trash", | |
); | |
$args = array( | |
"labels" => $labels, | |
"description" => "Post type Products", | |
'taxonomies' => array('category_products'), | |
"public" => true, | |
"show_ui" => true, | |
"has_archive" => true, | |
"show_in_menu" => true, | |
"exclude_from_search" => false, | |
"capability_type" => "post", | |
"map_meta_cap" => true, | |
"hierarchical" => false, | |
"rewrite" => array( "slug" => "product", "with_front" => true ), | |
"query_var" => true, | |
"supports" => array( 'title', 'editor','post_tags' ), | |
); | |
register_post_type( "products", $args ); | |
}// End of athelas_register_product() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment