<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Also, when you use something like:<br>
<br>
get_template_part( 'dir/slug' )<br>
<br>
You create a weird hook:<br>
<br>
get_template_part_dir/slug<br>
<br>
On 4/23/2011 11:56 AM, Justin Tadlock wrote:
<blockquote cite="mid:4DB304A0.6080101@justintadlock.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
get_template_part() was never meant to allow anything other than a
slug (not a directory and slug). Westi (who created the function)
has stated that this should be considered a bug. If you look at
the inline documentation for get_template_part() in the
wp-includes/general-template.php file, the documentation clearly
states that the first parameter of the function should be a
*slug*.<br>
<br>
Basically, get_template_part() is a generic version of
get_header(), get_footer(), and get_sidebar(). It's meant to work
in a similar fashion with the difference being that you can also
define the slug. <br>
<br>
There is a ticket trying to address the issue of sub-directories
and get_template_part() right now:<br>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://core.trac.wordpress.org/ticket/15086">http://core.trac.wordpress.org/ticket/15086</a><br>
<br>
Until that ticket has been closed and a resolution decided upon,
locate_template() would be the most correct option for including
templates within sub-directories.<br>
<br>
Now, for the question of including CSS files, neither of the
functions should be used. CSS files must use the URI path, but
those functions will use the directory path. You should always
use get_stylesheet_directory_uri() or get_template_directory_uri()
(depending on the scenario).<br>
<br>
On 4/22/2011 11:37 AM, Chip Bennett wrote:
<blockquote
cite="mid:BANLkTikkK8UX3VTCUnb0cVM=oBmBcrgAFA@mail.gmail.com"
type="cite">I believe the use of get_template_part() is
acceptable for including files in subdirectories.
<div><br>
</div>
<div>However, CSS should *always* be enqueued and output via the
wp_print_styles hook, rather than dumped directly into the
template.</div>
<div><br>
</div>
<div>Chip<br>
<br>
<div class="gmail_quote">On Fri, Apr 22, 2011 at 11:34 AM,
Curtis McHale <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:curtis@curtismchale.ca">curtis@curtismchale.ca</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;"> I'm reviewing a theme and I've found
uses of get_template_part where I believe that
locate_template is the proper item. Specifically the code
below loads the custom stylesheet.
<div><br>
</div>
<div>
<div><?php get_template_part('css/custom-css')?></div>
<div><br>
</div>
<div>It was my understanding that in this case we should
use:</div>
<div><br>
</div>
<div><?php locate_template( array(
'/css/custom-css.css' ), 1); ?></div>
<div><br>
</div>
<div>and that get_template part was to call a file in
the same directory like loop-main.php. Is there
established best practice and if so what is it? Is the
use above an okay way to call a custom stylesheet in
to the theme? If not what way is currently advised?</div>
<br>
Curtis McHale<br>
PH: 604.751.3482<br>
<a moz-do-not-send="true"
href="http://www.curtismchale.ca" target="_blank">http://www.curtismchale.ca</a><br>
Linkedin: <a moz-do-not-send="true"
href="http://www.linkedin.com/in/curtismchale"
target="_blank">http://www.linkedin.com/in/curtismchale</a><br>
Twitter: <a moz-do-not-send="true"
href="http://twitter.com/curtismchale" target="_blank">twitter.com/curtismchale</a><br>
<br>
</div>
<br>
_______________________________________________<br>
theme-reviewers mailing list<br>
<a moz-do-not-send="true"
href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a><br>
<a moz-do-not-send="true"
href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers"
target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<pre wrap=""><fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
theme-reviewers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a>
</pre>
</blockquote>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
theme-reviewers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a>
<a class="moz-txt-link-freetext" href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a>
</pre>
</blockquote>
</body>
</html>