8791 sujets

Développement web côté serveur, CMS

Pages :
(reprise du message précédent)

J'ai fais un essai :

<?php if ( in_category('Affiches') ) {
echo '<li><a id="menu-item-69" style="background:url(http://localhost:8888/cocks/wp-content/uploads/2014/09/categorie-affiches-B.png) no-repeat center;width:216px;height:120px;"></a></li>';
} else {
echo '<li><a id="menu-item-69" style="background:url(http://localhost:8888/cocks/wp-content/uploads/2014/09/categorie-affiches-A.png) no-repeat center;width:216px;height:120px;"></a></li>';
}
?>


Cependant, l'image "categorie-affiches-B.png" reste constamment active. Comme si le "else" n'était pas là pour rétablir l'image de base le as échéant... Une idée ?
Bonsoir MaxenceB,

Quand tu fais cela et que tu le teste dans ton navigateur, sur quel template de ton thème te situes-tu ?

Quel est le type de contenu ? Article seul, archive, catégorie, page, autre ?
Bonjour !
Mon theme est GridThemeResponsive.
J'ai inséré ce code dans le header.php et j'ai testé dans category.php
Là il s'agit du menu présentant les catégories, ce sont à l'origine des images insérées en css via la propriété background dans une liste de liens.
Modifié par MaxenceB (13 Sep 2014 - 11:00)
À priori, je dirais que ça devrais être inclu dans header.php, à ce niveau :

 <?php wp_nav_menu('menu=category_menu&container=false'); ?> 


Le code de header.php complet est le suivant, si ça peut aider :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">

<head> 

  <title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>          

  <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" title="no title" charset="utf-8"/>

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<!--[if lt IE 9]>

	<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>

<![endif]-->  

  <?php wp_head(); ?>

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.hover_caption.js" type="text/javascript" charset="utf-8"></script>    

  <script src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.infinitescroll.js" type="text/javascript" charset="utf-8"></script>    


<?php if ( is_page_template('tpl-blog.php') ) { ?>

<script type="text/javascript">

jQuery(document).ready(

function($){

  $('#content').infinitescroll({

    navSelector  : "div.load_more_text",            

                   // selector for the paged navigation (it will be hidden)

    nextSelector : "div.load_more_text a:first",    

                   // selector for the NEXT link (to page 2)

    itemSelector : "#content_inside .post_box"          

                   // selector for all items you'll retrieve

  },function(arrayOfNewElems){

      //$('.home_post_cont img').hover_caption();

  });  

}  

);

</script>

<?php } else { ?>

<script type="text/javascript">

jQuery(document).ready(

function($){

  $('#content').infinitescroll({

    navSelector  : "div.load_more_text",            

                   // selector for the paged navigation (it will be hidden)

    nextSelector : "div.load_more_text a:first",    

                   // selector for the NEXT link (to page 2)

    itemSelector : "#content_inside .post_box"          

                   // selector for all items you'll retrieve

  },function(arrayOfNewElems){

      $('.home_post_cont img').hover_caption();

  });  

}  

);

</script>

<?php } ?>



</head>

<body>



<?php $shortname = "grid"; ?>



<?php if(get_option($shortname.'_custom_background_color','') != "") { ?>

<style type="text/css">

  body { background-color: <?php echo get_option($shortname.'_custom_background_color',''); ?>; }

  .content_divider_inside { background-color: <?php echo get_option($shortname.'_custom_background_color',''); ?>; }

</style>

<?php } ?>



<?php if(get_option($shortname.'_post_hover_background_color','') != "") { ?>

<style type="text/css">

  .hover_caption { background-color: <?php echo get_option($shortname.'_post_hover_background_color',''); ?>; }

</style>

<?php } ?>



<div id="main_container">



    <div id="header">

        <div align="center">

   <ul id="menu-links">
		<li id="aile1"></li>
		<li id="icon-wtf"><a href=".single-left">WTF?!</a></li>
		<li id="icon-contact"><a href="#">CONTACT</a></li>
	</ul>


<?php
$catCouranteID = get_cat_ID(single_cat_title('', false)); // récupère l'ID de la catégorie courante
if (!empty($catCouranteID)) { // si on est dans une catégorie
    echo '<a href="'.get_bloginfo('url').'"><img src="'.get_bloginfo('template_url').'/images/logo-'.$catCouranteID.'.png" class="logo" /></a>';
} else { // si on est pas dans une catégorie, on affiche le fichier image logo.png
    echo '<a href="'.get_bloginfo('url').'"><img src="'.get_bloginfo('template_url').'/images/logo.png" class="logo" /></a>';
}
?>

        
	<ul id="menu-social">
		<li id="icon-facebook"><a href="https://www.facebook.com/pages/Cocks-on-Fire/735467936526483">FACEBOOK</a></li>
		<li id="icon-twitter"><a href="http://www.twitter.com">TWITTER</a></li>
		<li id="aile2"></li>
	</ul>

<div id="slogan">La Sérigraphie Au Service Des Artistes</div>           

        </div>

    </div><!--//header-->

    

    <div id="menu_container">

    <!--

        <ul>

          <li><a href="#">Home</a></li>

          <li><a href="#">About</a></li>

          <li><a href="#">Blog</a></li>

          <li><a href="#">Contact</a></li>

        </ul>-->

        <?php wp_nav_menu('menu=header_menu&container=false'); ?>

        <!--

        <ul>

          <li><a href="#">Architecture</a></li>

          <li><a href="#">Graphic Design</a></li>

          <li><a href="#">Print</a></li>

          <li><a href="#">Typography</a></li>

          <li><a href="#">Web Design</a></li>

        </ul>-->
     <div class="header_social_icons_cont">

        <?php wp_nav_menu('menu=category_menu&container=false'); ?>                    
        

            <?php if(get_option($shortname.'_twitter_link','') != "") { ?>

                <a href="<?php echo get_option($shortname.'_twitter_link',''); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/twitter-icon.png" /></a>

            <?php } ?>                    



            <?php if(get_option($shortname.'_facebook_link','') != "") { ?>

                <a href="<?php echo get_option($shortname.'_facebook_link',''); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/facebook-icon.png" /></a>

            <?php } ?>        

            

            <?php if(get_option($shortname.'_google_plus_link','') != "") { ?>

                <a href="<?php echo get_option($shortname.'_google_plus_link',''); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/google-plus-icon.png" /></a>

            <?php } ?>            

           


            <?php if(get_option($shortname.'_dribbble_link','') != "") { ?>

                <a href="<?php echo get_option($shortname.'_dribbble_link',''); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/dribbble-icon.png " /></a>

            <?php } ?>



            <div class="clear"></div>

        </div><!--//header_social_icons_cont-->




        <div class="clear"></div>

    </div><!--//menu_container-->
Pages :