Forums

[resolved] Getting the three recently "CustomField-tagged" pages? (4 posts)

  1. mowila
    Member
    Posted 2 years ago #

    Hello!

    I am currently working on a portfolio. It is based on pages being each of the projects I am working on (with posts linked to this page, as sub-articles).

    On the front page I want to show three projects/pages that I am currently working on.

    I can't think of a way of doing this, so if anyone has an idea please help me.

    As I am thinking it right now I would like to be able to add i value to a custom field on a page (no matter when it was originally created).
    Then when assigned a value it will appear on the frontpage, regardless of newer pages.

    Do you follow?
    Hopefully some of you do, so you can help me :)

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    As I am thinking it right now I would like to be able to add i value to a custom field on a page (no matter when it was originally created).
    Then when assigned a value it will appear on the frontpage, regardless of newer pages.

    When you say "a page" do you mean a Page or a post?

  3. MichaelH
    Volunteer
    Posted 2 years ago #

    Forget that last question, just change $type to be what you want:

    <?php
    $type = 'post'; //or 'page'
        $args=array(
          'post_type' => $type,
          'meta_key'=> 'your_key',
          'meta_value' => 'your_value_here',
          'showposts'=>5,
          'caller_get_posts'=>1
        );
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo '5 recent ' . $type . '(s)';
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <?php
          the_content();
          endwhile;
        } //if ($my_query)
      wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy
    the_content()
    the_excerpt()
    query_posts()

  4. mowila
    Member
    Posted 2 years ago #

    Thank you very much.
    It was exactly what I needed

Topic Closed

This topic has been closed to new replies.

About this Topic