开发者

What function do I use to get the post text?

开发者 https://www.devze.com 2023-01-29 14:54 出处:网络
I\'m us开发者_JAVA百科ing the function: <?php the_title(); ?> To get the post title. I want to get the post text/the body which is the second field of the post but I don\'t know how. I tried

I'm us开发者_JAVA百科ing the function:

<?php the_title(); ?>

To get the post title. I want to get the post text/the body which is the second field of the post but I don't know how. I tried two functions:

<?php the_content(); ?> and <?php the_excerpt(); ?>

They work but I get other things from wordpress plugins that are part of my post (like share buttons). I cannot disable these plugins. Is there any way to get what is in the second field without anything else?


I think your problem is that the_content() runs all the filters attached to the_content. Try calling get_the_content(), and echo its return:

<?php echo get_the_content() ?>

If you want the filters applied, you can call:

<?php apply_filters('the_content',get_the_content()) ?>


You might have a social media plugin installed that automatically adds facebook buttons etc. Have a peek inside your admin panel > plugins for any such plugin


A down-and-dirty way to hide the share plugin on certain posts could be using some simple jQuery like this:

$('post-id share-div-id-or-class').hide();

Not ideal, but other than modifying the plugin directly, you may not have a choice. You could repeat the above line for every post where you want to hide the sharing plugin.

0

精彩评论

暂无评论...
验证码 换一张
取 消