source

「」의 삭제"「」의 삭제"「」의 삭제" ★★★★★★★★★★★★★★★★★」 ★★★★★★★★★★★★★★★★★」 ★★★★★★★★★★★★★★★★★」WordPress 시 word word word wordWord..

itover 2023. 2. 18. 19:46
반응형

「」의 삭제"

★★★★★★★★★★★★★★★★★」
WordPress 시 word word word word

에 콘텐츠를 마다 WordPress와 같은 됩니다.<p> ★★★★★★★★★★★★★★★★★」<br/>출력에 여유 공간이 표시됩니다.래서그 그것 ?한 한?? ???모든 태그를 제거하려면 어떻게 해야 합니까?

WordPress가 입니다.wpautop. 파일 페이지

remove_filter( 'the_content', 'wpautop' );

remove_filter( 'the_excerpt', 'wpautop' );

상세한 것에 대하여는, http://codex.wordpress.org/Function_Reference/wpautop 를 참조해 주세요.

remove_filter 옵션을 사용하면 템플릿에서 태그와 마크업이 모두 삭제되므로 사용하지 않는 것이 좋습니다.

가장 좋은 방법은 PHP를 통해 문자열을 삭제하는 것입니다.

하려면 php 함수 strip_markups를 할 수 .hpp strip_markups는 strip_markups는 strip_markups를 합니다.echo strip_tags(get_the_excerpt()); // Get the raw text excerpt from the current post

또는

echo strip_tags(category_description()); // Get the raw text cat desc from the current cat page

호출 시 현재 워드프레스 게시물에서 HTML 태그를 모두 제거합니다.

, 자르다, 자르다, 자르기 기능은 과 같습니다.echo trim(strip_tags(get_the_excerpt())); // Get the raw text excerpt from the current post

또는

echo trim(strip_tags(category_description())); // Get the raw text cat desc from the current cat page

이는 HTML 마크업이 권장되지 않는 제목과 meta="description"에 대한 원시 텍스트를 가져오는 데 이상적입니다.

도움이 되었으면 좋겠다

이거 먹어봐

$my_postid = $post->ID;
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = strip_tags($content, '<p><br/>');
echo $content;

이 코드를 사용하여 편집기를 초기화하기 전에 제거합니다.

function tinymce_remove_root_block_tag( $init ) {
    $init['forced_root_block'] = false; 
    return $init;
}
add_filter( 'tiny_mce_before_init', 'tinymce_remove_root_block_tag' );

의 삭제wpautop이치노페이지 단위로 또는 투고별로 솔루션을 찾고 있는 경우는, 다음의 플러그 인을 사용할 수 있습니다.

https://wordpress.org/plugins/dont-muck-my-markup/

각 투고/페이지에 체크 박스가 추가되어 특정 페이지에 대해 코어 Wordpress 동작이 비활성화되는지 여부를 선택할 수 있습니다.

생성된 HTML 할 때 합니다.<br> ★★★★★★★★★★★★★★★★★」<p>세심하게 설계된 디자인을 엉망으로 만들어요.

플러그인에는 전역 옵션도 있으므로 모든 페이지/게시 시 기본적으로 이 동작을 해제할 수 있습니다.

대체 플러그인은 https://wordpress.org/plugins/preserve-code-formatting/입니다만, 설명한 플러그인만 사용해 보았습니다.

WP 4.8.1에서는 여기서 받아들여진 답변이 통하지 않아 저에게 도움이 되는 회피책을 게시합니다.p에 클래스를 추가해야 하는데 WordPress가 삭제되지 않습니다.

<p class="whatever">

는 WordPress 단락을 합니다.<p></p>태그를 카테고리 설명에 추가합니다.기능에 다음 항목을 추가하여 이를 중지합니다.php 파일

// Remove p tags from category description
remove_filter('term_description','wpautop');

심플하고 간단(코드 없음).

감사해요.

이 $sys= wp_filter_nohtml_kes($_POST['editor1'])를 사용합니다.

테마 기능에서 WordPress의 wpautop 기능을 제거하는 경우가 있습니다.php는 (어떤 이유로) 동작하지 않습니다.

그래서 다른 방법으로 제거를 중지합니다.<br>태그 또는 더블(<br><br>)의 행이 끊어집니다.

  1. 파일을 변경합니다./wp-content/themes/your_theme_name/functions.php

기능 상단에 두 줄을 추가합니다.

remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');

이 기능은 처음에 꺼집니다.wpautopop기능.

  1. 파일 변경/wp-includes/formatting.php기능하여wpautop.

    A) 변경function wpautop( $pee, $br = true)로.function wpautop( $pee, $br = false).

    이것은 추가로 꺼집니다.wpautopop모든 장소에서 기능합니다.

    B) 변경$pee = preg_replace('|<br\s*/?>\s*<br\s*/?>|', "\n\n", $pee);로.

    $pee1 = $pee;
    $pee = preg_replace('|<br\s*/?>\s*<br\s*/?>|', "\n\n", $pee);
    $pee = $pee1;
    

    이렇게 하면 시스템이 이중으로 분리되지 않습니다.<br>태그(코드가 이상하지만 간단한 건 알지만)//$pee때문에 도움이 되지 않는다?>태그 지정).

    C) 변경$pee = preg_replace("/\n\n+/", "\n\n", $pee);로.//$pee = preg_replace("/\n\n+/", "\n\n", $pee);

    이것에 의해, 시스템은 복수의 줄 바꿈을 제거할 수 없게 됩니다.

    D) 변경:

    $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
    

    다음과 같이 입력합니다.

    //$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
    

    이렇게 하면 다음과 같이 오픈 후 또는 클로징 블록 요소 태그 전에 시스템이 줄 바꿈을 제거하는 것을 방지할 수 있습니다.<div>,<article>,기타.

    E) 변경:

    $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
    

    다음과 같이 입력합니다.

    //$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
    

    거의 동일:이렇게 하면 다음과 같이 오픈 후 또는 클로징 블록 요소 태그 전에 시스템이 줄 바꿈을 제거하는 것을 방지할 수 있습니다.<div>,<article>,기타.

    F) 변경:

    $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
    

    다음과 같이 입력합니다.

    // $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
    

    이렇게 하면 시스템이 분리되지 않습니다.<br>그 블록의 끝에서

    G) 변경:

    $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
    

    다음과 같이 입력합니다.

    //$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
    

    이렇게 하면 시스템이 분리되지 않습니다.<br>블록 태그를 열거나 닫은 후.

도움이 되었으면 좋겠다!또, 이 파일의 코멘트를 읽어 주세요.이 코멘트를 사용하면, 온/오프 할 필요가 있는 것을 이해할 수 있습니다.

기능을 변경하지 않고 Wordpress post 또는 text area에서 p 태그를 삭제하려는 경우: css:와 같은 간단한 css-trick을 수행할 수 있습니다.

.container >p {
display:none;
}

html:

<div class = 'container'>
<!the p tag u dont want here!>
</div>

언급URL : https://stackoverflow.com/questions/6625458/removing-p-and-br-tags-in-wordpress-posts

반응형