WordPress.org

Ready to get started?Download WordPress

Forums

How to List WordPress Pages in checkboxe Options (7 posts)

  1. Behseini
    Member
    Posted 1 year ago #

    Can you please let me know how I can load checkboxes based on following code:
    <?php wp_list_pages('title_li='); ?>

    I know that this code will list all pages in wordpress but I would like to have them in checkbox format which let user to select parent for a new product.

  2. michael.mariart
    Member
    Posted 1 year ago #

    That's not going to work. Firstly, that code only gives a drip-down, so it can't do checkboxes. If you want to do that you'll have to write your own code to do it. It's not that hard, you just need to think about it a little bit.

    The main reason that it won't work though is that a post/page/product/etc post type can only ever have one parent, so there's no way that a user would be able to select two checkboxes and have it work as only one value will ever be used. If you want to do it this way you could possibly use radio buttons instead so that you're limited to a single selection, but I'd still advise against it because you'll fidn it gets very messy as your sites pages grow. When there's only a few pages the list isn't to long, but once you get to 20 or 30 pages there's just to many to scroll through when you display them that way.

  3. Behseini
    Member
    Posted 1 year ago #

    Michael, Thanks for your perfect explanation. Your are right it doesn't' make sense!
    What I am trying to do is creating a plugin for my website which will help me to upload my images easier.
    I was thinking to Add images as products and specify the parent gallery for that by categories but it was too hard for me! so I thought I may use this way which let me to select the parent pages(Wedding, Commercial, Portrait, and Nature)which they have different styles and file depository path!
    I am pretty sure that my pages are not going to exceed more that 10 but you are right this is not correct way to do it? can you please let me know what is the best solution for things like this?
    Thanks

  4. Behseini
    Member
    Posted 1 year ago #

    I forget to mentioned that I have seen something like this in "Woo Commerce " product plugin. so I was thinking to create a Category and Product and which each product must associated with one of [checkboxes] listed categories!

  5. michael.mariart
    Member
    Posted 1 year ago #

    This is probably a stupid question, but why not use the standard WP image media gallery on each page and upload the images there? That way they are "linked" to that page, you can insert them anywhere that you want to, and it's all done through a standard system without any messing around trying to write your own.

  6. Behseini
    Member
    Posted 1 year ago #

    Wow! I didn't know that but how Can I assign specific style to them? for example let say I have my content like this from my HTML:

    <div class="wrapper">
    <!-- content -->
    <div id="scrool" class="clearfix">
    <div id="content_1" class="galcontent">
    <div class="gal item"><a class="group4" href="img/gallery/Beauty/Beauty 1.jpg"><img src="img/gallery/Beauty/gal/Beauty 1.jpg" alt="Ghazal Photo" width="231" height="149" id="roma" class="colorshift" /></a></div>
    <div class="gal item"><a class="group4" href="img/gallery/Beauty/Beauty 2.jpg"><img src="img/gallery/Beauty/gal/Beauty 2.jpg" alt="Ghazal Photo" width="231" height="149" id="roma" class="colorshift"/></a></div>
    <div class="gal item"><a class="group4" href="img/gallery/Beauty/Beauty 3.jpg"><img src="img/gallery/Beauty/gal/Beauty 3.jpg" alt="Ghazal Photo" width="231" height="149" id="roma" class="colorshift"/></a></div>
    </div>   <!-- Scrooler -->
    </div><!-- End of content -->
    </div><!-- End of wrapper -->

    in HTML and if I add the images from the WordPress built-in function how I can make sure the image will follow the associated rules?

  7. michael.mariart
    Member
    Posted 1 year ago #

    Look at the HTML markup that WordPress gives you when you add in the galleries. That will show you what is and is not available. From there you'll be able to apply your own styling to the galleries. Remember that there's classes all the way up the page to the body tag that can let you target individual pages and areas as well as just the classes and ID's in the galleries.

    If that doesn't work for you, you can also write your own gallery functions. I've written shortcodes and template functions before that output galleries the way that I want them to look and include the markup that I want wrapped around them, and can use either selected images attached to the page, or all images attached to the page. Depending on what you need it may be eaiser to do it this way.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags