Questions tagged [post-content]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
32
votes
1answer
10k views

When is the 'post_content_filtered' column in database cleared by WordPress?

Some WordPress plugins (although very few) use the post_content_filtered column in database to save some data related to a post. For example, Markdown on Save stores the markdown version of a post ...
25
votes
3answers
17k views

Check what Gutenberg blocks are in post_content

I'm working on a design that has different styling if a certain Gutenberg block is present on a page. In other words, if the first block is a custom built Gutenberg block, the post_title is rendered ...
24
votes
10answers
64k views

Get post content from outside the loop

Is there a way to get the content from another outside the loop? The ID is 302 and I need to display the content of that on another page.
22
votes
3answers
49k views

How to get 'post_content' without stripping <p> tags?

I'm trying to retrieve the post content of a specific post: $post = get_post(/* id */); $content = $post->post_content; However, this retrieves the content with no line-breaks and omits all <p&...
9
votes
1answer
16k views

post_content with line breaks

I want to be able to get post_content with line breaks. What is the best way to do it? I previously use the_content() which was working fine until I needed to install a plugin that adds share buttons ...
9
votes
1answer
426 views

Why is javascript allowed in my post content?

The codex says you can't add javascript in the post content https://codex.wordpress.org/Using_Javascript But I can. I've turned off all plugins and changed to twentysixteen theme, but to no avail - ...
8
votes
4answers
42k views

Proper way to get page content

I have to get specific page content (like page(12)) I used that : <?php $id=47; $post = get_page($id); echo $post->post_content; ?> Work nice execpt for compatibility with qtranslate ...
6
votes
1answer
2k views

Is there a quick way to remove inline css from all posts?

I have 40 WordPress sites with 20-30 pages on each. Most of them have some inline css, like <p style="text-align: justify;"> in every single paragraph. Is there a quick, mostly automated way to ...
6
votes
2answers
799 views

Insert Custom HTML After Shortcode

The scenario is that I need to add an HTML banner under a slideshow which is a shortcode in the homepage content. I personally hate adding a bunch of div tags to the TinyMCE editor so I'm trying to ...
4
votes
3answers
2k views

How to embed page content in a blog post

