WordPress.org

Ready to get started?Download WordPress

Forums

Description and Keywords: personalized and without plugin (2 posts)

  1. newboxters
    Member
    Posted 5 years ago #

    I already tested the plugin All in One SEO Pack, but now I need something more specific and advanced.

    Current code (that needs of corrections)

    function limit_the_content($excerpt_length = 55, $resume = 'more »', $resume_link = true) {
    global $post;
    if($resume_link)
    $resume = '<a href="'.get_permalink().'" title="'.$resume.'">'.$resume.'</a>';
    $text = get_the_content('');
    $text = apply_filters('the_content', $text);
    $text = str_replace(']]>', ']]>', $text);
    $text = strip_tags($text);
    $words = explode(' ', $text, $excerpt_length + 1);
    if (count($words) > $excerpt_length) {
    array_pop($words);
    array_push($words, $resume);
    $text = implode(' ', $words);
    }
    echo $text;
    }
    
    if (is_category()) {
    	$description = category_description();
    	$keywords = get_category_parents($cat, false, ', ');
    	//Description ok, but keyword: " key1, key2,"
    	//as to remove the last comma (" key1, key2 ")?
    } elseif (is_single() || is_page()) {
    	if (the_excerpt() == "") { $description = limit_the_content(15, '...', false); }
    	//the_excerpt() == "" - is the verification correct?
    
    	else { $description = the_excerpt(); }
    
    	if (get_the_tags()) { $keywords = the_tags(); }
    	else { $keywords = single_cat_title("", false); }
    } else {
    	$description = "simple description (home)";
    	$keywords = "key1, key2, other simple keywords (home)";
    }

    I would like a help for improving that code, including the comments and questions that I did.

  2. newboxters
    Member
    Posted 5 years ago #

    Any suggestion?

Topic Closed

This topic has been closed to new replies.

About this Topic