Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 631 Vote(s) - 3.62 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What's the difference between get_stylesheet_directory_uri() and get_template_directory_uri() when enqueuing scripts in wordpress

#1
It's not a serious question.

I normally use `get_stylesheet_directory_uri()` when enqueuing scripts in WordPress, which worked fine so far.

I just wonder what's the difference between `get_stylesheet_directory_uri()` and `get_template_directory_uri()` when enqueuing scripts in wordpress.

**According to WordPress Codex:**

- `get_template_directory_uri` -> Retrieve template directory URI for the
current theme.
- `get_stylesheet_directory_uri` ->Retrieve stylesheet directory URI for
the current theme/child theme

Then, `get_template_directory_uri` cannot be used for a child theme?
Reply

#2
Both functions can be used in a parent or a child theme.

[get_template_directory_uri][1] will always refer to the parent theme folder for assets.

[get_stylesheet_directory_uri][2] will refer to the "current" theme folder for assets (which could be the parent or the child, depending on where it is called).


For example, in a child theme:

// This will point to style.css in child theme
wp_enqueue_style( 'my_child_styles', get_stylesheet_directory_uri().'/style.css' );

// This will point to style.css in the parent theme
wp_enqueue_style( 'my_parent_styles', get_template_directory_uri().'/style.css' );

Note that if a theme is not a child theme, then it is considered a parent theme.

[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through