Hey Folks!

During April & May of 2020, answers may be delayed more than it usually happens. This is caused by my personal situation that requires a lot of time from me to be dedicated elsewhere, and also because of the local things that are happening currently cause of the all things connected to "Corona Virus".

Please be patient, all answers are coming as soon as possible :-)

Sorry for any inconvenience.

Air.
Before you ask please READ THIS

(New) Random Posts Widget

edited June 2013 in Hypershot Posts: 40
Hi guys,
for I was missing this feature, I added it :) It's a alteration of the already existing widgets of the theme.

Just add the code snippet attached in your widgets.php between
register_widget('Apollo13_Widget_Popular_Posts');
and
class Apollo13_Widget_Related_Posts extends WP_Widget {
Oh, and if you want to show only random posts of a certain category change
$r = new WP_Query(array($search_string => $__search,'post__not_in' => array($post->ID), 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true));
to
$r = new WP_Query(array($search_string => $__search,'post__not_in' => array($post->ID), 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'category_name' => 'PUT_YOUR_CATEGORY_NAME_HERE'));
in the attached snippet.

Max

P.S.: This randomness only works properly, if NO page caching plugin is enabled (There are ways, to exclude widgets from caching, but that's too much work to alter :) )
Regards,
Max
txt
txt
random-widget.txt
6K
Post edited by macmacs on

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion