Custom Post Types

Les codes pour optimiser le SEO des CPT de WordPress


Mélanger pages et articles

[pastacode lang= »php » manual= »function%20sx_tags_categories_support()%20%7B%0A%09register_taxonomy_for_object_type(%20’post_tag’%2C%20’page’%20)%3B%0A%09register_taxonomy_for_object_type(%20’category’%2C%20’page’%20)%3B%0A%7D%0Aadd_action(%20’init’%2C%20’sx_tags_categories_support’%20)%3B » message= »Ajouter les catégories et étiquettes aux pages » highlight= » » provider= »manual »/] [pastacode lang= »php » manual= »function%20sx_tags_categories_support_query(%20%24wp_query%20)%20%7B%0A%09if%20(%20%24wp_query-%3Eget(%20’tag’%20)%20)%20%7B%0A%09%09%24wp_query-%3Eset(%20’post_type’%2C%20array(%20’post’%2C%20’page’%20)%20)%3B%0A%09%7D%0A%09if%20(%20%24wp_query-%3Eget(%20’category_name’%20)%20)%20%7B%0A%09%09%24wp_query-%3Eset(%20’post_type’%2C%20array(%20’post’%2C%20’page’%20)%20)%3B%0A%09%7D%0A%7D%0Aadd_action(%20’pre_get_posts’%2C%20’sx_tags_categories_support_query’%20)%3B » message= »Afficher les pages dans les catégories et étiquettes » highlight= » » provider= »manual »/]

Ajouter les sticky posts aux custom posts types

[pastacode lang= »php » message= » » highlight= » » provider= »manual » manual= »%2F**%0A*%20Source%20%3A%20GeekPress%20http%3A%2F%2Fwww.geekpress.fr%2Fwordpress%2Fastuce%2Fsticky-postscustom-%0Apost-types-1967%2F%0A*%2F%0Afunction%20seomix_add_sticky_post_support()%20%7B%0Aglobal%20%24post%2C%20%24typenow%3B%0Aif%20(%20%24typenow%20%3D%3D%20’saucisson’%20%26%26%20current_user_can(%20’edit_others_posts’%20)%20)%20%3A%20%3F%3E%0A%3Cscript%3E%0AjQuery(function(%24)%20%7B%0Avar%20sticky%20%3D%20%22%3Cbr%2F%3E%3Cspan%20id%3D’sticky-span’%3E%3Cinput%20id%3D’sticky’%0Aname%3D’sticky’%20type%3D’checkbox’%20value%3D’sticky’%20%3C%3Fphp%20checked(%20is_sticky(%20%24post-%0A%3EID%20)%20)%3B%20%3F%3E%20%2F%3E%20%3Clabel%20for%3D’sticky’%20class%3D’selectit’%3E%3C%3Fphp%20_e(%20%22Stick%20this%20post%0Ato%20the%20front%20page%22%20)%3B%20%3F%3E%3C%2Flabel%3E%3Cbr%20%2F%3E%3C%2Fspan%3E%22%3B%0A%24(‘%5Bfor%3Dvisibility-radio-public%5D’).append(sticky)%3B%0A%7D)%3B%0A%3C%2Fscript%3E%0A%3C%3Fphp%20endif%3B%20%7D%0Aadd_action(%20’admin_footer-post.php’%2C%20’seomix_add_sticky_post_support’%20)%3B%0Aadd_action(%20’admin_footer-post-new.php’%2C%20’seomix_add_sticky_post_support’%20)%3B »/]

Améliorer l’intégration des custom post types : flux RSS et boucle principale (ch.27.)

Ces codes permettent de mieux intégrer les custom post types dans le reste de votre site WordPress

© 2013-2023 Optimiser son référencement WordPress, le livre - Par Daniel Roch


Theme by Anders NorenHaut de page ↑