Monday, 2 October 2017

How to Add Random Post Button In Wordpress Urdu

How to Add Random Post Button In Wordpress Urdu


Code : 

add_action('init','random_add_rewrite');
function random_add_rewrite() {
       global $wp;
       $wp->add_query_var('random');
       add_rewrite_rule('random/?$', 'index.php?random=1', 'top');
}

add_action('template_redirect','random_template');
function random_template() {
       if (get_query_var('random') == 1) {
               $posts = get_posts('post_type=post&orderby=rand&numberposts=1');
               foreach($posts as $post) {
                       $link = get_permalink($post);
               }
               wp_redirect($link,307);
               exit;
       }
}


===
<a href="/?random=1">Random Post</a>


Watch Video




WP Random Button
How to Get a Random Post Button in WordPress
How to Redirect Users to a Random Post in WordPress
Wordpress: Create A Random Post Button
How to add a Random Post button in wordpress - wpsites
How to Add a Random Post Button in WordPress?
WordPress Random Post Button Code Snippets
Create a Random Post button in WordPress
random post generator wordpress
random post wordpress
wordpress show random posts on homepage
wordpress random page
wp random button
wordpress random redirect
wordpress random post order
display random posts wordpress

random post generator wordpress,random post wordpress,wordpress show random posts on homepage,wordpress random page,wp

random button,wordpress random redirect,wordpress random post order,display random posts wordpress

Previous Post
Next Post

Blogger By Passion, Programmer By Love And SEO Expert By Birth.This Quote Explain Me Perfectly.

0 comments: