WordPress.org

Ready to get started?Download WordPress

Forums

Meta Data Into Custom Page Template? (3 posts)

  1. RKCastillo
    Member
    Posted 2 years ago #

    I added a custom page template to use as a page on my site.

    I basically just took out the get header and footer from the main page template.

    This is what I'm using as the custom page template:

    <?php
    /**
    Template Name: Opt In
    */
    
    ?>
    
    <!-- mid content --><div id="mid-content">  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>    <div id="post-<?php the_ID(); ?>" <?php if (function_exists("post_class")) post_class(); else print 'class="post"'; ?>>        <p class="right edit-post"><?php edit_post_link(__('Edit','fusion')); ?></p>     <div class="clear"></div>     <div class="entry clearfix">      <?php the_content(__('Read the rest of this page &raquo;', 'fusion')); ?>      <?php wp_link_pages(array('before' => '<p class="postpages"><strong>'.__("Pages:","fusion").'</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>     </div>    </div>   <?php endwhile; endif; ?>   <?php comments_template(); ?></div><!-- mid content --></div><!-- /mid -->

    But it isn't pulling in the meta data to get the page title & description.

    What do I need to add to the template code to get the meta data for this page?

  2. van-knowmad
    Member
    Posted 2 years ago #

    Inside your while (have_posts()) : loop, you should be able to use the_title() and the_content to print the title and content, or prefix those two functions with get_ if you need to assign them to a variable.

    (You should be able to use the existing get_header function for a custom page template, to write the HTML <head> element with the page's title, but that depends on your theme.)

    Hope some of this helps.

  3. RKCastillo
    Member
    Posted 2 years ago #

    Would you mind writing out the code? I don't really know php.

    I am using the wordpress seo plugin by Yoast for the meta title and description.

    So I want to just pull in that info for this page template.

Topic Closed

This topic has been closed to new replies.

About this Topic