{"id":100,"date":"2017-02-17T00:00:00","date_gmt":"2017-02-16T18:30:00","guid":{"rendered":"https:\/\/git-staging.wpastra.com\/docs\/?p=100"},"modified":"2021-09-08T21:30:50","modified_gmt":"2021-09-08T16:00:50","slug":"using-hooks","status":"publish","type":"docs","link":"https:\/\/git-staging.wpastra.com\/es\/docs\/using-hooks\/","title":{"rendered":"Uso de ganchos en Astra"},"content":{"rendered":"<h3 class=\"wp-block-heading\">Descripci\u00f3n<\/h3>\n\n\n\n<p>Los ganchos te permiten a\u00f1adir funcionalidad extra en varias \u00e1reas dentro del tema. Por ejemplo, puede que quieras mostrar alg\u00fan mensaje promocional debajo de todas las entradas de tu blog. Los ganchos hacen que estas cosas din\u00e1micas sean posibles.<\/p>\n\n\n\n<p>Astra utiliza <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/add_action\/#description\">API de ganchos de WordPress<\/a>&nbsp;para insertar varios ganchos a lo largo del tema.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"usage\">Utilizaci\u00f3n<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">add_action( 'hook_name','callback_function_name' );\nfunction nombre_de_la_funci\u00f3n_de_retorno () { ?&gt;\n \/\/ Inserta aqu\u00ed el contenido de tu hook.\n&lt;?php }<\/pre>\n\n\n\n<p>En el ejemplo anterior, sustituya hook_name por el valor <a href=\"https:\/\/developers.wpastra.com\/theme-visual-hooks\/\">nombre del gancho<\/a> que desea utilizar, como <strong>astra_header_before <\/strong>o <strong>astra_header_after<\/strong>. A continuaci\u00f3n, sustituya callback_function_name por un nombre de funci\u00f3n \u00fanico y significativo, algo espec\u00edfico para usted.<\/p>\n\n\n\n<p>A <a href=\"https:\/\/developers.wpastra.com\/theme-visual-hooks\/\">ver la lista de ganchos disponibles en Astra Visually<\/a>visite el sitio que hemos creado.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span id=\"Example\" class=\"mw-headline\">Ejemplo<\/span><\/h3>\n\n\n\n<p>En <strong>astra_header_before<\/strong>&nbsp;se ejecuta justo antes de la cabecera del sitio.<\/p>\n\n\n\n<p><strong>Nota: <\/strong>Cabecera del sitio - <header id=\"masthead\">.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">A\u00f1ade PHP a tu cabecera<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ A\u00f1adir scripts a astra_header_before()\nadd_action( 'astra_header_before', 'add_script_before_header' );\nfunction add_script_before_header() {\n    \/\/ Tu PHP va aqu\u00ed\n}<\/pre>\n\n\n\n<p>o...<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">A\u00f1ade HTML a tu cabecera<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ A\u00f1adir contenido a astra_header_before()\nadd_action( 'astra_header_before', 'add_content_before_header' );\nfunction add_content_before_header() { ?&gt;\n      <!-- Tu HTML va aqu\u00ed -->\n&lt;?php }\n<\/pre>\n\n\n\n<p>Si est\u00e1 a\u00f1adiendo PHP a astra_header_before(), utilice el primer m\u00e9todo. Utilice el segundo m\u00e9todo para cualquier otra cosa que vaya a a\u00f1adir.<\/p>\n\n\n\n<p>Echa un vistazo a la documentaci\u00f3n que explica c\u00f3mo a\u00f1adir c\u00f3digo PHP personalizado utilizando la funci\u00f3n <a href=\"https:\/\/git-staging.wpastra.com\/es\/docs\/add-custom-php-code\/#3.-in-child-theme\">functions.php del tema hijo<\/a> archivo.&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>Los Ganchos de Descripci\u00f3n le permiten a\u00f1adir funcionalidad extra en varias \u00e1reas dentro del tema. Por ejemplo, podr\u00edas querer mostrar alg\u00fan mensaje promocional debajo de todas las entradas de tu blog. Los ganchos hacen posible este tipo de cosas din\u00e1micas. Astra usa la API de Hooks de WordPress para insertar varios hooks a lo largo del tema. Usage add_action( 'hook_name','callback_function_name' ); function callback_function_name () { ?&gt; \/\/ [...]<\/p>","protected":false},"author":6,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"","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":"","theme-transparent-header-meta":"default","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":"","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":""},"docs_category":[2109],"docs_tag":[],"class_list":{"0":"post-100","1":"docs","2":"type-docs","3":"status-publish","5":"docs_category-astra-theme-pro-filters"},"spectra_custom_meta":{"_wp_old_slug":[""],"_wp_page_template":["default"],"wpil_sync_report3":["1"],"wpil_links_inbound_internal_count":["0"],"wpil_links_inbound_internal_count_data":["a:0:{}"],"wpil_links_outbound_internal_count":["1"],"wpil_links_outbound_internal_count_data":["a:1:{i:0;a:9:{s:3:\"url\";s:75:\"https:\/\/git-staging.wpastra.com\/docs\/add-custom-php-code\/#3.-in-child-theme\";s:8:\"url_real\";s:75:\"https:\/\/git-staging.wpastra.com\/docs\/add-custom-php-code\/#3.-in-child-theme\";s:4:\"host\";s:11:\"wpastra.com\";s:9:\"host_real\";s:11:\"wpastra.com\";s:8:\"internal\";b:1;s:7:\"post_id\";i:0;s:6:\"anchor\";s:27:\"child theme's functions.php\";s:15:\"added_by_plugin\";b:0;s:10:\"post_title\";s:0:\"\";}}"],"wpil_links_outbound_external_count":["3"],"wpil_links_outbound_external_count_data":["a:3:{i:0;a:9:{s:3:\"url\";s:75:\"https:\/\/developer.wordpress.org\/reference\/functions\/add_action\/#description\";s:8:\"url_real\";s:75:\"https:\/\/developer.wordpress.org\/reference\/functions\/add_action\/#description\";s:4:\"host\";s:23:\"developer.wordpress.org\";s:9:\"host_real\";s:23:\"developer.wordpress.org\";s:8:\"internal\";b:0;s:7:\"post_id\";i:0;s:6:\"anchor\";s:24:\"WordPress Hooks&nbsp;API\";s:15:\"added_by_plugin\";b:0;s:10:\"post_title\";s:0:\"\";}i:1;a:9:{s:3:\"url\";s:50:\"https:\/\/developers.wpastra.com\/theme-visual-hooks\/\";s:8:\"url_real\";s:50:\"https:\/\/developers.wpastra.com\/theme-visual-hooks\/\";s:4:\"host\";s:22:\"developers.wpastra.com\";s:9:\"host_real\";s:22:\"developers.wpastra.com\";s:8:\"internal\";b:0;s:7:\"post_id\";i:0;s:6:\"anchor\";s:16:\"name of the hook\";s:15:\"added_by_plugin\";b:0;s:10:\"post_title\";s:0:\"\";}i:2;a:9:{s:3:\"url\";s:50:\"https:\/\/developers.wpastra.com\/theme-visual-hooks\/\";s:8:\"url_real\";s:50:\"https:\/\/developers.wpastra.com\/theme-visual-hooks\/\";s:4:\"host\";s:22:\"developers.wpastra.com\";s:9:\"host_real\";s:22:\"developers.wpastra.com\";s:8:\"internal\";b:0;s:7:\"post_id\";i:0;s:6:\"anchor\";s:49:\"see the list of hooks available in Astra Visually\";s:15:\"added_by_plugin\";b:0;s:10:\"post_title\";s:0:\"\";}}"],"wpil_sync_report2_time":["2019-09-05T12:02:11+00:00"],"_edit_lock":["1685896205:86"],"_edit_last":["70"],"onesignal_meta_box_present":["1"],"onesignal_send_notification":[""],"site-sidebar-layout":["default"],"site-content-layout":["default"],"theme-transparent-header-meta":["default"],"_yoast_wpseo_content_score":["90"],"_ppc_meta_key":["a:8:{s:20:\"ppc_key5d92f85d42273\";s:60:\"Images &amp; Names Correctly. Title &amp; Alt Tags are Given\";s:8:\"ppc_key4\";s:15:\"Formatting Done\";s:8:\"ppc_key2\";s:23:\"Featured Image Assigned\";s:8:\"ppc_key3\";s:17:\"Category Selected\";s:8:\"ppc_key5\";s:15:\"Title is Catchy\";s:8:\"ppc_key6\";s:22:\"Social Images Assigned\";s:8:\"ppc_key7\";s:8:\"Done SEO\";s:8:\"ppc_key8\";s:28:\"Spelling and Grammar Checked\";}"],"tap_disable_autolinker":["no"],"tap_autolink_inside_heading":["global"],"tap_autolink_random_placement":["global"],"tap_post_autolinker_limit":["0"],"_yoast_wpseo_title":["How to Use Hooks in Astra?"],"_ht_kb_post_views_count":["19"],"_ht_kb_usefulness":["0"],"_ht_article_order_103":["100"],"wp_last_modified_info":["September 8, 2021 @ 9:30 PM"],"wplmi_shortcode":["[lmt-post-modified-info]"],"views":["10647"],"helpful":["13"],"unhelpful":["17"],"redirects":["10"],"_lmt_disableupdate":["no"],"_wplmi_last_modified":["2021-09-08 21:30:50"],"rank_math_title":["How to Use Hooks in Astra?"],"rank_math_news_sitemap_robots":["index"],"rank_math_robots":["a:1:{i:0;s:5:\"index\";}"],"rank_math_analytic_object_id":["1440"],"rank_math_internal_links_processed":["1"],"_trp_automatically_translated_slug_es_ES":["utilizando-ganchos"],"_uag_page_assets":["a:9:{s:3:\"css\";s:2495:\".wp-block-uagb-container.uagb-block-debf2792 .uagb-container__shape-top svg{width: calc( 100% + 1.3px );}.wp-block-uagb-container.uagb-block-debf2792 .uagb-container__shape.uagb-container__shape-top .uagb-container__shape-fill{fill: rgba(51,51,51,1);}.wp-block-uagb-container.uagb-block-debf2792 .uagb-container__shape-bottom svg{width: calc( 100% + 1.3px );}.wp-block-uagb-container.uagb-block-debf2792 .uagb-container__shape.uagb-container__shape-bottom .uagb-container__shape-fill{fill: rgba(51,51,51,1);}.wp-block-uagb-container.uagb-block-debf2792 .uagb-container__video-wrap video{opacity: 1;}.wp-block-uagb-container.uagb-is-root-container .uagb-block-debf2792{max-width: 100%;width: 100%;}.wp-block-uagb-container.uagb-is-root-container.alignfull.uagb-block-debf2792 > .uagb-container-inner-blocks-wrap{--inner-content-custom-width: min( 100%, 1200px);max-width: var(--inner-content-custom-width);width: 100%;flex-direction: column;align-items: center;justify-content: center;flex-wrap: nowrap;row-gap: 0px;column-gap: 0px;}.wp-block-uagb-container.uagb-block-debf2792{box-shadow: 0px 0px   #00000070 ;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;margin-top: 0px !important;margin-bottom: 0px !important;margin-left: 0px;margin-right: 0px;overflow: visible;border-color: inherit;row-gap: 0px;column-gap: 0px;}@media only screen and (max-width: 976px) {.wp-block-uagb-container.uagb-is-root-container .uagb-block-debf2792{width: 100%;}.wp-block-uagb-container.uagb-is-root-container.alignfull.uagb-block-debf2792 > .uagb-container-inner-blocks-wrap{--inner-content-custom-width: min( 100%, 1024px);max-width: var(--inner-content-custom-width);width: 100%;}.wp-block-uagb-container.uagb-block-debf2792{padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;margin-top: 0px !important;margin-bottom: 0px !important;margin-left: 0px;margin-right: 0px;}}@media only screen and (max-width: 767px) {.wp-block-uagb-container.uagb-is-root-container .uagb-block-debf2792{max-width: 100%;width: 100%;}.wp-block-uagb-container.uagb-is-root-container.alignfull.uagb-block-debf2792 > .uagb-container-inner-blocks-wrap{--inner-content-custom-width: min( 100%, 767px);max-width: var(--inner-content-custom-width);width: 100%;flex-wrap: wrap;}.wp-block-uagb-container.uagb-block-debf2792{padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;margin-top: 0px !important;margin-bottom: 0px !important;margin-left: 0px;margin-right: 0px;}}\";s:2:\"js\";s:0:\"\";s:18:\"current_block_list\";a:5:{i:0;s:12:\"core\/heading\";i:1;s:14:\"core\/paragraph\";i:2;s:17:\"core\/preformatted\";i:3;s:14:\"uagb\/container\";i:4;s:14:\"core\/shortcode\";}s:8:\"uag_flag\";b:1;s:11:\"uag_version\";s:10:\"1776934010\";s:6:\"gfonts\";a:0:{}s:10:\"gfonts_url\";s:0:\"\";s:12:\"gfonts_files\";a:0:{}s:14:\"uag_faq_layout\";b:0;}"]},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"trp-custom-language-flag":false},"uagb_author_info":{"display_name":"Swapnil","author_link":"https:\/\/git-staging.wpastra.com\/es\/author\/swapnild\/"},"uagb_comment_info":0,"uagb_excerpt":"Description Hooks&nbsp;allow you to add extra functionality at various areas inside the theme. For example, you might want to display some promotional message below all of your blog posts. Hooks make such dynamic things possible. Astra uses WordPress Hooks&nbsp;API&nbsp;to insert various hooks throughout the theme. Usage add_action( 'hook_name','callback_function_name' ); function callback_function_name () { ?&gt; \/\/&hellip;","_links":{"self":[{"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs\/100"}],"collection":[{"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":0,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs\/100\/revisions"}],"wp:attachment":[{"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs_category?post=100"},{"taxonomy":"docs_tag","embeddable":true,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs_tag?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}