0

Is there a way that I can change the order of sections using custom fields?

For example I have:

<section id="1"></section>
<section id="2"></section>
<section id="3"></section>
<section id="4"></section>

And maybe the marketing team would like to try displaying section 4 first.

I do use custom fields a lot to decide whether to display something...but changing the order I cannot think of a way to do it.

Any ideas?

  • What are sections in this case? – Rarst Sep 14 '17 at 16:46
0

If I was designing the page from scratch then my own answer would be to combine flexbox and custom fields.

<div class="flexbox">
    <section id="a" style="order: <?php echo $customfield1 ?>"></section>
    <section id="b" style="order: <?php echo $customfield2 ?>"></section>
    <section id="c" style="order: <?php echo $customfield3 ?>"></section>
    <section id="d" style="order: <?php echo $customfield4 ?>"></section>
</div>

.flexbox {
display: flex;
}
0

Have 5 custom fields: the first 4 are your sections and the last would be your order identifier.

CASE 1

If you want to have the order simply revsered have the last field be a dropdown with "normal" or "reversed". (You could even say "random"... the world is your oyster)

$s1 = '<section id="1">$customfield1</section>';
$s2 = '<section id="2">$customfield2</section>';
$s3 = '<section id="3">$customfield3</section>';
$s4 = '<section id="4">$customfield4</section>';
if ($customfieldorder == 'reversed') {
echo $s4.$s3.$s2.$s1;
}else{ 
echo $s1.$s2.$s3.$s4;
}

CASE 2

With these 4 fields, they could simply put the info that they want to appear first in the first field and next information in the next field etc. Then your code would be simply: (users would choose order to display simply by where they put the information.

$s1 = '<section id="1">$customfield1</section>';
$s2 = '<section id="2">$customfield2</section>';
$s3 = '<section id="3">$customfield3</section>';
$s4 = '<section id="4">$customfield4</section>';

echo $s1.$s2.$s3.$s4;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.