如何在我的functions.php代碼中添加圖庫短代碼到Wordpress中的內容?我在這裏使用的數字是硬編碼的,但最終會是動態的。這是我正在嘗試,但似乎沒有工作。在Wordpress Functions.php中添加圖庫短代碼
add_filter('the_content', 'wpse6034_the_content');
function wpse6034_the_content($content)
{
$gallery_shortcode = '[gallery ids="282,283,284"]';
$content .= '<p>Hello World!!!!</p>'.$gallery_shortcode;
return $content;
}
你是否試圖將此附加到所有wp文章? – technology101010
沒有事件只會是一個特定的自定義帖子類型,將追加到 – user520300
自定義帖子類型也將受到密碼保護,所以與畫廊的內容不應該顯示,除非提供有效密碼 – user520300