admin管理员组文章数量:1389897
I'am createing my own theme. I want to use shortcodes but they're not working. If I enter them in a post I juste get the shortcode name whit brackets.
To display the code I use this function:
function post_content($page = null){
//Define variables
$page = get_post($page);
$userData = get_userdata($page->post_author);
$months_german = array(1 => 'Januar', 2 => 'Februar', 3 => 'März.', 4 => 'April', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember');
/*
* Create page content
*/
$html = '<div class="post-container">';
//If the page has an featured image, display it
if(get_the_post_thumbnail_url($page)){
$html .= '<div class="header-image" style="background-image: url(\''.get_the_post_thumbnail_url($page).'\')"></div>';
}
//Start with content
$html .= '<div class="content">';
//General information (Title, date, author)
$html .= '<div class="headline">';
$html .= '<h1 class="title">'.$page->post_title.'</h1>';
$html .= '<span class="time-author">'.date("j", strtotime($page->post_date)).' '.$months_german[date("n", strtotime($page->post_date))].' '.date("Y H:i", strtotime($page->post_date)).' | von '.$userData->display_name.'</span>';
$html .= '</div>';
//Start maincontent
$html .= '<div class="text">'.$page->post_content.'</div>';
$html .= '</div>';
$html .= '</div>';
echo $html;
}
To create a shortcode I use this function:
function lorem_function(){
return "<p>Lorem Ipsum dolor sit amet</p>";
}
add_shortcode('lorem', 'lorem_function');
if I execute the following function in the index.php file the shortcut works very well:
echo do_shortcode('[codeworks]');
I use both functions in the functions.php file.
Thank you for your support.
本文标签: Theme does not allow shortcodes
版权声明:本文标题:Theme does not allow shortcodes 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744652152a2617748.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论