Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I add in a post the words "No content available" if nothing is ritten

Example:
If there is no text added, i want to get "No content available" automated in my template. I want to get for a specific Post Type, Seriale.

How can I make that?

In the template i have this

<?php 
    if (is_search()) 
        the_excerpt(); 
    else 
        the_content(__('Read the rest of this entry &raquo;')); ?>
<?php 
    if (is_page() or is_single()) 
        wp_link_pages(array(
            'before' => '<p><strong>Pages:</strong> ', 
            'after' => '</p>', 'next_or_number' => 'number'
        )); 
?>
share|improve this question
    
Have you searched before asking? Also, what this code has to do with "No content"? What template is this? :::: Please, don't answer in the comments, update your Question: edit –  brasofilo Mar 7 '13 at 12:27
add comment

1 Answer 1

add_filter( 'the_content', 'check_empty_postcontent', 0, 99 ); // filter post content
add_filter( 'the_excerpt', 'check_empty_postcontent', 0, 99 ); // filter excerpt content

function check_empty_postcontent( $content ) {

    global $post;

    $post_type = get_post_type( $post->ID );

    return ( empty( $content ) && 'seriale' === strtolower( $post_type ) ) ?
        'No content available' : $content;

}

There are a lot of articles about that in the web.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.