Jump to content
selected

Generare excerpt pana la un anumit keyword

Recommended Posts

Posted

Sa zicem ca am postul de genu:

imagine1

text

imagine2

keyword1 keyword2 bla bla(sub forma de text)

Cum pot face ca excerpt-ul sa fie format doar din:

imagine1

text

imagine2

Adica sa se opreasca inainte de keyword1 !? Stie cineva vreo functie ?

Wordpress !!

Posted

Stiu ca exista asa ceva dar am zis sa intreb...

function modified_excerpt_length($length) {

return 40;

}

add_filter('excerpt_length', 'modified_excerpt_length');

Functia asta limiteaza excerpt-ul la 40 de caractere.

Cine se pricepe la coding si ma poate ajuta ? :-S

LE:

function excerpt($limit) {

$excerpt = explode(' ', get_the_excerpt(), $limit);

if (count($excerpt)>=$limit) {

array_pop($excerpt);

$excerpt = implode(" ",$excerpt).'...';

} else {

$excerpt = implode(" ",$excerpt);

}

$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);

return $excerpt;

}

function content($limit) {

$content = explode(' ', get_the_content(), $limit);

if (count($content)>=$limit) {

array_pop($content);

$content = implode(" ",$content).'...';

} else {

$content = implode(" ",$content);

}

$content = preg_replace('/\[.+\]/','', $content);

$content = apply_filters('the_content', $content);

$content = str_replace(']]>', ']]>', $content);

return $content;

}

Cred ca asta ajuta mai tare... Va rog ! ^<img src=^'>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...