Aca te coloco el codigo completo del archivo:
Código PHP:
<?php
/**
* This is your child theme's functions.php file.
* You should make edits and add additional code above this point.
* Only change the functions below if you know what you're doing.
*/
/********************************************************/
/*
* Constant paths
*/
define( HYBRID_NEWS, get_stylesheet_directory() );
define( HYBRID_NEWS_URL, get_stylesheet_directory_uri() );
/*
* For localization
*/
load_theme_textdomain( 'news', HYBRID_NEWS );
/*
* Hybrid News theme settings
*/
$news_settings = get_option( 'hybrid_news_theme_settings' );
/*
* Include admin files
*/
if ( is_admin() )
require_once( HYBRID_NEWS . '/library/admin/theme-settings.php' );
/*
* Actions
*/
add_action( 'hybrid_head', 'news_front_page_template' );
add_action( 'wp_head', 'news_remove_actions' );
add_action( 'hybrid_before_header', 'hybrid_page_nav' );
/*
*add_action( 'hybrid_after_page_nav', 'hybrid_search_form' );*/
add_action( 'hybrid_header', 'news_get_header_widget', 11 );
add_action( 'hybrid_after_header', 'hybrid_cat_nav' );
add_action( 'hybrid_after_container', 'news_widget_container', 11 );
/* add_action( 'hybrid_after_single','news_author_box' );*/
add_action( 'widgets_init', 'news_register_widget_areas' );
/*
* Filters
*/
add_filter( 'wp_page_menu_args', 'news_page_menu_args' );
add_filter( 'hybrid_category_menu_args', 'news_category_menu_args' );
add_filter( 'hybrid_post_meta_boxes', 'news_post_meta_boxes' );
/**
* Removes default Hybrid theme actions
*
* @since 0.1
*/
function news_remove_actions() {
remove_action( 'hybrid_after_header', 'hybrid_page_nav' );
remove_action( 'hybrid_after_container', 'hybrid_get_primary' );
remove_action( 'hybrid_after_container', 'hybrid_get_secondary' );
}
/**
* Page menu
* Add/remove arguments for your page menu
*
* @since 0.1.1
*/
function news_page_menu_args( $args ) {
$args['depth'] = 4;
return $args;
}
/**
* Category menu
* Add/remove arguments for your category menu
*
* @since 0.1
*/
function news_category_menu_args( $args ) {
$args = array(
'depth' => 4,
);
return $args;
}
/**
* Register additional widget areas
*
* @since 0.1.1
*/
function news_register_widget_areas() {
register_sidebar( array( 'name' => __('Tertiary', 'news'), 'id' => 'tertiary', 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) );
register_sidebar( array( 'name' => __('Utility: Header', 'news'), 'id' => 'utilityheader', 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) );
}
/**
* Adds JavaScript and CSS to Front Page page template
* Also removes the breadcrumb menu
*
* @since 0.1
*/
function news_front_page_template() {
if ( is_page_template( 'front-page.php' ) ) :
wp_enqueue_script( 'slider', HYBRID_NEWS_URL . '/library/js/jquery.cycle.js', array( 'jquery' ), 0.1 );
wp_enqueue_script( 'slider-functions', HYBRID_NEWS_URL . '/library/js/jquery.functions.js', array( 'jquery' ), 0.1 );
wp_enqueue_style( 'front-page', HYBRID_NEWS_URL . '/front-page.css', false, '0.1', 'screen' );
remove_action( 'hybrid_before_content', 'hybrid_breadcrumb' );
endif;
}
/**
* Adds a feed/subscribe link to the category menu
*
* @since 0.1
*/
function news_subscribe_link() {
echo '<div id="feed"><ul>';
echo '<li class="feed-url"><a href="' . get_bloginfo( 'rss2_url' ) . '" title="' . __('Subscribe to the feed','news') . '">' . __('Subscribe','news') . '</a></li>';
echo '</ul></div>';
}
/**
* Displays the Utility: Header widget section
*
* @since 0.1
*/
function news_get_header_widget() {
if ( is_sidebar_active( __('Utility: Header', 'news') ) ) :
echo '<div id="utility-header" class="utility">';
dynamic_sidebar( __('Utility: Header', 'news') );
echo '</div>';
endif;
}
/**
* Wraps the Primary, Secondary, and Tertiary widget sections
* Calls each section
*
* @since 0.1
*/
function news_widget_container() {
if ( !is_page_template( 'no-widgets.php' ) ) :
echo '<div id="widget-container">';
hybrid_get_primary();
hybrid_get_secondary();
news_get_tertiary();
echo '</div>';
endif;
}
/**
* Displays the Tertiary widget section
*
* @since 0.1
*/
function news_get_tertiary() {
if ( is_sidebar_active( __('Tertiary', 'news') ) ) :
echo '<div id="tertiary">';
dynamic_sidebar( __('Tertiary', 'news') );
echo '</div>';
endif;
}
/**
* Shows an author description after the post
* Only shows on single post
*
* @since 0.1
*/
function news_author_box() {
global $hybrid_settings;
?>
<div class="author-profile vcard">
<?php echo get_avatar( get_the_author_email(), '96', $hybrid_settings['default_avatar'] ); ?>
<h4 class="author-name fn n"><?php the_author_posts_link(); ?></h4>
<p class="author-description author-bio">
<?php the_author_description(); ?>
</p>
</div>
<?php
}
/**
* Add additional post meta boxes
* - Feature image input box
*
* @since 0.1
*/
function news_post_meta_boxes( $meta_boxes ) {
$meta_boxes['medium'] = array(
'name' => 'Medium',
'default' => '',
'title' => __('Medium/Feature:', 'news'),
'type' => 'text',
'show_description' => false,
'description' => false,
);
return $meta_boxes;
}
?>
<?php
$title = get_the_title() //Guardas el título en una variable
$largo = srtlen($titulo); //Guardas el numero de caracteres de tu titulo
$palabras = ($largo <= 50)?(300):(200); //Si el titulo tiene menos de 50 caracteres (o igual) $palabras sera igual a 300, sino igual a 200
?>