colap Posted June 7, 2015 Share Posted June 7, 2015 https://core.trac.wordpress.org/browser/branches/4.2/src/wp-content/themes/twentyfifteen/content.php When is content.php called? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/296688-when-is-contentphp-called-in-wordpress-twentyfifteen-theme/ Share on other sites More sharing options...
QuickOldCar Posted June 7, 2015 Share Posted June 7, 2015 In index.php of that theme or other wordpress themes usually, unless they include other files or functions special for a theme. get_template_part() is the function that includes other files into the template. In twentyfifteen theme it's get_template_part( 'content', get_post_format() ); Quote Link to comment https://forums.phpfreaks.com/topic/296688-when-is-contentphp-called-in-wordpress-twentyfifteen-theme/#findComment-1513401 Share on other sites More sharing options...
colap Posted June 8, 2015 Author Share Posted June 8, 2015 In index.php of that theme or other wordpress themes usually, unless they include other files or functions special for a theme. get_template_part() is the function that includes other files into the template. In twentyfifteen theme it's get_template_part( 'content', get_post_format() ); If get_post_format() returns "Standard" format, then will it be "content-get_post_format()" ? Quote Link to comment https://forums.phpfreaks.com/topic/296688-when-is-contentphp-called-in-wordpress-twentyfifteen-theme/#findComment-1513428 Share on other sites More sharing options...
QuickOldCar Posted June 8, 2015 Share Posted June 8, 2015 get_post_format() actually returns a true/false boolean. Wordpress theme functions consider this as standard. get_template_part('content',get_post_format());would beget_template_part('content',false); Since get_template_part expects a string, you would leave it empty or add a string name there.If you wanted to keep it the same throughout a theme could define format as standard with a check. $format = get_post_format();//boolean true/false //do a check for true or false and assign it a string if ( false === $format ) { $format = 'standard'; } get_template_part( 'content', $format ); The second function variable is optional, but if used the code above would look for content-standard.php, adding it to the content area.So add a file named content-standard.php If you want to assign get_template_part() with different strings, should use get_post_format_string() get_post_format_string('standard'); And here is the function within wordpress post-formats.php for that to see your available options function get_post_format_strings() { $strings = array( 'standard' => _x( 'Standard', 'Post format' ), // Special case. any value that evals to false will be considered standard 'aside' => _x( 'Aside', 'Post format' ), 'chat' => _x( 'Chat', 'Post format' ), 'gallery' => _x( 'Gallery', 'Post format' ), 'link' => _x( 'Link', 'Post format' ), 'image' => _x( 'Image', 'Post format' ), 'quote' => _x( 'Quote', 'Post format' ), 'status' => _x( 'Status', 'Post format' ), 'video' => _x( 'Video', 'Post format' ), 'audio' => _x( 'Audio', 'Post format' ), ); return $strings; } Quote Link to comment https://forums.phpfreaks.com/topic/296688-when-is-contentphp-called-in-wordpress-twentyfifteen-theme/#findComment-1513431 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.