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

  • SEARCH
  • Home
  • 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 9299259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:31:06+00:00 2026-06-18T22:31:06+00:00

I am using wordpress, and I am creating a widget chooser for every page

  • 0

I am using wordpress, and I am creating a “widget chooser” for every page of the site. On the backend of each page, I have 15 checkboxes – if the user chooses a checkbox, it shows that particular widget in the sidebar of that page.

I have a large PHP document, with 15 includes. Each include is a widget. If the user checks a box on that page, that include is triggered like so:

 if( in_array( 'Blog', get_field('modules') ) ) { 
    include 'modules/blog.php'; 
 }

This works great! But, there is no way for the user to specify the order in which the widgets will appear. I need to develop some sort of system that will allow the user to choose the order of the modules.

Heres what I was thinking- If I can get each checkbox to spit out a specified order, I would need some sort of way within php to reposition the includes:

 if( in_array( 'Blog', get_field('modules') ) ) { 
    $order = 2;
    include 'modules/blog.php'; 
 }

if( in_array( 'Gallery', get_field('modules') ) ) { 
    $order = 1;
    include 'modules/gallery.php'; 
}

Now I would need some way to reorder these two “blocks” based on their supplied order. Can I make that happen somehow? Obviously I want to use PHP, but if not possible I could do it with jQuery. Any thoughts?

  • 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-18T22:31:07+00:00Added an answer on June 18, 2026 at 10:31 pm

    Instead of including the modules, push the list to an array which will include them in the end. Like:

    $final_modules = array();
     if( in_array( 'Blog', get_field('modules') ) ) { 
        $order = 2;
        $final_modules[$order] = 'modules/blog.php';
     }
    
    if( in_array( 'Gallery', get_field('modules') ) ) { 
        $order = 1;
        $final_modules[$order] = 'modules/gallery.php';
    }
    
    //sort based on key
    ksort($final_modules);
    
    foreach($final_modules as $order => $include_file) {
        include $include_file;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a blog using only Wordpress's backend. I have found functions to
I´m creating web page in wordpress, and I have navigation menu using <?php wp_nav_menu();
Using Wordpress.. I would like to redirect to a certain page on the site
I just started out using wordpress as a CMS. On the site I have
I'm creating a site in wordpress which holds information on television programs. I'm using
I'm Windows 8 user who wants to install Wordpress. I'm using XAMPP and have
I am using wordpress for my next CMS project. Say I have a page
I am creating feedback page in wordpress application. I am using <?php comments_template(); ?>
I am creating my first wordpress widget and I am having problems using jquery
I am creating a WordPress site using Artisteer and various plugins to show off

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.