• Resolved Steven

    (@spstieng)


    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?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Steven

    (@spstieng)

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

    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: https://codex.www.ads-software.com/Using_Custom_Fields#Advanced_Techniques_for_Custom_Fields

    Thread Starter Steven

    (@spstieng)

    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.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    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:
    https://codex.www.ads-software.com/Template_Tags

    Thread Starter Steven

    (@spstieng)

    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 '';
    	?>
    (...)

    Thread Starter Steven

    (@spstieng)

    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 ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to display current page information’ is closed to new replies.