<?php
$rand_posts = get_posts(‘numberposts=10&orderby=rand’);
foreach( $rand_posts as $post ) :
?>
<li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>
<?php endforeach; ?>
wordpress display random articles
Related Articles
Get all WordPress category names and IDs
function show_category(){ global $wpdb; $request = “SELECT $wpdb->terms.term_id, name FROM $wpdb->terms “; $request .= ” LEFT JOIN $wpdb->term_taxonomy ON $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id “; $request .= ” WHERE $wpdb->term_taxonomy.taxonomy = ‘category’ “; $request .= ” ORDER BY term_id asc”; $categorys =...
0
0
6
How to Make Sticky Posts in WordPress
<?php $sticky = get_option(‘sticky_posts’); rsort( $sticky ); $sticky = array_slice( $sticky, 0, 5); query_posts( array( ‘post__in’ => $sticky, ‘caller_get_posts’ => 1 ) ); if (have_posts()) :while (have_posts()) : the_post(); ?> <li><a href=”<?php%20the_permalink();%20?>” target=”_blank”><?php the_title(); ?></a></li> <?php endwhile; endif; ?>
0
0
4
WordPress functions.php-Add a Sidebar
Adding a Sidebar Our theme also doesn’t have a sidebar (widget area), let’s fix that now. First, we need to register the sidebar in functions.php: function my_custom_theme_sidebar() {register_sidebar( array( ‘name’ => __( ‘Primary Sidebar’, ‘my-custom-theme’ ), ‘id’ => ‘sidebar-1’,) );...
0
0
5
Build Your Own Custom WordPress Theme
Building your own custom WordPress theme can be a rewarding process. It allows you to create a unique look and functionality for your website that’s tailored to your specific needs. Here’s a step-by-step guide to help you build your own...
0
0
6

Comments (0)