Changer l'image de fond par page
-
-
Non,cen'estpas du CSS.Vous devez créer des 'add_meta_boxes' http://codex.wordpress.org/Function_Reference/add_meta_boxNo. It is not CSS. You have to create 'add_meta_boxes' http://codex.wordpress.org/Function_Reference/add_meta_box
- 0
- 2014-01-16
- ucon89
-
2 réponses
- votes
-
- 2014-12-26
Oui,celapeut êtrefait avec CSS.
J'aifait cela avec lesidentifiants depageet depublication.
< IMPORTANT: Lesexemples suivants sont desexemples debaseet devront êtretestéset régléspour votre utilisation. Si vousnotez uneerreurici (avec lesexemples CSS debase),veuillezpublier unenote concernant l'erreur.
Pouridentifier despageset des articles,accédez à votrepage Pages ou Articleset survolez lenom den'importe quellepage ou article. En survolant,regardezen bas àgauche de votrenavigateuret l'ID de lapage sera affiché dans labarre d'état. Oufaites ce queje faiset utilisez leplugin Catch IDs.
Pour une utilisationen arrière-plan à l'échelle du site:
body { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
Pour cibler unepage:
body.page-id-33 { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
Pour ciblerplusieurspages:
body.page-id-33, body.page-id-41, body.page-id-725 { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
Pour cibler une catégorie:
.category-CategoryName { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
Pour ciblerplusieurs catégories:
.category-CategoryName, .category-CategoryName-2 { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
Pour cibler lespages d'archives:
.archive { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
Pour cibler unmodèlepersonnalisépour unepage,un article ou une catégorie,utilisez:
.page-template-name { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
Dans chacune desinstances ci-dessus,vouspouvez simplement copier le CSSet le coller ànouveau,en changeant lesidentifiantset l'URL de l'imagepour changer l'imagebg pour différentespages ou catégories.
RÉFÉRENCES
Désolé - alors quej'essaie d'aideret d'attribuerplusieurs articles sources,les règlestrop zéléesicim'empêchent depublierplus d'un lien vers les références. J'ai donc écrit un article à ce sujetet toutes les références sont sur cet article.
http://kb4wp.com/blog/use-css-to-target-pages-posts-and-categories/
Yes, this can be done with CSS.
I have done this with page and post IDs.
IMPORTANT: The following are base examples and will need to be tested and tuned for your use. If you note any error here (with the base CSS examples), please post a note about the error.
To ID pages and posts, go to your Pages or Posts page and hover over the name of any page or post. While hovering look at the bottom left of your browser and the page ID will be displayed in the status bar. Or do what I do and use the Catch IDs plugin.
For one site-wide background use:
body { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
To target a page:
body.page-id-33 { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
To target multiple pages:
body.page-id-33, body.page-id-41, body.page-id-725 { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
To target a category:
.category-CategoryName { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
To target multiple categories:
.category-CategoryName, .category-CategoryName-2 { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
To target Archive pages:
.archive { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
To target a custom template for a page, post or category use:
.page-template-name { background-image:url('example.gif'); background-repeat:no-repeat; background-attachment:fixed; }
In each of the above instances you can simply copy the CSS and paste it again, changing the IDs and image URL to change the bg image for different pages or categories.
REFERENCES
Sorry--while I'm trying to help and give attribution to several source articles, the overzealous rules here prevent me from posting more than one link to the references. So I wrote a post about this and all the references are on that post.
http://kb4wp.com/blog/use-css-to-target-pages-posts-and-categories/
-
Lorsque l'utilisateur accède au
home.php
,appelle-le A,il doit avoir uneimage d'arrière-plan,alors sije l'envoie à unepage B,j'aimerais que l'image d'arrière-plan change.Quelqu'unpeut-ilme guider dans labonne direction,s'il vousplaît?Je comprends que celapeut être réalisé via
.css
.