Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-10-30 18:29:02

Manaus
Member
From: Turin, Italy
Registered: 2010-10-22
Posts: 252
Website

Dynamic display of meta

Hello, I’m trying to generate the meta tags with this code:

<!-- meta -->
<txp:article limit="1">
	<txp:if_custom_field name="meta_description">
		<meta name="description" content="<txp:custom_field name='meta_description' />" />
	<txp:else />
		<meta name="description" content="Lorem ipsum dolor sit amet" />
	</txp:if_custom_field>

	<!-- keywords -->
	<txp:if_keywords>
		<txp:meta_keywords />
	<txp:else />
		<meta name="keywords" content="One, two, three, four" />
	</txp:if_keywords>
</txp:article>

But on the homepage I get a double copy of the article body itself, one below the other.

Thanks for any suggestion

Offline

#2 2012-10-30 18:50:56

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,172
Website GitHub Mastodon Twitter

Re: Dynamic display of meta

You could try

<!-- meta -->
<txp:article_custom limit="1">
	<txp:if_custom_field name="meta_description">
		<meta name="description" content="<txp:custom_field name="meta_description" />" />
	<txp:else />
		<meta name="description" content="Lorem ipsum dolor sit amet" />
	</txp:if_custom_field>
	<!-- keywords -->
	<txp:if_keywords>
		<txp:meta_keywords />
	<txp:else />
		<meta name="keywords" content="One, two, three, four" />
	</txp:if_keywords>
</txp:article_custom>

note that you also have double quotes where there should be single ones. I corrected them in the above code.

You have single quotes where there should be double ones:) – corrected my code too.

Last edited by colak (2012-10-30 18:54:27)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB