admin管理员组

文章数量:1406178

In single.php, inside the loop the code shows text output.

<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
$content = get_the_content();
$content = apply_filters('the_content', $content);
echo wp_strip_all_tags($content);
$Temp_text=wp_strip_all_tags($content);

?>

Is there any way to use $Temp_text in functions.php.

In single.php, inside the loop the code shows text output.

<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
$content = get_the_content();
$content = apply_filters('the_content', $content);
echo wp_strip_all_tags($content);
$Temp_text=wp_strip_all_tags($content);

?>

Is there any way to use $Temp_text in functions.php.

Share Improve this question edited Nov 24, 2019 at 13:40 cjbj 15k16 gold badges42 silver badges89 bronze badges asked Nov 24, 2019 at 13:21 NARAYAN CHANGDERNARAYAN CHANGDER 1012 bronze badges 2
  • you want to use the content of a post ? what do you want to do with it ? – Kaperto Commented Nov 24, 2019 at 13:30
  • I want to create the title, description , and keyword from this text and pass it to SEO. I am using YOAST SEO. – NARAYAN CHANGDER Commented Nov 24, 2019 at 13:44
Add a comment  | 

1 Answer 1

Reset to default 0

I don't undesrtand well what you want to do. You mean this??? (the last line):

<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
$content = get_the_content();
$content = apply_filters('the_content', $content);
echo wp_strip_all_tags($content);
$Temp_text=wp_strip_all_tags($content);

do_something($Temp_text);

?>

And implement do_something() inside functions.php

本文标签: loopHow to use singlephp output in functionphp