Site logo

Archived topic

add code to function.php

3 replies · Started by Mohamad on March 10, 2021

Viewing posts 1–4 of 4

Hi, I'm still new to element and to php in general. My question is can I add a code to functions.php using element?

I just want to add extra sitemap support for jetpack plugin and the plugin needs to read the following code from functions.php first:

function jeherve_add_cpt_sitemaps( $post_types ) {
    $post_types[] = 'your_post_type';
    return $post_types;
}
add_filter( 'jetpack_sitemap_post_types', 'jeherve_add_cpt_sitemaps' );

Hi there,

PHP snippets like this should be added to a child theme's functions.php or a Code Snippets plugin.
https://docs.generatepress.com/article/adding-php/

The Hook Element, while it can run PHP snippets as well, is for presentation purpose. It's for inserting actual HTML elements or shortcodes you intend to display on the page.

Thanks a lot for your kind reply. This makes sense to me now

No problem. :)

This archived topic is closed to new replies.