if/else 함수를 추가하기 위해 Wordpress functions.php에서 PHP 코드 조각을 편집하려고합니다.If/Else 규칙을 functions.php에 추가하십시오.
내 현재 코드는 다음과 같습니다
add_filter('the_content','add_my_content');
function add_my_content($content) {
$my_custom_text = '<hr><div class="patreonpara"><p><em>PARAGRAPH TEXT</em></p><a href="LINKURL" data-patreon-widget-type="become-patron-button" class="patreonbutton"><img src="FILEURL"></a></div>'; //
if(is_single() && !is_home()) {
$content .= $my_custom_text;
}
return $content;
}
는 내가 추가 할 것은 범주가 '스포츠'인 경우 위의 다른 버전을 표시하는 규칙이다.
나는 몇 가지 시도했지만 작동하지 않을 수 있습니다, 나는 PHP로 진짜 초보자입니다.
이 가이드는 온라인 상태이지만 각 섹션에 규칙을 적용하면 작동하지 않아 functions.php 파일이 손상되었습니다. 따라서 분명히 잘못된 것이 있거나 코드가 적용되지 않습니다.
<?php if(in_category('videos')) : ?>
// show video
<?php else: ?>
// show the other thing you want
<?php endif ?>
도움이 매우 감사 할 것입니다.
당신의 시도를 보여주십시오 ... –
https://developer.wordpress.org/reference/functions/is_category/ –
@ B.Desai 제가 사용한 코드를 찾으려고 노력할 것입니다. 그것은 functions.php 파일을 깨뜨렸고 삭제해야했기 때문에 분명히 올바르게 수행되지 않았습니다. –