Home › Forums › General Issues › Checkbox issue : server error (500)
hi there,
I’m not a PHP expert that’s why i’m requesting your valuable help.
I have an author-box field in which i have to select, for each post, if :
1 : Display the author-box
2 : Don’t display
By putting the following code, it seems to miss something because in some case, I can lead to 500 server error (I have a piece of code before AND after).
<?php
///////////// //AUTHOR BOX ////////////
$selected = get_field('author_box');
if( in_array('1', $selected) ) {
echo do_shortcode('[wptabsy]');
}
?>
The thing is that I don’t know how to tell, via PHP, to display nothing if ‘2’ is selected. Maybe this will solve the issue.
—————
For further investigation, here’s the complete code :
<div id="contenu-et-author-box">
<div id="contenu-article">
<?php
/////////////////////// //CONTENU DE L'ARTICLE ///////////////////////
the_content();
?>
</div>
<div id="author-box">
<?php
///////////// //AUTHOR BOX ////////////
$selected = get_field('author_box');
if( in_array('1', $selected) ) {
echo do_shortcode(' [wptabsy] [tab icon="fa-th-large"]Auteur[/tab] [tab icon="fa-heart"]Derniers articles[/tab] [tabcontent]<div id="author-container"> <div id="img-avatar">[field avatar]</div> <div id="recap-container"> <div id="author-display-name">[field author]</div> [if exists] [field author meta=description] [else]Fan inconditionnel [/if] </div> </div> [/tabcontent] [tabcontent][userpro template=postsbyuser user=author postsbyuser_thumb=35px postsbyuser_types=post,logiciel,jeu postsbyuser_mode=compact postsbyuser_num=20][/tabcontent] [/wptabsy] ');
}
?>
</div>
<?php
/////////////////// //TABS FIN DE PAGE ///////////////////
if( have_rows('fin-de-page') ): // Vérifier si le champ contenu flexible dispose de données
while( have_rows('fin-de-page') ) : the_row();
// Ciblage du layout
$layout = get_row_layout();
// Avis Utilisateurs
if( $layout === 'avis-utilisateurs' ): ?>
[wptabsy] [tab icon="fa-th-large"] Alternatives[/tab] [tab icon="fa-heart"] Les avis de nos lecteurs[/tab] [tabcontent]Tab Content Here[/tabcontent] [tabcontent]<?php $idreview = get_sub_field('shortcode_avis'); echo do_shortcode('[rwp-review-ratings id="'.$idreview.'"]'); ?>[/tabcontent] [/wptabsy]
<?php
// Sous-Menu Logiciels
elseif( $layout === 'sous_menu_logiciels1' ): ?> <nav role="sub" class="clearfix">
[url=<?php the_sub_field(]#ancre">Fiche
</nav>
<?php
endif;
endwhile;
endif;
?>
What we really need to know is what the error is, I don’t see anything wrong with the first code that should cause an error. Turn on PHP debugging in WP so that hopefully you can see the real error. https://codex.wordpress.org/WP_DEBUG
In facts, the issue is coming from the Content Shortcode plugin, which is unable to make loops since the 4.6 update (at least for my case).
I’m just trying to find an alternative… Problem solved.
Thank you.
The topic ‘Checkbox issue : server error (500)’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.