add date to go after title
-
First of all, this plugin is great! I used to have 5 random posts hard-coded onto my sidebar. But this coding now produces 5 identical posts. I really like that the post dates can be added. But I couldn’t quite figure out what CSS to change to put the date inline with the title.
I would like to display the titles only and put their post dates after each anchor tag, like this: title of random post, date
Knowing only enough about PHP to get myself in trouble, I tried the following in my theme’s functions.php. I don’t know why I was surprised that it threw a blank page. Clearly, I have added incorrect coding.
/*............... vi random posts add date after anchor tag for post title ...............*/ add_filter('virp_get_random_posts', 'virp_add_date-to-titlespec'); function virp_add_date-to-titlespec($virp-add_date) { $html .= '<a class="virp-title" href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( '%s', 'virp' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">' . esc_attr( get_the_title() ) . '</a>, ' . esc_attr(get_the_date(l, j F Y)); return $virp-add_date; }
Thank you for any help you can offer
E Morris, etherwork [dot] net [slash] blog « purposely unlinked in attempt to keep spammers at bay
Here is the coding (gleaned from the codex) that was on my sidebar and no longer works:
<!-- start random post links --> <h2><?php _e('5 randomly chosen posts:'); ?></h2> <ul> <?php $args = array( 'posts_per_page' => 5, 'orderby' => 'rand', 'category__not_in' => array(9, 10, 11) ); $rand_posts = get_posts( $args ); foreach( $rand_posts as $post ) : ?> <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> <!-- end random post links -->
https://www.ads-software.com/plugins/vi-random-posts-widget/
- The topic ‘add date to go after title’ is closed to new replies.