Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Meta descriptions in articles

Asked Modified Viewed 1,198 times
Z
zimi27
Z
zimi27 10
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 8 threads in the forums
  • Started this discussions
asked
Junior Member

In php-fusion 7, I had a mod that took the first 150 words of an article and put them in the meta descriptions:

add to render_article in theme.php
replace_in_output("<title>(.*?)</title>(.*?)<meta name='description' content='(.*?)' />(.*?)<meta name='keywords' content='(.*?)' />","<title>$subject</title>$2<meta name='description' content='".substr(strip_tags($article),0,150)."' />$4<meta name='keywords' content='$subject' />","si");


Unfortunately, in PF8 all the descriptions in the articles are identical and this mod does not work. Could it be blocked by another seo mod?
Edited by zimi27 on 25-02-2022 19:10,
0 replies

4 posts

R
Anonymous User
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
answered
Veteran Member

Use set_meta().

This function is here since v7 so idk why author of mod used replace_in_output.. Is much better to use set_meta() because you don't need to know regex.
0 replies
Z
zimi27
Z
zimi27 10
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 8 threads in the forums
  • Started this discussions
answered
Junior Member

@RobiNN I see you know it.
Can you give the code what it should look like? I don't know much about programming.
0 replies
R
Anonymous User
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
answered
Veteran Member

Ah..

Basically only this you need set_meta('description', substr(strip_tags($article),0,150));. No need to change title.
0 replies
Z
zimi27
Z
zimi27 10
  • Junior Member, joined since
  • Contributed 18 posts on the community forums.
  • Started 8 threads in the forums
  • Started this discussions
answered
Junior Member

It works! grin thank you
0 replies

Category Forum

SEO & SEF - 8

Labels

None yet

Statistics

  • Views 0 views
  • Posts 4 posts
  • Votes 0 votes
  • Topic users 2 members

0 participants

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet