Need help with PHP code
-
How do I ask for help with some php code on my site?
I used the WP.org support forum last about 8 years ago, and I remember just having to log in, go to the support forum page, and there was a ‘Start New Thread’ link. I think, lol.
Anyway, I have an old site and my Home page (index.php) uses WP_Query stuff, pulling the 1st post in one category on the left column, and the first 2 in the right.
I can’t get it to display the post author’s name (with info link).
Here’s the .index file.
It’s after ‘END OF LEFT COLUMN’ and ‘Videos and Op Ed’ where I want the author link.
Thanks, sorry for posting in the wrong place (if I have).<?php get_header();?> <div id="l-side"> <h2>Today's Headlines</h2> <?php $args = array( 'post_type' => 'post', 'category_name' => 'news', 'posts_per_page' => 1, ); $result = new WP_Query( $args ); $posts = $result->posts; if( !empty( $posts ) ) { foreach( $posts as $post ) { ?> <div <?php post_class();?> id=post-"<?php echo $post->ID;?>"> <h3><a href="<?php echo get_permalink( $post->ID );?>"><?php echo $post->post_title;?></a></h3> <?php echo apply_filters('the_content', $post->post_content);?> <div style="clear:both;"></div> <div class="commentlink"> <?php comments_popup_link('Comment »', '1 Comment »', '% Comments »'); ?></div> <div style="clear:both;"></div> <?php the_tags('<p class="post-tags"><strong>Tags:</strong> ', ', ', '</p>'); ?> <div style="clear:both;"></div> <?php if( is_user_logged_in() ) { $uid = get_current_user_id(); $userdata = get_userdata( $uid ); if( in_array( 'administrator' , $userdata->roles ) ){ edit_post_link( 'Edit', '', '', $post->ID, '' ); } } ?> <?php } } ?> </div> <h5 style="text-align:right; margin:7px 0;"><a title="Browse All News" href="https://rebellionnews.com/category/news"> Browse all News »</a></h5> </div> <!-- END OF LEFT COLUMN --> <div id="r-side"> <h2>Videos and Op Ed</h2> <?php $args = array( 'post_type' => 'post', 'category_name' => 'video', 'posts_per_page' => 2, ); $result = new WP_Query( $args ); $posts = $result->posts; if( !empty( $posts ) ) { foreach( $posts as $post ) { ?> <div <?php post_class();?> id=post-"<?php echo $post->ID;?>"> <h3 style="margin-bottom:0.45rem;"> <a href="<?php echo get_permalink( $post->ID );?>"><?php echo $post->post_title;?></a> </h3> ****************************************************** ***HERE'S WHERE I'M TRYING TO GET THE AUTHOR NAME, AFTER THE DATE:**** ****************************************************** <p style="font-size:70%; line-height:0; text-align:right;"> Posted on <?php the_time('F jS, Y') ?> by <ahref...etc> AUTHOR </a> </p> <?php echo apply_filters('the_content', $post->post_content);?> <div style="clear:both;"></div> <div class="commentlink"> <?php comments_popup_link('Comment »', '1 Comment »', '% Comments »'); ?> </div> <div style="clear:both;"></div> <?php the_tags('<p class="post-tags"><strong>Tags:</strong> ', ', ', '</p>'); ?> <div style="clear:both;"></div> <?php if( is_user_logged_in() ) { $uid = get_current_user_id(); $userdata = get_userdata( $uid ); if( in_array( 'administrator' , $userdata->roles ) ){ edit_post_link( 'Edit', '', '', $post->ID, '' ); } } ?> <?php } } ?> </div> <h5 style="text-align:right; margin:7px 0;"><a title="Browse All Videos" href="https://rebellionnews.com/category/video"> Browse all Videos »</a></h5> <div class="custom-hr"></div> <div style="clear:both;"></div> <?php the_tags('<p class="post-tags"><strong>Tags:</strong> ', ', ', '</p>'); ?> <div style="clear:both;"></div> </div> <div style="clear:both;"></div> </div><!-- END OF RIGHT COLUMN --> <div style="clear:both;"></div> <?php get_footer(); ?>
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Need help with PHP code’ is closed to new replies.