function – XTRA Tutorials https://xtratheme.com/docs Documentation of XTRA WordPress Theme Fri, 20 Sep 2024 18:00:33 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.2 How to Safely Add PHP Code to WordPress Theme’s functions.php Using a Child Theme? https://xtratheme.com/docs/how-to/how-to-safely-add-php-code-to-wordpress-themes-functions-php-using-a-child-theme/ https://xtratheme.com/docs/how-to/how-to-safely-add-php-code-to-wordpress-themes-functions-php-using-a-child-theme/#respond Tue, 17 Sep 2024 07:53:20 +0000 https://xtratheme.com/docs/?p=4247

Description

Step 1
Xtra

Using Child Theme

  1. Download Child theme from package
  2. Install Child Theme and Active It
  3. Find and edit the functions.php file of the child theme
  4. Add your custom PHP code below the existing codes in the file, then Save it
  5. Test the Changes

    Once you’ve added the PHP code to the functions.php file of the child theme, it’s important to test the website to ensure everything works properly. Clear your browser cache or test in an incognito window.
    If you encounter any issues, you can always access the child theme’s functions.php file via FTP or the hosting File Manager to revert any problematic changes.

Tip

You might also be interested to know…

You might also be interested to know that adding PHP code to the functions.php file of a WordPress theme through a WordPress child theme is the best way to preserve your changes. Not only does it prevent your modifications from being overwritten during theme updates, but it also ensures the security and stability of your site.

]]>
https://xtratheme.com/docs/how-to/how-to-safely-add-php-code-to-wordpress-themes-functions-php-using-a-child-theme/feed/ 0
How to Find and Edit header.php or footer.php in Theme? https://xtratheme.com/docs/how-to/how-to-find-and-edit-header-php-or-footer-php-in-theme/ https://xtratheme.com/docs/how-to/how-to-find-and-edit-header-php-or-footer-php-in-theme/#respond Tue, 10 Sep 2024 12:49:57 +0000 https://xtratheme.com/docs/?p=4170

Description

Step 1
Xtra

Editing header.php and footer.php

In WordPress, the header.php and footer.php files are part of the theme files responsible for displaying your site’s header and footer sections. Here’s how you can locate and edit these files:

Steps to Find header.php or footer.php:

1. Via WordPress Dashboard:

  • Go to your WordPress Dashboard.
  • Navigate to Appearance > Theme File Editor.
  • On the right-hand side, you will see a list of theme files. Look for header.php or footer.php under Theme Files.
  • Click on the file you want to view or edit.

2. Via FTP or Hosting File Manager:

  • Access your website files through FTP (using a client like FileZilla) or through your hosting provider’s File Manager.
  • Go to the /wp-content/themes/ directory.
  • Open the folder of the active theme you are using.
  • Find header.php and footer.php files and download or edit them.

Important Tip: Avoid Directly Editing header.php and footer.php

While it is possible to edit header.php and footer.php directly, it is not recommended because any custom changes will be overwritten when the theme is updated. Instead, you should use WordPress action hooks like wp_body_open() and wp_footer() to add custom code.

]]>
https://xtratheme.com/docs/how-to/how-to-find-and-edit-header-php-or-footer-php-in-theme/feed/ 0
What is the generate_page() Function in Theme? https://xtratheme.com/docs/developer/what-is-the-generate_page-function-in-theme/ https://xtratheme.com/docs/developer/what-is-the-generate_page-function-in-theme/#respond Tue, 10 Sep 2024 10:39:14 +0000 https://xtratheme.com/docs/?p=4167

Description

Step 1
Xtra

The theme generate_page() function

The generate_page() function in our WordPress theme is not a default or built-in function from WordPress and its premium function to generate all pages in our theme. Only way to edit it is using theme functions.php file and we do not recommend it, because you will lose your changes after any theme and plugins updates.

 

If you want to edit any part of it, We recommend you use WordPress and theme built-in filters and actions. For example if you want to edit content, you can use WordPress the_content filter. If you want to edit or add something before or after any sections in pages, single posts, products, etc. We recommend you first check Developer posts from top menu, if you can’t find your solution then ask it from chatGPT, it will give you a WordPress filter or action for this purpose.

]]>
https://xtratheme.com/docs/developer/what-is-the-generate_page-function-in-theme/feed/ 0