Dynamic H1 Header - How?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
BankNegotiator
Forum Newbie
Posts: 1
Joined: Sat Feb 07, 2009 10:22 am

Dynamic H1 Header - How?

Post by BankNegotiator »

I'm having a problem getting my Wordpress blog to generate a dynamic h1 header where I want it to.

Please Take a look at this screenshot: http://screencast.com/t/WtSrEOr8P

This cap of SEOZombie.com shows how the site owner is creating a dynamic H1 tag for his various blog posts/pages.

I'd like to have a similar setup on my blog. Here is a screencap: http://screencast.com/t/vx7TvT4xY

My idea is to put whatever targeted keywords for that page in a custom field entitled 'dynamich1" upon posting to the blog. From there I'd like to have a php call that checks to see if the "dynamich1" variable is there. If it is, it includes it there and wraps it in an h1 tag. If it is NOT there it pulls the post title and wraps it in an h1 instead.

So basically all I want this thing to do is "Check and see if there is a custom field named "dynamich1". If there IS, then diplay that here. If not, then display the post title here."

I don't know very much php and can only swipe bits and pieces from other themes to try to make it work. Here is what I tried to put in there, if no "dynamich1" was included in the post custom fields, it did properly display the blog title. But if that custom field WAS included, nothing showed.

I feel like I'm close, and that it's probably a small tweek? Possibly? Maybe. I hope.

Here's the code snippet I used:

Code: Select all

<?php if( get_post_meta($post->ID, "dynamich1", true) ): ?>
<h1 align="right"><a href="<?php echo get_post_meta($post->ID, "dynamich1", true); ?>/"></h1>
<?php else: ?>
<h1 align="right"><a href="<?php bloginfo('url'); ?>/"><?php bloginfo('name'); ?></a></h1>
<?php endif; ?>
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Dynamic H1 Header - How?

Post by JAB Creations »

1.) Wrong forum.

2.) There is no such thing as a "tag", they are called elements.

3.) WordPress code is like MySpace code, any self-respecting web programmer doesn't even consider it code.

4.) WordPress has it's own forums, did you try there?

5.) Lastly I recommend the following...

Code: Select all

<h2><?php the_title(); ?></h2>
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: Dynamic H1 Header - How?

Post by kaszu »

Correction: there is "tag" (search this for "tag", or how about getElementsByTagName?), while I agree that he was talking about elements.
Post Reply