Skip to main content
11 votes
Accepted

Where to hook into post content?

You can use the_content with an high prioriety (lower number). add_filter( 'the_content', function( $content ) { return 'Hello World '.$content; }, 0); You can even use negative priority: ...
gmazzap's user avatar
  • 46.2k
9 votes

Best way to eliminate xmlrpc.php?

When you have the ability to block it via your web server's configuration, @Charles' suggestions are good. If you can only disable it using php, the xmlrpc_enabled filter is not the right way. Like ...
tweber's user avatar
  • 191
9 votes

Get the content of a specific page (by ID)

$post = get_post( 42 ); $output = apply_filters( 'the_content', $post->post_content ); echo $output; from https://developer.wordpress.org/reference/functions/get_post/
João Marcos Santos Teixeira's user avatar
9 votes
Accepted

Get Post ID by Content

WordPress has a handy function called post_exists() which allows you to find an existing post by its title, content, and/or date. It returns the post ID on success or 0 otherwise. In your case, you ...
swissspidy's user avatar
  • 3,874
8 votes

if the post has content

What about if ( !empty( get_the_content() ) ){ //code }
Juan Solano's user avatar
7 votes
Accepted

How to show page content in feed?

First set the post type to display on main feed page i.e. /feed using pre_get_posts hook $q->set('post_type', array('post', 'page')); On individual page WordPress shows comment feed then set it ...
Sumit's user avatar
  • 4,804
7 votes
Accepted

How do I create new content pages for my Custom Post Type?

In your dashboard go to settings/permalinks. Hit save. You should be able to see your cpts now.
rudtek's user avatar
  • 6,143
6 votes

use query string in URL to display content on the page

Per the OP's answer within their question: With your help and some Googling, I put together a shortcode that returns the value of any url parameter. Here it is: //THIS IS A CUSTOM SHORTCODE TO ...
Ethan O'Sullivan's user avatar
6 votes
Accepted

How to remove Nextpage tag inside posts text depending of utm_campaign

You can use the_post hook to remove <!--nextpage-->. In this case: add_action( 'the_post', 'campaign_remove_nextpage', 99); function campaign_remove_nextpage ( $post ) { if ( ($_GET['...
cjbj's user avatar
  • 14.8k
5 votes

if the post has content

i have implemented some "has_content()" methods for several times over years now and there is always enough time in between so i need to search again a bit to answer this question. anyways - this is ...
Thomas Fellinger's user avatar
5 votes

Allowing SVG uploads in media uploader without plug-in

function cc_mime_types($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mimes; } add_filter('upload_mimes', 'cc_mime_types'); add in functions.php in your active theme define('...
Dharmishtha Patel's user avatar
4 votes
Accepted

remove <p> tags from the_content

By default, WordPress adds paragraph tags to category descriptions. Stop this by adding the following to your functions.php file // Remove p tags from category description remove_filter('...
Jodyshop's user avatar
  • 196
4 votes

How to show page content in feed?

This may not be ideal, but it is a beginning. First make sure that the full content is in the feed: function fullcontentfeed($content) { global $post; $content = $post->post_content; ...
cjbj's user avatar
  • 14.8k
4 votes

How to remove Nextpage tag inside posts text depending of utm_campaign

We can use the content_paginationcodex filter to modify the paginated content without modifying the globals directly: add_filter( 'content_pagination', function( $pages ) { // Target only the ...
birgire's user avatar
  • 67.5k
4 votes
Accepted

What is the best / efficient way to get WordPress content by post id and why?

The methods you offer for comparison are pretty much the same, with minor API differences and whether the_content filters are applied. Within the loop get_the_content() should typically be used, ...
Rarst's user avatar
  • 99.7k
4 votes
Accepted

WordPress REST API - JSON "Rendered" Content Incorrect

The content that you are referring to is coming from the Elegant Themes Page Builder plugin on that site. The page builder uses WordPress Shortcodes to render the content on the WordPress site. ...
Mat's user avatar
  • 1,637
4 votes

Gutenberg First Block on Page Conditional?

Here's a solution I've come up with, that works with Wordpress 5.4 and ACF Pro 5.8.9. First you need this function somewhere in functions.php: /** * Get ID of the first ACF block on the page */ ...
Skovsgaard's user avatar
3 votes
Accepted

Change Content for Specific Page

Your function is signup but you're hooking check_for_signup. You're also trying to apply the_content filters from within a function that's hooked to the_content: function ...
TheDeadMedic's user avatar
  • 36.5k
3 votes

Best way to eliminate xmlrpc.php?

For the extreme minority that are hosting WordPress in IIS, you could use the IIS URL Rewrite module to do similar htaccess-like restrictions. The example below assumes the true client IP is coming ...
BRass's user avatar
  • 131
3 votes

Stop WordPress automatically adding <br> tags to post content

Install the plugin "Don't Muck My Markup". It adds a checkbox option to each page disabling auto insertion of <p> and <br> tags. There is also an option to do this site-wide.
Brent Baccala's user avatar
3 votes

Get Content From Blog Page

With the new WP editor that uses blocks the second code block in the accepted answer won't render the blocks. To get them to render use the following. $page_for_posts_id = get_option( 'page_for_posts'...
William Wilkerson's user avatar
3 votes

Strategy for handling hierarchical pages with empty parent content

Create a new file called page-parent.php and enter the following code in your new file: <?php /* * Template Name: Parent Menu * Description: Redirects empty parent page to first child page */ #...
Ethan O'Sullivan's user avatar
3 votes

How to show page content in feed?

As mentioned by @Sumit, you need to turn off the comments feed for a page (which I find really strange since by default comments are off on pages?) ... this is what I ended up with (allowing for ...
majick's user avatar
  • 5,091
3 votes
Accepted

How to get a post's content?

"best" greatly depends on context. guid is probably (with some debate about it) the best way to uniquely identify a post, but not all import/export plugins leave it alone without changes. ID is a ...
Mark Kaplun's user avatar
  • 23.4k
3 votes
Accepted

Customize <header> in category page

Review the template hierarchy from the Codex to gain a better understanding of what files are read when. This will help you to understand what's called in what situation (tag/category/front-page/etc). ...
Greg McMullen's user avatar
3 votes

Multiple content areas per page

This sounds to me like a perfect use of Advanced Custom Fields "flexible content" feature to me. Flexible content fields allow you to define multiple layouts, and then add them to a page or post one ...
Dalton Rooney's user avatar
3 votes
Accepted

Applying custom filter instead of the_content doesn't render embeds

the_content filter is as good as other filters are. The issue is that it is supposed to be run inside a loop with the glogal $post correctly set to current post in the loop. So, you could do something ...
cybmeta's user avatar
  • 20.5k
3 votes

wp_ajax unauthenticated and authenticated

add_action('wp_ajax_get_post_info', 'get_post_info'); add_action('wp_ajax_nopriv_get_post_info', 'get_post_info'); wp_ajax_nopriv_(action) only on front-end and only for non logged users. Use ...
Maxim Sarandi's user avatar
3 votes
Accepted

Filter post_content before loading in Gutenberg editor

I found that there is no way to change the data which is coming to editor when it is loaded. But it's possible to replace the data after that. JS: script.js wp.domReady(function () { const newData ...
Andrei Surdu's user avatar
3 votes

How To Watermark Audio

I don't think this is possible. Watermarking the audio with an audio editing software takes a process that 'WordPress' cannot simulate. It's advisable you do the watermarking before the audio file is ...
Michael Adegoke's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible