WordPress: How to order child pages in a select menu? The Next CEO of Stack OverflowHow to add a PHP page to WordPress?Wordpress custom taxonomy paged getting 404 not foundPage ordering by up/down arrows in phpHow to handle search query strings with jQuery sort, number of results, page number, etc. SELECT menus?MySQL query - how order by 2 rows in one tableDisplay child post on parent post page in wordpressHow to print a multidimensional array that the user selected?Wordpress WP_Term_Query Custom Taxonomy Select Optionscategory & sub category order issues in wordpressHow can I show dynamic options in select, based on another select element using AJAX?

Does increasing your ability score affect your main stat?

WOW air has ceased operation, can I get my tickets refunded?

What is the value of α and β in a triangle?

Unclear about dynamic binding

What steps are necessary to read a Modern SSD in Medieval Europe?

Which one is the true statement?

RigExpert AA-35 - Interpreting The Information

A Man With a Stainless Steel Endoskeleton (like The Terminator) Fighting Cloaked Aliens Only He Can See

How many extra stops do monopods offer for tele photographs?

Why does standard notation not preserve intervals (visually)

Can a Bladesinger Wizard use Bladesong with a Hand Crossbow?

Is there a difference between "Fahrstuhl" and "Aufzug"

Why didn't Khan get resurrected in the Genesis Explosion?

Rotate a column

Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?

What did we know about the Kessel run before the prequels?

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

Powershell. How to parse gci Name?

How to sed chunks text from a stream of files from find

Why do remote US companies require working in the US?

Is it ever safe to open a suspicious HTML file (e.g. email attachment)?

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

Why did CATV standarize in 75 ohms and everyone else in 50?

How to place nodes around a circle from some initial angle?



WordPress: How to order child pages in a select menu?



The Next CEO of Stack OverflowHow to add a PHP page to WordPress?Wordpress custom taxonomy paged getting 404 not foundPage ordering by up/down arrows in phpHow to handle search query strings with jQuery sort, number of results, page number, etc. SELECT menus?MySQL query - how order by 2 rows in one tableDisplay child post on parent post page in wordpressHow to print a multidimensional array that the user selected?Wordpress WP_Term_Query Custom Taxonomy Select Optionscategory & sub category order issues in wordpressHow can I show dynamic options in select, based on another select element using AJAX?










0















I have a select box, which allows you to navigate between parent pages and their children, they are given a specific order, in order to display them in a certain way on the website.



I believe that the line of code that interest you is perhaps this one



$children = get_pages("title_li=&child_of=" . $parent . "&echo=0");



The full code is below. You can see that the order of the pages on the site is different than the order of the pages in the select menu, that is because wordpress sorts per order, my pages are sorted alphabetically. How to sort them by order, so that what you see on the website matches the select box?



<?php

// determine parent of current page

if ($post->post_parent)

$ancestors = get_post_ancestors($post->ID);
$parent = $ancestors[count($ancestors) - 1];

else

$parent = $post->ID;


$children = get_pages("title_li=&child_of=" . $parent . "&echo=0");
?>
<div id="info-select-wrap" class="single-france-select">
<select id="info-select"class="fr-select" >
<?php

if (get_the_ID() == $parent->ID): ?>
<option value="<?php
echo get_the_permalink($parent->ID); ?>" selected>  <?php
echo get_the_title($parent->ID); ?></option>
<?php
else: ?>
<option value="<?php
echo get_the_permalink($parent); ?>">  <?php
echo get_the_title($parent); ?></option>

<?php
endif;

foreach($children as $child):
if (has_children($child))

if (get_the_ID() == $child->ID)
?>
<option value="<?php
echo get_the_permalink($child->ID); ?>" selected>  <?php
echo get_the_title($child->ID); ?></option>
<?php

else
?>
<option value="<?php
echo get_the_permalink($child->ID); ?>"> <?php
echo get_the_title($child->ID); ?></option>



<?php


else

if (get_the_ID() == $child->ID)
?>
<option value="<?php
echo get_the_permalink($child->ID); ?>" selected>  <?php
echo get_the_title($child->ID); ?></option>
<?php

else
?>
<option value="<?php
echo get_the_permalink($child->ID); ?>"> <?php
echo get_the_title($child->ID); ?></option>



<?php



endforeach; ?>
</select>
</div>


I tried



$children = get_pages("title_li=&child_of=" . $parent . "&echo=0&orderby='menu_order'&order='ASC'");


Didn't solve it.










share|improve this question




























    0















    I have a select box, which allows you to navigate between parent pages and their children, they are given a specific order, in order to display them in a certain way on the website.



    I believe that the line of code that interest you is perhaps this one



    $children = get_pages("title_li=&child_of=" . $parent . "&echo=0");



    The full code is below. You can see that the order of the pages on the site is different than the order of the pages in the select menu, that is because wordpress sorts per order, my pages are sorted alphabetically. How to sort them by order, so that what you see on the website matches the select box?



    <?php

    // determine parent of current page

    if ($post->post_parent)

    $ancestors = get_post_ancestors($post->ID);
    $parent = $ancestors[count($ancestors) - 1];

    else

    $parent = $post->ID;


    $children = get_pages("title_li=&child_of=" . $parent . "&echo=0");
    ?>
    <div id="info-select-wrap" class="single-france-select">
    <select id="info-select"class="fr-select" >
    <?php

    if (get_the_ID() == $parent->ID): ?>
    <option value="<?php
    echo get_the_permalink($parent->ID); ?>" selected>  <?php
    echo get_the_title($parent->ID); ?></option>
    <?php
    else: ?>
    <option value="<?php
    echo get_the_permalink($parent); ?>">  <?php
    echo get_the_title($parent); ?></option>

    <?php
    endif;

    foreach($children as $child):
    if (has_children($child))

    if (get_the_ID() == $child->ID)
    ?>
    <option value="<?php
    echo get_the_permalink($child->ID); ?>" selected>  <?php
    echo get_the_title($child->ID); ?></option>
    <?php

    else
    ?>
    <option value="<?php
    echo get_the_permalink($child->ID); ?>"> <?php
    echo get_the_title($child->ID); ?></option>



    <?php


    else

    if (get_the_ID() == $child->ID)
    ?>
    <option value="<?php
    echo get_the_permalink($child->ID); ?>" selected>  <?php
    echo get_the_title($child->ID); ?></option>
    <?php

    else
    ?>
    <option value="<?php
    echo get_the_permalink($child->ID); ?>"> <?php
    echo get_the_title($child->ID); ?></option>



    <?php



    endforeach; ?>
    </select>
    </div>


    I tried



    $children = get_pages("title_li=&child_of=" . $parent . "&echo=0&orderby='menu_order'&order='ASC'");


    Didn't solve it.










    share|improve this question


























      0












      0








      0








      I have a select box, which allows you to navigate between parent pages and their children, they are given a specific order, in order to display them in a certain way on the website.



      I believe that the line of code that interest you is perhaps this one



      $children = get_pages("title_li=&child_of=" . $parent . "&echo=0");



      The full code is below. You can see that the order of the pages on the site is different than the order of the pages in the select menu, that is because wordpress sorts per order, my pages are sorted alphabetically. How to sort them by order, so that what you see on the website matches the select box?



      <?php

      // determine parent of current page

      if ($post->post_parent)

      $ancestors = get_post_ancestors($post->ID);
      $parent = $ancestors[count($ancestors) - 1];

      else

      $parent = $post->ID;


      $children = get_pages("title_li=&child_of=" . $parent . "&echo=0");
      ?>
      <div id="info-select-wrap" class="single-france-select">
      <select id="info-select"class="fr-select" >
      <?php

      if (get_the_ID() == $parent->ID): ?>
      <option value="<?php
      echo get_the_permalink($parent->ID); ?>" selected>  <?php
      echo get_the_title($parent->ID); ?></option>
      <?php
      else: ?>
      <option value="<?php
      echo get_the_permalink($parent); ?>">  <?php
      echo get_the_title($parent); ?></option>

      <?php
      endif;

      foreach($children as $child):
      if (has_children($child))

      if (get_the_ID() == $child->ID)
      ?>
      <option value="<?php
      echo get_the_permalink($child->ID); ?>" selected>  <?php
      echo get_the_title($child->ID); ?></option>
      <?php

      else
      ?>
      <option value="<?php
      echo get_the_permalink($child->ID); ?>"> <?php
      echo get_the_title($child->ID); ?></option>



      <?php


      else

      if (get_the_ID() == $child->ID)
      ?>
      <option value="<?php
      echo get_the_permalink($child->ID); ?>" selected>  <?php
      echo get_the_title($child->ID); ?></option>
      <?php

      else
      ?>
      <option value="<?php
      echo get_the_permalink($child->ID); ?>"> <?php
      echo get_the_title($child->ID); ?></option>



      <?php



      endforeach; ?>
      </select>
      </div>


      I tried



      $children = get_pages("title_li=&child_of=" . $parent . "&echo=0&orderby='menu_order'&order='ASC'");


      Didn't solve it.










      share|improve this question
















      I have a select box, which allows you to navigate between parent pages and their children, they are given a specific order, in order to display them in a certain way on the website.



      I believe that the line of code that interest you is perhaps this one



      $children = get_pages("title_li=&child_of=" . $parent . "&echo=0");



      The full code is below. You can see that the order of the pages on the site is different than the order of the pages in the select menu, that is because wordpress sorts per order, my pages are sorted alphabetically. How to sort them by order, so that what you see on the website matches the select box?



      <?php

      // determine parent of current page

      if ($post->post_parent)

      $ancestors = get_post_ancestors($post->ID);
      $parent = $ancestors[count($ancestors) - 1];

      else

      $parent = $post->ID;


      $children = get_pages("title_li=&child_of=" . $parent . "&echo=0");
      ?>
      <div id="info-select-wrap" class="single-france-select">
      <select id="info-select"class="fr-select" >
      <?php

      if (get_the_ID() == $parent->ID): ?>
      <option value="<?php
      echo get_the_permalink($parent->ID); ?>" selected>  <?php
      echo get_the_title($parent->ID); ?></option>
      <?php
      else: ?>
      <option value="<?php
      echo get_the_permalink($parent); ?>">  <?php
      echo get_the_title($parent); ?></option>

      <?php
      endif;

      foreach($children as $child):
      if (has_children($child))

      if (get_the_ID() == $child->ID)
      ?>
      <option value="<?php
      echo get_the_permalink($child->ID); ?>" selected>  <?php
      echo get_the_title($child->ID); ?></option>
      <?php

      else
      ?>
      <option value="<?php
      echo get_the_permalink($child->ID); ?>"> <?php
      echo get_the_title($child->ID); ?></option>



      <?php


      else

      if (get_the_ID() == $child->ID)
      ?>
      <option value="<?php
      echo get_the_permalink($child->ID); ?>" selected>  <?php
      echo get_the_title($child->ID); ?></option>
      <?php

      else
      ?>
      <option value="<?php
      echo get_the_permalink($child->ID); ?>"> <?php
      echo get_the_title($child->ID); ?></option>



      <?php



      endforeach; ?>
      </select>
      </div>


      I tried



      $children = get_pages("title_li=&child_of=" . $parent . "&echo=0&orderby='menu_order'&order='ASC'");


      Didn't solve it.







      php wordpress






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 17:06







      Lynob

















      asked Mar 7 at 16:34









      LynobLynob

      1,65873567




      1,65873567






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Issue solved by adding sort_column=menu_order



          $children = get_pages("title_li=&child_of=" . $parent . "&echo=0&sort_column=menu_order");


          Just a quick note, &echo=0 is useless, you can remove it.






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55048707%2fwordpress-how-to-order-child-pages-in-a-select-menu%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Issue solved by adding sort_column=menu_order



            $children = get_pages("title_li=&child_of=" . $parent . "&echo=0&sort_column=menu_order");


            Just a quick note, &echo=0 is useless, you can remove it.






            share|improve this answer





























              0














              Issue solved by adding sort_column=menu_order



              $children = get_pages("title_li=&child_of=" . $parent . "&echo=0&sort_column=menu_order");


              Just a quick note, &echo=0 is useless, you can remove it.






              share|improve this answer



























                0












                0








                0







                Issue solved by adding sort_column=menu_order



                $children = get_pages("title_li=&child_of=" . $parent . "&echo=0&sort_column=menu_order");


                Just a quick note, &echo=0 is useless, you can remove it.






                share|improve this answer















                Issue solved by adding sort_column=menu_order



                $children = get_pages("title_li=&child_of=" . $parent . "&echo=0&sort_column=menu_order");


                Just a quick note, &echo=0 is useless, you can remove it.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 7 at 19:59

























                answered Mar 7 at 17:06









                LynobLynob

                1,65873567




                1,65873567





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55048707%2fwordpress-how-to-order-child-pages-in-a-select-menu%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

                    Алба-Юлія

                    Захаров Федір Захарович