• Resolved tsalagi

    (@tsalagi)


    I can’t determine what is causing this issue. Maybe someone has experienced it before.

    When I use
    <?php the_title(); ?>
    My list of pages has to correct title and author info when I use this
    <a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'Modern Scribe'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a>
    All of the titles are “Home”.
    I’d like my output to be links to the pages.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Are you using that code in a correct loop? Please paste all the code from the theme template file that is displaying those posts into a pastebin such as wordpress.pastebin.ca, and report the link back here. Maybe someone can spot your problem. Thanks.

    Thread Starter tsalagi

    (@tsalagi)

    Thanks. Here is the only loop on the page.

    <?php
    				$pub_posts = $wpdb->get_results("SELECT post_title, post_author, post_status, post_type, post_date FROM $wpdb->posts WHERE post_type = 'page' LIMIT 5");
    				foreach($pub_posts as $post) {
    					setup_postdata($post);
    			?>
    			<?php while ( have_posts() ) : the_post() ?>
    							<ul class="info_list">
    								<li><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'Test Template'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a><li>
    								<li class="auth"><span class="author vcard"><a class="url fn n" href="<?php echo get_author_link( false, $authordata->ID, $authordata->user_nicename ); ?>" title="<?php printf( __( 'View all articles by %s', 'Test Template' ), $authordata->display_name ); ?>"><?php the_author(); ?></a></span></li>
    								<li class="date"><span class="entry-date"><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time( get_option( 'date_format' ) ); ?></abbr></span></li>
    								<li class="edit_link"><?php edit_post_link( __( 'Edit', 'template_test' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t" ) ?></li>
    							</ul>
    				<?php endwhile; ?>
    			<?php } ?>

    Display first 5 pages:

    <?php
        $args=array(
          'post_type' => 'page',
          'post_status' => 'publish',
          'posts_per_page' => 5,
          'caller_get_posts'=> 1
          );
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <ul class="info_list">
            <li><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'Test Template'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a><li>
            <li class="auth"><span class="author vcard"><a class="url fn n" href="<?php echo get_author_link( false, $authordata->ID, $authordata->user_nicename ); ?>" title="<?php printf( __( 'View all articles by %s', 'Test Template' ), $authordata->display_name ); ?>"><?php the_author(); ?></a></span></li>
            <li class="date"><span class="entry-date"><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time( get_option( 'date_format' ) ); ?></abbr></span></li>
            <li class="edit_link"><?php edit_post_link( __( 'Edit', 'template_test' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t" ) ?></li>
            </ul>
          <?php  endwhile;
        }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Thread Starter tsalagi

    (@tsalagi)

    Thanks much Michael. Two things if you don’t mind. What does the caller_get_posts do? I can find little in the way of explanation in the codex.
    Also, I thought I knew how to add a specific author in that group of arguments
    'post_author' => author_number
    that doesn’t work as it does in `$wpdb’ but ‘author’ does. Why the inconsistency in WordPress?
    Thanks again.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Links to pages not working’ is closed to new replies.