Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » How do I…?
  3. » Meta tags

#1 2007-07-02 13:25:19

beechy
Member
Registered: 2006-03-02
Posts: 92

Meta tags

I am currently using the following code for my keywords and meta description:

<txp:if_individual_article>
<meta name=“keywords” content=”<txp:keywords />” />
<meta name=“description” content=”<txp:custom_field name=“meta_description” />” />

<meta name=“author” content=”<txp:author />” />
<txp:else />
<meta name=“description” content=“default description” />
</txp:if_individual_article>

I have created a custom field for the description of each artilce.

This works fine for all my live articles, however I also have static articles using “sticky” with these page the meta description is always the default description.

How do I get my custom field to display in the static, sticky articles as well

Offline

#2 2007-07-02 13:55:04

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Re: Meta tags

This is what I do. I’m assuming you’re using sticky articles as the section landing page.

<txp:if_individual_article>
<txp:article form="metadata" />
<txp:else />
<txp:article limit="1" status="sticky" form="metadata" />
</txp:if_individual_article>

Then the article form metadata contains this…

<txp:if_custom_field name="meta_description">
<meta name="keywords" content="<txp:keywords />" />
<meta name="description" content="<txp:custom_field name="meta_description" />" />
<txp:else />
<meta name="keywords" content="default keywords" />
<meta name="description" content="default description" />
</txp:if_custom_field>

Last edited by FireFusion (2007-07-02 14:08:28)

Offline

#3 2007-07-02 14:03:15

beechy
Member
Registered: 2006-03-02
Posts: 92

Re: Meta tags

FireFusion thanks for the reply, could you expand on the description of your solution a little more, I dont quite follow at the moment.

Offline

#4 2007-07-02 14:13:18

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Re: Meta tags

I’ve expanded my above post. The important bit is that solution works only if sticky pages are the default pages you see on article lists.

You could also to it like this if you aren’t using sticky in that way…

<txp:if_individual_article>
<txp:article limit="1" status="sticky" form="metadata" />
<txp:article form="metadata" />

<txp:else />

<meta name="keywords" content="default keywords" />
<meta name="description" content="default description" />
</txp:if_individual_article>

Since the article tags is sensitive to the URL it will only output content if the conditions are right. You can use more then one article tag in the same page to breakup bits of your content.

Last edited by FireFusion (2007-07-02 14:15:18)

Offline

  1. Index
  2. » How do I…?
  3. » Meta tags

Board footer

Powered by FluxBB