{"id":1845,"date":"2024-08-03T08:43:59","date_gmt":"2024-08-03T06:43:59","guid":{"rendered":"https:\/\/blog.sutilweb.eu\/?page_id=1845"},"modified":"2024-08-03T08:44:00","modified_gmt":"2024-08-03T06:44:00","slug":"11-estructura-y-maquetacion-de-un-theme","status":"publish","type":"page","link":"https:\/\/sutilweb.eu\/index.php\/cmss-frameworks\/wordpress-2\/wordpress-avanzado\/11-estructura-y-maquetacion-de-un-theme\/","title":{"rendered":"11. Estructura y Maquetaci\u00f3n de un Theme"},"content":{"rendered":"\n<p>Vamos a empezar a trabajar con la estructura de contenido de WP y estructura de maquetaci\u00f3n. Vamos a crear los siguientes archivos:<\/p>\n\n\n\n<!--more-->\n\n\n\n<ul class=\"wp-block-list\">\n<li><em>header.php<\/em><\/li>\n\n\n\n<li><em>header-secundario.php<\/em><\/li>\n\n\n\n<li><em>content.php<\/em><\/li>\n\n\n\n<li><em>sidebar.php<\/em><\/li>\n\n\n\n<li><em>footer.php<\/em><\/li>\n<\/ul>\n\n\n\n<p>Vamos a empezar a seccionar el contenido de esta estructura de WP en varios archivos, as\u00ed es como trabaja WP. <strong>WP<\/strong> trabaja a trav\u00e9s del paso de variables. Se va a trabajar continuamente sobre el archivo <em>index.php.<\/em><\/p>\n\n\n\n<p>A nuestro <em>index.php<\/em> simplemente le agregamos una etiqueta de apertura <em>php<\/em> de la siguiente manera.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<\/pre>\n\n\n\n<p>La dejamos sin cerrar, la dejamos sin omitir.<\/p>\n\n\n\n<p>No hay una funci\u00f3n en <strong>WP<\/strong> que llame al contenido principal, tenemos que crear nuestro propio archivo.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mandar llamar a todos los archivos<\/h2>\n\n\n\n<p>Hay 3 funciones para ello:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><em>get_header()<\/em><\/strong>;<\/li>\n\n\n\n<li><strong><em>get_header(\u201csecundario\u201d)<\/em><\/strong>; \/\/ MUESTRA EL header_secundario.php QUE CREAMOS<\/li>\n\n\n\n<li><strong><em>get_sidebar()<\/em><\/strong> \/\/ SIDEBAR PRINCIPAL<\/li>\n\n\n\n<li><strong><em>get_sidebar(\u201csecundario\u201d);<\/em><\/strong> \/\/ SIDEBAR SECUNDARIO<\/li>\n\n\n\n<li><strong><em>get_footer();<\/em><\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Contenido principal<\/h2>\n\n\n\n<p>Utilizamos la funci\u00f3n <strong><em>get_template_part()<\/em><\/strong> ya sea por su <strong>slug<\/strong> o por su <strong>nombre,<\/strong> no es necesario poner la extensi\u00f3n <em>.php.<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">get_template_part('content'); \/\/ NO LE PONEMOS LA EXTENSI\u00d3N .php<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Otras funciones a utilizar<\/h2>\n\n\n\n<p>Existen otras funciones a utilizar como son:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><em>get_search_form();<\/em><\/strong><\/li>\n\n\n\n<li><strong><em>comments_templates();<\/em><\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Funciones de inclusi\u00f3n obligatorias<\/h2>\n\n\n\n<p>Hay dos funciones que debemos utilizar obligatoriamente en nuestros temas.&nbsp;<strong>Es important\u00edsimo ponerlas para que todo funcione bien.<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><em>wp_head()<\/em><\/strong>: debemos colocarlo antes del <strong><em>&lt;\/head><\/em><\/strong> (antes del cierre de la etiqueta).<\/li>\n\n\n\n<li><strong><em>wp_footer()<\/em><\/strong>: debemos colocarlo antes de <strong><em>&lt;\/body><\/em><\/strong> (antes del cierre de la etiqueta).<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Vamos a empezar a trabajar con la estructura de contenido de WP y estructura de maquetaci\u00f3n. Vamos a crear los [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1809,"menu_order":10,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-1845","page","type-page","status-publish","hentry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Sutil Web","author_link":"https:\/\/sutilweb.eu\/index.php\/author\/sutilweb\/"},"uagb_comment_info":0,"uagb_excerpt":"Vamos a empezar a trabajar con la estructura de contenido de WP y estructura de maquetaci\u00f3n. Vamos a crear los [&hellip;]","_links":{"self":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/comments?post=1845"}],"version-history":[{"count":2,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1845\/revisions"}],"predecessor-version":[{"id":1847,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1845\/revisions\/1847"}],"up":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1809"}],"wp:attachment":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/media?parent=1845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}