I've built an HTML table that is posted on a page in my site, and I'd like to use that same content inside a blog post (something of an announcement of the table's publication). The table is likely to ...
3
votes
2answers
3k views

WordPress REST API - JSON “Rendered” Content Incorrect

i'm working in android application that use wordpress rest api to get blog from website to , i don't have any knowledge about php or wordpress , but i take some time to learn about it , any way my ...
3
votes
2answers
164 views

Is it possible to handle a specific section of a post separately?

I've tinkered with WordPress a little, but I'm far from an expert, so apologies in advance if this is a duplicate question. I've built a simple WordPress theme based around Bootstrap, and I can ...
3
votes
2answers
2k views

How do I insert a short tag after 350 words in post_content?

I have 700 posts mostly in excess of 1000 words each. I'm setting this up as a membership site. I'm using wishlist member and would like to protect all the content after the first 350 words. This ...
3
votes
1answer
660 views

Removing the title attribute from links in the post content

When using the WYSIWYG editor to create links, and selecting an existing page or post from the selection list, those links will have a title attribute by default. Is there a simple way of turning off ...
2
votes
3answers
6k views

How to create WP Editor using javascript

I am trying to create some kind of repeated fields and for that, I want to create a new wp editor with some unique ID. So my question is there any way to create wp_editor using any js? same as we ...
2
votes
1answer
1k views

Search and replace in post content

I am about to change themes on my site and also a plugin that creates tabs with a post. I need to replace multi-line text with other multi-line text and can't work out how to do it. I have tried "/r/...
2
votes
1answer
636 views

Get IDs of posts currently visible on archive

This probably is a easy one for many. And also probably is already answered here, but I don't know how to search for it - so sorry I did search but not found anything. I like to get the contents of ...
2
votes
3answers
915 views

How to *disable* the post content editor

Any good ideas on how to disable the post content editor? I don't want to hide it, remove it, or remove the page. The goal is to allow users with few permissions to view the edit screen so they can ...
2
votes
1answer
446 views

Check if page/post has any anchors that link to an image jpg/gif/png

What I'm aiming to do is add fancybox to a site I'm developing, but I only want to enqueue the JS/CSS etc if the page/post needs it. My thoughts are that I would need to check all the anchor tags on ...
2
votes
0answers
59 views

Is there a better way to programmatically insert content into a page?

During activation of the plugin I'm writing, I insert a custom page. I can add post_content using the wp_insert_post command, which seems like a reasonable way to add a limited amount of content. For ...
1
vote
1answer
3k 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-...
1
vote
1answer
391 views

Double or Single Quotes in WordPress Content Conflicting With HTML

so I know about addslashes() and related native PHP functions, but I was surprised that I wasn't able to quickly find a WordPress "catch-all" for this kind of situation, given WordPress' focus on CMS. ...
1
vote
1answer
2k views

Exclude posts with empty post_content in wp_query

is it possible to exclude posts with empty post content from a wp_query? $args = array( 'post_type' => array('post'), 'posts_per_page' => 5, 'post_status' => 'publish', ); $...
1
vote
1answer
2k views

wp_insert_post -> post_content not showing

I have a problem with wp_insert_post. When I'm attempting to insert my post, the post_content essentially shows up as just blanks spaces. I even went into MySQL to confirm. Everything else, ...
1
vote
1answer
941 views

Float images in content

This is not a programming question. I have the problem to update the content in my WordPress blog. I'm very aware this problem can be solved by html modification. But my client doesn't know about html....
1
vote
1answer
98 views

How to make search and replace in content through php

I actually can show content and change content while displaying post. Problem is that I am using RSS importer and after importing I want to make search and replace and correct data imported because I ...
1
vote
1answer
60 views

Adding current user's ID to the end of PDF hyperlinks in post content

How can I add extra parameters after a hyperlink, for tracking purposes? For example, let's say I inserted media into a post - http://mysite/wp-content/uploads/2018/12/My_PDF_File.pdf. How can I make ...
1
vote
1answer
48 views

Redirect All Search Links Containing - to + on Wordpress

I deleted all my wordpress tags via phpmyadmin, and most of my post content contains tag links, now I redirected all the tag links to search using .htaccess, I.E example.com/tag/stack-exchange/ ...
1
vote
1answer
617 views

Is there a way to show only the text editor

I'm working on a desktop app and I'd like to show only the editor and it's toolbar. I'm able to load and save the past content easily enough through the app but I'd like to be able to reuse the ...
1
vote
2answers
418 views

Password protection for page template

I`m using my own page template, for display post from some category: $wp_query = new WP_Query(); $wp_query->query('&cat=9' . '&paged=' . $paged); while ($wp_query->have_posts()) : ...
1
vote
1answer
137 views

Add predefined/default values to custom post plugin

I have created a custom post plugin. I need to add predefined text/values within this plugin, when adding new custom post. Is it possible to handle these predefined text/values in my plugin PHP file,...
1
vote
1answer
4k views

How to display widgets inside a page content without a plugin?

I want to build a homepage where I can show posts gathered from different categories and having the ability to choose such categories from the admin. I was thinking to use widgets for this. Is the ...
1
vote
1answer
91 views

Getting post content without the navigation

I'm having a issue I don't seem to be able to figure out how to get around. I'm using the_content(); to get post content for a single post, but it returns a navigation item with it. I would like to ...
1
vote
1answer
2k views

Updating post content on the front end

I have used the code below to add frontend editing to my posts/pages. How would I go about saving the post content when an update/save button is pressed? $post_id = get_the_ID(); $settings = array( '...
1
vote
1answer
567 views

Where is the content cache when using apply_filters('the_content…?

The following code block is giving me an accumulated result: foreach($sections as $section) { $content_post = get_post($section->ID); $content = $content_post->post_content; $...
1
vote
1answer
24 views

Copy content stored in meta to post content

I'm working on a site that had an existing theme that used meta fields to store blocks (bad practice IMO but pre-block editor). The problem is there are over 300 posts and all the different "...
1
vote
0answers
12 views

How to filter post content and force every link (<a>) made in blocks to return urldecode(<a>) with readable value?

Will really appreciate your help with something. I'm using non English letters in my URL slugs. So every time I add an internal or external link with non English letters to my post (via blocks editor ...
1
vote
0answers
49 views

Bulk append custom field to post content

I want to bulk append my custom field named 'LINK' (with data like 'http://domain.com') to the end of the post content, so I can go back to using a standard theme with no support for custom fields. ...
1
vote
2answers
1k views

Get and Trim Full Post Content in WP Query

Simple task, but it isn't working: <?php $content = apply_filters( 'the_content', get_the_content() ); $contentWithoutHTML = wp_strip_all_tags($content); $pos = strpos($contentWithoutHTML, " ", ...
1
vote
0answers
153 views

current post index within content.php

I have a custom post type 'projects', I would like to add a post counter ('current project index' / 'total number projects') I would like this to show within the post content, but not sure how to ...
1
vote
1answer
536 views

WP_Query() order by post content lenght?

How do I order a post query by the length of the post content? $orderby = ?; $query = array( 'posts_per_page' => 10, 'post_status' => 'publish', 'orderby' => $orderby, 'order' => ...
1
vote
0answers
38 views

Auto-create a post with last 10 images in WordPress directory

I want to create something to help me auto-create a post with 10 last images hosted in some directory (in my server or WordPress), this code I found helps to post an image but not many images if ...
1
vote
1answer
290 views

Bulk updates to post_content

Ok, so I have a custom post type (let's call it 'custompost') with about 3,000 posts and each has about 150 advanced custom field data items. I am trying to update the post_content for all of these by ...
1
vote
0answers
357 views

Add Attribute to p Tag of Post Content

I would like the default <p> elements that are added to the (TinyMCE) editor when users post content, to have a dir attribute as well. Reasoning: When the editor is displayed to users, it is ...
1
vote
2answers
2k views

How to parse shortcodes within returned content

I'm using Visual Composer, but I think it has more to do with WordPress than VC ;-) I did a shortcode (with the VC API) to get the content of a post. Here it is (in functions.php): add_filter( '...
1
vote
1answer
2k views

Creating a post from data returned from HTML form

I am trying to write a WordPress plugin and I have hit a bump. The Background: I have some data in a mySQL DB that I am using (each row has a unique ID and some other information I have added). I am ...
1
vote
2answers
70 views

Show image exactly defined to a width

I have a photoblog displaying posts as image galleries having width 500px and some posts as single image of width 900px. For posts with 900px width images, I made category HQ. Posts with 500px width ...
0
votes
2answers
71 views

Wordpress: Loop Help

I was working on this site this morning and I ran into a bit of an issue with my static page. I have a "featured" post section and I use: <div id="featured"> <img src="<?php echo ...
0
votes
1answer
407 views

wp_mail sending old content from post

I have a function that sends out emails using wp_mail() every time a post is published or updated. However, the content that is being sent is always one post behind. If I update the content the email ...
0
votes
3answers
1k views

Conditionally set post_content in wp_insert_post

Is it possible to conditionally set the post_content in wp_insert_post? Im using a foreach to add multiple pages at once: foreach ($create_pages as $new_page) { $add_pages = array( '...