WordPress.org

Support

Support » How-To and Troubleshooting » Page Shortcode

Page Shortcode

  • I would like to produce a ToC for my blog, where are the guidelines hiding? I can find general guidelines, and the article an the shortcode API, but nothing on the page shortcode. Or has that particular short code been depracated?

Viewing 1 replies (of 1 total)
  • Not sure what you are asking so this will list all pages and then all posts

    <?php
    $types[0] = 'page';
    $types[1] = 'post';
    
    foreach ($types as $type) {
      $args=array(
        'post_type' => $type,
        'post_status' => 'publish',
        'showposts' => -1,
        'caller_get_posts'=> 1
        );
      $my_query = null;
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        echo 'List of: ' . $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
        endwhile;
      } //if ($my_query)
    } // foreach
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Page Shortcode’ is closed to new replies.
Skip to toolbar