Forums

[resolved] How to display current page information (7 posts)

  1. spstieng
    Member
    Posted 3 years ago #

    I'm using WP as a CMS where a page is a template and posts are "articles".

    I have a page (template) that displays a list of posts within a specific category. No sweat.

    Now I want to display some general information before the post list. Something like:

    "This is a list over the hottest designers in Norway. If you are not on the list, and you should be, let me know".

    {Then the list starts}

    The page has the following attributes: Title, Page, custom-fields and so on.

    I would like to display the page TITLE and the PAGE information.
    Looking at page.php they use the following code:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      	<?php the_content; ?>
      	<?php endwhile; endif; ?>

    This however does not display the information in the Page attribute.

    Any suggestions anyone?

  2. spstieng
    Member
    Posted 3 years ago #

    Ok, so wp_title('') will get me the name of the page.
    What about the page description? How can I output that?

  3. VelvetBlues.com
    Member
    Posted 3 years ago #

    Do you mean page excerpt or are you using a custom field and naming it description?

    If you want to retrieve the excerpt, you can just use the_excerpt().

    However, if custom fields, check out this documentation: http://codex.wordpress.org/Using_Custom_Fields#Advanced_Techniques_for_Custom_Fields

  4. spstieng
    Member
    Posted 3 years ago #

    No, it's not the Excerpt.
    It's the field just below the Title field on a page.

    Getting stuff from the custom fields is easy.

  5. Otto
    Tech Ninja
    Posted 3 years ago #

    It's the field just below the Title field on a page.

    ... Do you mean the actual post content itself? That would be the_content(). Also, the_title() is probably what you wanted before.

    The empty parentheses matter. Don't put '' in them.

    Read this:
    http://codex.wordpress.org/Template_Tags

  6. spstieng
    Member
    Posted 3 years ago #

    I use the following code:

    <?php
    /*
    Template Name: Artist List
    */
    ?>
    <?php get_header(); ?>
    
    <div id="content">
    	<div class="spacer20px"></div>
    
      <?php
      		wp_title(''); echo '';
    			the_content(); echo '';
    			the_ID(); echo '';
    	?>
    (...)
  7. spstieng
    Member
    Posted 3 years ago #

    I got it working!

    <?php
      if (have_posts()): while (have_posts()): the_post();
      	wp_title(''); echo '<br />';
    	the_content(); echo '<br />';
      endwhile; endif;
    ?>

    One of the first things I tried was using The Loop. But it didn't work.
    Does this mean a Page is also considered as a post by the system?

    Well, it works and I'm good to go :-D

Topic Closed

This topic has been closed to new replies.

About this Topic