2017-09-26 1 views
0

Cordialement. Je travaille sur un thème de wordpress et j'ai des footer area.I essayant de limiter le widget à 3 widget je n'ai que 3 taches dans mon thème ainsi j'ai cherché et aucune réponse à ceci à n'importe quel emplacement.comment limiter le widget wordpress

J'utilise ce code pour afficher le widget de bas de page

if(!function_exists('dynamic_sidebar')|| !dynamic_sidebar('footer')) : 
echo "<p> No Widget Here </p>"; 
endif ; 

donc ici aucune limite pour un widget Je veux limiter à 3 points mon pied de page ressemble à:

<footer> 
 
    <div class="container"> 
 
    <div class="row s"> 
 
    <div class="col-md-3 col-sm-6 footer-col pull-0"> 
 
     <h6 class="heading7 heading72">Social Media</h6> 
 
     <ul class="footer-social "> 
 
     <?php global $any_thing; ?> 
 
     <li><a href="<?php echo $any_thing['social3'] ?>"><i class="fa fa-instagram social-icon instagram-in" aria-hidden="true"></i></a></li> 
 
     <li><a href="<?php echo $any_thing['social2'] ?>"><i class="fa fa-facebook social-icon facebook" aria-hidden="true"></i></a></li> 
 
     <li><a href="<?php echo $any_thing['social4'] ?>"><i class="fa fa-twitter social-icon twitter" aria-hidden="true"></i></a></li> 
 
     <li><a href="<?php echo $any_thing['social1'] ?>"><i class="fa fa-google-plus social-icon google" aria-hidden="true"></i></a></li> 
 
     </ul> 
 
     </div> 
 
     
 
<?php 
 
if(!function_exists('dynamic_sidebar')|| !dynamic_sidebar('footer')) : 
 
?> 
 
<p>No Wedgit Here</p> 
 
<?php endif; ?> 
 
\t </div> 
 
    </div> 
 
    </div> 
 
</footer>

Répondre

0

Vous pouvez essayer de limiter le nombre de widgets de cette manière.

$sidebars = wp_get_sidebars_widgets(); 
$count_sidebar_widgets = count($sidebars['footer']); 
$limit_widgets = 3; 

if ($count_sidebar_widgets <= $limit_widgets) { 
    dynamic_sidebar('footer'); 
} else { 
    ?> 
    <p>Over the allowed widget limit</p> 
    <?php 
}