Questions tagged [the-content]

Displays the contents of the current post. This template tag must be used within The_Loop.

Filter by
Sorted by
Tagged with
1
vote
1answer
46 views

Content vs Template on custom post

I just wrote a custom post (suppliers) as a plugin (with meta content) that works great. I've also created a template page (single-suppliers.php) within the same plugin to display the data. I wrote it ...
0
votes
1answer
100 views

Apply a filter str_replace on specific caracters array in the_content()

I am trying to create a filter for the_content() where I would be able to aply a str_replace() on specific caracters array(). At the moment, I have it working for only one caracter. I would like to ...
1
vote
2answers
83 views

Add content as soon <body> starts

So, what I am trying to do is creating a slideshow plugin that won't require end user to write a single line of code. I can't use custom posts because I need to keep it simple for the end user. Is ...
-1
votes
1answer
162 views

append code after the_content not working

Goal: Add pagination below single post pages. Code function add_pagin( $content ) { if ( is_singular('post') ) { $content .= previous_post_link() . next_post_link(); } return $...
0
votes
1answer
249 views

The_content and Preg_replace in loaded Iframe [closed]

The Problem: I try delete the tag generates by a iframe after is loaded. The iframe is for load a video but then it loads some tags like this <div role="contentinfo" class="dmp_VideoInfo dmp_is-...
0
votes
1answer
42 views

Don't allow JavaScript in the content area

Is there any way to disable or remove JavaScript in the page/post content area? So if there was any <script> tags it would remove them or ignore them when outputting the_content();
0
votes
1answer
254 views

get_post_fields as an excerpt

I have a strange question, I have built my site and my loop etc. But on my sidebar I want to add a sort of random post display, but I don't want the entire post to display, I've had some difficulties ...
0
votes
1answer
41 views

How to insert link, with lightbox, that opens specific page content only

I need insert link next to Woocommerce product addon label, that sould act as pop-up on clic, and open content of one specific page. I have successfully done it by js and hardcoded url. But: Pop up ...
22
votes
3answers
13k views

Split Content and Gallery

Is there a way to split up the post content and the gallery short code. I want to display the gallery outside my normal content no matter how or where it is placed. I can use this to get the shortcode ...
-1
votes
1answer
918 views

the_content() “crashes” for single pages

I have big trouble with the_content() for single.php. Whats my problem? the_content() doesn't give any output on single pages furthermore it crashes (no other PHP code below the function call is ...
0
votes
2answers
48 views

Load Posts' individual body content on index starting at char 200 of each post

I would like to have my index or posts overview page load each post teaser starting at char 206 of each post's body content. This as all posts start with a general introduction in the post body ...
0
votes
2answers
59 views

Extract links inside embed tags in WordPress

I am using the default WordPress embed to embed a couple of videos in the content. I want to extract the video link from [embed]https://www.youtube.com/watch?v=Z9QbYZh1YXY[/embed], can anyone help ...
0
votes
2answers
159 views

Looking to limit the number of characters on my post page

I want my posts to be limited to number characters. I want this to happen on the page that shows all my posts. I am using this snippet. The read more link also appears when you are viewing the single ...
0
votes
1answer
269 views

add_filter to the_content from plugin function

I am using myeffecto plugin for post reaction.The plugin shows emoticons using the_content hook.But i don't want to show it on every posts.i want it in a conditional if() statement the plugin uses: ...
0
votes
2answers
151 views

How can I display “read more” without any other post text?

I have created the Read more in my posts, but when I add the php tag <?php the_content(); ?> ...it shows the post content with read more button. I only want to display the button, with no ...
0
votes
1answer
256 views

$content is empty while using DOMDocument

I'm trying to modify the Image Output on my Wordpress-Site to replace src and srcset with their "data-" Equivalent while adding an additional class. Therefor I'm using DOMDocument and filter for imgs. ...
0
votes
1answer
42 views

Excerpt is being added above the content, but it should be after it

I have this code in my functions.php file to display the excerpt of every post right below the content of every post. But, for some reason the Excerpt is appearing above the Content when it should be ...
1
vote
1answer
74 views

WordPress get_the_content get child element like p value

I am developing web site by wordpress in case my problem I want to remove h1 and h2 tag in from main page. I want to get only child p tag by get_the_content() <p id="main"> <?php echo ...
1
vote
1answer
4k views

shortcode not working and the relation to the_content()

Reference Post (I was even downvoted here.) My short code was not working on my custom theme, but the same short code, when used in twenty fifteen, was working. I researched over google and found ...
0
votes
1answer
675 views

first paragraph of the_content as meta description

I was trying to use the_content as my meta description, however, i noticed that the texts/content is way too many so I'm thinking if it's possible to use the first paragraph only? Here's the code I'm ...
0
votes
1answer
37 views

Separate Content from gallery (custom post type)

i have a php file (single-model.php) who display in one div first the post content and than the gallery in thumbs. How can split the content from gallery and display the gallery in diferent div ..? ...
1
vote
1answer
901 views

Proper way to use get_the_content() in front-page.php and the content-home.php?

<div class="class1"> <ul> <li> <div class="class2"> <?php the_post_thumbnail( 'large') ?> </div> <...
0
votes
0answers
97 views

Can I add content before post content without using the_content filter

I am adding filter to add embed before post content, but don't want add to other places where called apply_filters("the_content"). So i need add embed before(after) post content without "the_content" ...
0
votes
1answer
310 views

after setup_postdata, the_content() only displays text before the read more tag

I'm building a traveling-page and i need to add the description of a train or a ship into the description of a trip. My code looks like this: <?php if (!empty(rwmb_meta("train_ship"))) { ?> ...
0
votes
1answer
62 views

Balance Tags to the_content Words Length

I have a category page that I need to show some of the content of a the posts with HTML tags such as images. Site - http://hoffwebsites.com/wp-hoff-testing/ms-conversations/ I have found this code ...
0
votes
2answers
2k views

Force the_content() to show full post in RSS feed

I'm making a custom RSS feed where I want the full article to display. The problem is that when I use the_content() to output the article, it will only show the excerpt if there is a 'more' tag in ...
3
votes
2answers
15k views

Static page homepage not showing the_content

I must be doing something wrong here. I setup my site with a static front page using front-page.php. I created a page in the admin with a title and chose the front-page.php in the template dropdown. ...
3
votes
1answer
7k views

Get excerpt from $post->post_content

I am modifying the output of a plugin using a filter, and the $post variable is available to me, so I can display the post content like so: <h3><?php echo $post->post_title; ?></h3&...
0
votes
2answers
3k views

strip_tags in get_the content

So, I tried to strip all the html tags in a string but I can't get it to work. This is my code snippet $content = get_the_content(); ...
0
votes
1answer
347 views

How to turn each phone number within the $content to a telephone link?

I am working on a webpage that lists all the access numbers our customers ask for. What I am trying to do is turn all the text phone numbers into telephone links through a php function rather than ...
0
votes
1answer
82 views

Remove P tag from images if aligncenter class is set

I am trying to create a function that will filter the_content depending on image alignment. So far I have this... function filter_ptags_on_images($content) { $content = preg_replace('/<p>\\s*?...
0
votes
1answer
70 views

Caching the_content calls

I am writing a very small cache plugin called Tiny Cache. It would cache only the_content() calls which take - I think - the longest time to generate during a page load. I am able to hook the_content ...
0
votes
1answer
14 views

Call the content help

I bought a template and uploaded it to my wordpress site. I can't seem to edit this page because of a 'call the content'. I have no experience of coding so is there something i can do? thank you - ...
0
votes
2answers
2k views

Remove a div with ID from the_content WordPress

I was trying to remove a div having some ID from the_content WordPress. I am trying to achieve something like this jQuery( "#some_id" ).remove(); but on server side, I don't have a clue how I can ...
0
votes
0answers
41 views

if CPT content is empty then

I need to be able to do something if the content is empty in a CPT. This works for standard WP posts using the following: if($post->post_content=="") { //Do something if there is content is empty ...
0
votes
2answers
376 views

Extremely slow pageload for long post when using the_content?

My WordPress site has quite a few long posts that slow down page loading time exponentially. This only happens when using the post_content, for example, when using the the_content() and ...
1
vote
0answers
25 views

Short Overview in AMP Version and Link to full article non-amp [closed]

I want to setup amp version as short post around 60 words with link to full article's non-amp version is it possible ? without having duplicate content issues.
1
vote
1answer
1k views

Apply the_content filter, but prevent other hooked actions

I have a plugin that displays some content onto the front end of the site after applying the_content filter to the block of text. I do this for formatting and maintaining links and images etc. When I ...
6
votes
2answers
6k views

Are content.php and content-single.php the same?

I understand that when using get_template_part('content', get_post_format()); it will help choosing a post format for specific page according to post format. And if there is no post format 'i.e it's ...
1
vote
0answers
283 views

Run Shortcode of post's custom field in functions.php / Plugin

After 3 or 4 hours of searching the web for a solution, I abandoned it and hopefully you can help me? I added a sub-headline as a custom field (subheadlineclass). That works pretty. I can save, edit ...
2
votes
6answers
2k views

How to use wp_rel_nofollow to add nofollow to external links only?

I want to add nofollow attribute to only external links in the content of the post. Internal links should stay follow. So, can I use wp_rel_nofollow() to make only external links nofollow? Or do I ...
2
votes
1answer
99 views

Return array of images after content

I am trying to output a bunch of images after each post but I can only output one. add_filter( 'the_content', 'image_posts' ); function image_posts( $content ) { global $post; if ( ! $post ...
0
votes
2answers
932 views

Add div before the first paragraph the_content [closed]

I need to add a div before the first paragraph. Example: <div class="ads-site">ADS </div> <p>First Paragraph</p> <p>Second Paragraph</p> My Function: global $...
1
vote
1answer
119 views

$content variable - Is this a reserved variable for a Wordpress function? - php / wordpress

I'm just starting to have a dig around in the Wordpress codex because I'm undertaking my first simple plugin. Can I ask, is the $content variable a reserved variable for the_content() function. ...
0
votes
2answers
9k views

limit how many words show up in the_content on index

I'm having a heck of a time with this! I'm trying to force this page to only show a limited amount of words regardless if they insert a readmore tag. I was going to use the_excerpt, but it doesn't ...
5
votes
4answers
15k views

Removing any and all inline styles from the_content()

For one of my current projects, I had to transfer blogposts from an old Wordpress site to my project. Things went smoothly until I've seen that all the posts were copy pasted from Word, leaving this ...
0
votes
2answers
36 views

WordPress Add advertising ads befor and after content with periority [closed]

How we can use function with filter to add ads before and after content, Every ad has its priority. How we can use parameters at function then use it at filter This is the function function ...
0
votes
1answer
71 views

wp_content text length and displaying 'more' for the full text

(Using wordpress)I tried to find out what's the php code to display the length text of content and likely a clickable 'more' under the content to display my full content when somebody click (like in ...
2
votes
2answers
2k views

Content editor creating blank paragraphs in spaces and creating &nbsp in the_excerpt

I see that in other sites that use wordpress this does not happen, so I would like to know how to space without creating a blank paragraph or a &nbsp ? As you can see in the image, in each space ...
2
votes
2answers
2k views

Hook added to the_content seems to be called multiple times

I have the following code running in a plugin: add_filter('the_content','thousand_pay'); //Callback function function thousand_pay($content) { echo $content; if( !in_category( 'Stories') ) ...