Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [the-content]

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

0
votes
1answer
19 views

the_content(); of custom post type treated as an array or object

I created a custom post type in the mu-plugins folder. function wpdocs_codex_book_init() { $labels = array( 'name' => _x( 'Books', 'Post type general name', '...
0
votes
1answer
18 views

Add HTML before a specific div?

I bought the "Woocommere Checkout Add-Ons" Plugin, which adds upsells to the checkout page - but it only allows to place text after the upsell checkbox. So I got the idea to add an image with some ...
0
votes
1answer
50 views

WordPress adding content into different sections

What I'm trying to figure out is how I can get the content of a page displayed different div's. That means if I add two paragraphs in the editor I would like to display the first paragraph in div ...
1
vote
2answers
18 views

Inserting a functions output after the content

So I am trying to add a button at the end of my blog posts, here is the code I have in the plugin so far: <?php /* Plugin Name: etc.... */ function shares_content() { ?> <div class='...
1
vote
1answer
41 views

Responsive class to all the images in the content

I have used this function to add a responsive class to all the images in content but this breaks the html structure of the website. This wraps the content with : <!DOCTYPE html PUBLIC "-//W3C//DTD ...
0
votes
1answer
16 views

Set Microsoft Word links to open in new window/tab

I'm unable to set Word hyperlinks to open in a new window/tab. Basically, I create a Word document and paste its contents to WordPress, and everything is there, links do work, but they don't have "...
1
vote
1answer
76 views

How to count rows of table in the_content()

In fact, every post in custom post type contains just a table that has several different rows. Every row is important, so we want to count them by a function and I think it is possible by counting <...
1
vote
0answers
36 views

Gutenberg is Adding Additional HTML Tags When Grabbing the Excerpt

I am running into an issue with Gutenberg where I want to display the excerpt of a post, even when the excerpt field isn't filled in. Usually the functionality of WordPress is when the excerpt is ...
0
votes
0answers
24 views

Get post content before rendering

I am currently working on a shortcode function, where I need to access the content of a post, before its rendering. If I do it like this $content = get_the_content( get_the_ID() ); It gives me the ...
0
votes
1answer
44 views

Split the_content into two parts

I want to split the content of a post into two parts. The First part is in an <strong>-tag, it is like a excerpt and in the second part i want to display the rest of the content. But I don‘t ...
0
votes
0answers
19 views

Adding HTML every number of words in the content

I'm building a news website and i want to add a banner every 200 words inside the content. How can i add a plain html inside every article when calling the content function?
0
votes
2answers
28 views

How to replace text in hompage only

I have a wordpress site with the 10 latest posts shown on the homepage. I need to modify some text (because of duplicate content) on homepage but not on post page. I try to modify the following line ...
0
votes
0answers
15 views

the_content() breaks html while generating exceprt up to “more” tag

So I have a post with img src in it, after which goes the "more" tag. Something like this: text <img src= http://images.com/images/image.jpg> text <!--more--> more text Notice the space ...
-2
votes
1answer
25 views

Creating mixture of shortcodes to use in the visual/text editor

I am attempting to make a page on my site that has a mixture of different kinds of content. So I'd like for the first part to just be the_content, but then beneath it calls to posts under specific ...
0
votes
0answers
13 views

Title and date of last post stays on page even after replacing the_content

I'm doing a plugin that generates custom subpages (i.e. it's an app that has nothing to do with WPs posts). I did the rewrite thing (rewrite + query_vars + template_redirect), I generate the content ...
1
vote
0answers
14 views

Missing content in Pages only

I have an odd one. One site is missing all content on it's page (but not posts.) If I add a filter on 'the_content', $content is empty. I've tried giving the filter priority of 1, 0 and even ...
0
votes
0answers
25 views

One Content Filter To Rule Them All

I have a plugin that fetches post content, then runs it through a series of custom and native the_content filters and updates the post using ajax. Problem is that I have many other filters also ...
0
votes
0answers
26 views

Specifying image size used in template the_content

I have a template that is used to display all posts. It uses query_posts with a set of $args that I specify. The template uses the_content to output the content of each post (text and images) I want ...
0
votes
0answers
62 views

How to add the_content function?

I bought the Magazine Newspaper Pro theme about a month ago and tried to customize the homepage with Elementor. But, an error message showed up which says that I need to call the_content function. I ...
0
votes
2answers
229 views

get the_content by ID and save the result to one array

I try this: <?php function get_ct($id){ $ct = apply_filters('the_content', get_post_field('post_content', $id)); return $ct; } $arr = array('post_content' => get_ct(...
1
vote
1answer
29 views

Differentiate Nested WP_Query from Parent

I'm filtering the_content in order to append a grid of related posts onto a single post with a nested WP_Query and would like to use the same content.php file as I do for my main query. The problem is ...
1
vote
1answer
139 views

How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?

Is there any way to change the order of filters for e.g. the_content before they are applied? What I currently have is the following ideas: /** * Print all filters for some hook. */ function ...
-1
votes
3answers
38 views

Does WP have a hook for the use of wp_trim_words?

I am using bootstrap to layout a simple webpage. I have also add some css (@media (min-width: 1920px) {..}) media queries which I use for different resolutions Now I hope WP has a hook which checks ...
1
vote
0answers
241 views

Show the content that is after the excerpt using child theme

How do I set a value for $stripteaser using the functions.php file in a child theme so that when the_content() is called on post pages only the post exerpt is shown? I have a theme that I am using. ...
0
votes
0answers
141 views

Post using the_content() and the_excerpt()

I can't wrap my head around this one. I've tried so many different ways. I'm new to wordpress, so please excuse my noobie question! I'm trying to get the following loop below to display all my post ...
0
votes
2answers
20 views

Getting content from a referenced post

I have the following, which is successfully pulling the title, thumbnail, and custom field data (YouTube link) from a referenced post, but the content displayed is that of the parent: function ...
1
vote
1answer
31 views

Removing the_content() from the page

There is the_content() in one of the template files which, well, prints the content. I get the content with get_the_content() manipulate it and print it. However, I couldn't figure out which action ...
1
vote
0answers
24 views

get post id by $content (so by post content)

So weird, huh? But, not joke --> I try to be very clean of being: I have a subdomain based multisite network. If the users posts to their sites, I get a clone from the current post to my network home. ...
0
votes
2answers
40 views

Is it possible to change the structure of the HTML generated by the_content()? If yes, how? If not, is there a workaround?

Suppose the editor on my admin dashboard creates the following HTML (when I print to the webpage using the_content(): <blockquote>Hello this is the best quote in the world!</blockquote> &...
0
votes
1answer
18 views

How do I isolate the reason a wordpress filter is not running?

I have a wordpress filter defined in my theme's single.php: header( 'X-Filter-1: here' ); add_filter( 'the_content', function( $content ) use ( $details ) { header( 'X-Filter-2: here' ); /...
0
votes
1answer
44 views

Get the_content surrounded by <h1> instead of <p>

I'm looking to use the_content() on a particular page, but I want it to be surrounded with an <h1> instead of a <p>. I've tried doing this: $thisPagesContent = the_content(); echo '<...
1
vote
1answer
97 views

Changing the HTML Of the content

<?php the_content(); ?> When we use the above the content is published like this → <p>Content is published</p> If I want to later this HTML and instead of <p></p> I ...
0
votes
0answers
34 views

Using the_content() causes the white screen of death

I have a custom post type for creating popups. I have a loop where I display all the popups and it all works fine, until I try get the content using the_content(); the_title(), the_ID() etc., all ...
1
vote
2answers
72 views

Save the_content into custom field

Is it possible to save the content (inside the WP WYSIWYG (the_content)) into a custom field? This is what I have so far: add_action('edit_post', 'save_content_to_field'); function ...
0
votes
1answer
580 views

$content = $post->post_content; with formating

I'm trying to get formating but with no luck. My code looks like this global $post; $content = $post->post_content; And to output here <div class="tribe-events-single-event-description tribe-...
0
votes
1answer
225 views

Post content being duplicated by the_content();

I have a query that runs through a set of posts with the post type location. It returns them broken down by a custom field value (in this case, the state in which the location is located). For some ...
0
votes
1answer
36 views

Insert template-part inside the content

I want to display an image/banner with link, inside the content of the posts of my blog. Neither at the beginning, nor at the end. It should appear somewhere inside the content of the post. I don't ...
0
votes
1answer
43 views

How to split a post and intercalate elements from a loop

What I'm trying to achieve is spreading related posts throughout the content - such as one reccomendation after every 3 paragraphs. As I see it, three things need be done: 1 - Do the loop. What I'm ...
-1
votes
1answer
16 views

Exactly where I have to insert get_next_post_link() in a post?

Currently I'm working on a website, where there are posts and I intend to give the possibility the user to jump to the adjacent posts with a simple link pointing to them. It will be with ...
0
votes
2answers
67 views

Use content from one page in another template

I'm quite new to WordPress and wonder if there is a way to take the content in a normal page created in WP and show this content in a div tag through a page template? The setup is two divs next to ...
2
votes
1answer
649 views

How I can split text in the_content() into 2 columns?

I need to split one paragraph of text into two columns in wordpress the_content(); I tried different tutorials, but they not work for me. Also I can't use shortcodes. Here how I need to make it done: ...
1
vote
1answer
67 views

Searching for content post

I need the "wordpress search" engine to be only for the content of the posts. I looking for some solution but always "wordpress search" engine only shows results by titles of the post. What can I ...
0
votes
2answers
2k views

Difference between the_content() and get_post()?

I'm working on tweaking a theme and I need to explode the post content to remove some text. The following code is what I am using: $custom_Get_Post_Title = explode('|',get_post()->post_content); ...
0
votes
0answers
21 views

Regex help, remove links around images and others

Trying to clean up an old blog, Id like to delete all Links in posts, even the ones surrounding images but id like to keep the images in place. I suspect I need two pattens, one to remove all links ...
0
votes
1answer
476 views

Remove External Links from WordPress posts Using add_filter() in Theme functions.php

We have been searching high an low for a plugin, code sample or example of how to remove all external links at the theme filter level but can't seem to find anything online. We want to keep the ...
0
votes
3answers
682 views

Getting first 20 words without excerpt

I'm working on my own custom theme (first custom WP work so I'm a real beginner) and need help in listing the first 20 words of a list of recent posts. I managed to solve this with manual? excerpt ...
0
votes
3answers
114 views

Why do images inserted in the post content via the_content() go off the max-width?

I have many containers over the said image itself such as col-md-10 which defines a max-width of 80% or so, this is how I generate my post: <article id="single-post-<?php the_ID(); ?>" <?...
0
votes
0answers
96 views

the_content filter not working when Jetpack activated. Any idea?

I use this function to filter some posts content: function frontend_wizard_content($content){ if ( !is_page(213) ) return $content; ob_start(); locate_template('mycontent.php', true); ...
0
votes
1answer
262 views

How do you get specific tags from the_content?

How would I grab specific tags from the_content? For example, I'd like to pull a list of all h1 tags.
0
votes
1answer
21 views

use a Thumbnail size in post

When inserting a image to WordPress post, I have used size as "Full Size" for all images. My images width are between 800px to 1500px. Is there way to change it for whole site when displaying on the ...