Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7723117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:21:46+00:00 2026-06-01T04:21:46+00:00

While developing my WordPress application i have a requirement where i need to show

  • 0

While developing my WordPress application i have a requirement where i need to show some random posts and user should be provided a link where he/she can refresh the posts, this should be the part of home page and here is what i have done in home page so far

<div id="random-wrapper">
    <h3>Random Posts</h3>
        <div id="random-content" style="opacity: 1; display: block;">
            <?php
            $args1 = array( 'numberposts' => 12 ,'orderby' => 'rand');
            global $post;  //save the current post
            $temp=$post;
            $rand_posts1 = get_posts( $args1);
            foreach( $rand_posts1 as $post ) ://yes this is required, we need $post in setup_postdata
                setup_postdata($post);    ?> 
                <?php   $values = get_post_custom_values("Image");  
                if (isset($values[0])) { ?>
                    <span style="float:left; padding:0 0 10px;">
                      <a href="<?php the_permalink() ?>"  title="<?php the_title(); ?>" class="left">
                            <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
                            $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=80&h=80&zc=1&q=90"
                            alt="<?php the_title(); ?>" class="colabs-image" width="80px" height="80px"  /></a>
                    </span>
                <?php } ?>
            <?php endforeach; 
            $post=$temp;//restore current page
            ?>
        </div>
</div>

Above code is working fine, but i am not sure how can i refresh the above div so that it can fetch any other random posts to display in home page.
I know i can reload that using jQuery but for that i need to separate this to other page and than reload the page and i am not sure how this can be done in WordPress

Please suggest a way to achieve this functionality.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:21:47+00:00Added an answer on June 1, 2026 at 4:21 am

    You could use an ajax call to the php file that is producing the content. Then take the response and refresh the div using its id. You might have to custom code a php file. You could basically reproduce the file to only output the content that you need. WordPress codex site has a lot of info on custom loops.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While developing my ASP.NET MVC, I have started to see the need for a
While developing my application i came across some comparison stuff here was it: string
While developing products, we often need to create proprietary tools to test some of
While developing a Facebook application I got the friendlist of a user by $friends
I am facing some issue while developing Video capturing application. 1) When I start
I need phone numbers while developing my application. So, I used TelephonyManager as seen
While developing a WinForms application, I came across what I believe is a bug
While developing an application, I had the following problem. I wanted to return an
While developing a Launcher (Homescreen) application for Android, I've come into a security exception
While developing a web application I want to perform certain validation check and only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.