How to take shortcode and content separately from a page?

I found the solution. I used the following codes and it worked for me . To remove the shortcode from the content, I Used this <?php $content = get_the_content(); $content = preg_replace(“/\[.*]/m”, ” “, $content); $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, ‘]]>’, $content); echo $content; ?> and the following code to get the shortcode … Read more

Print only parent categories of post in custom RSS feed

I’m still interested in hearing how this can be accomplished using the WordPress function the_category_rss(), but I did find another way to do this: <?php $parentsonly = “”; // loop through categories foreach((get_the_category()) as $category) { // exclude child categories if ($category->category_parent == 0) { $parentsonly = ‘<category domain=”‘ . get_category_link($category->cat_ID) . ‘”>’ . $category->name … Read more

how to develop a filter in wordpress to let the user filter the page content depends on the date (newest to oldest etc…)?

I would recommend looking at FacetWP plugin, which is a paid plugin, but it does all of this and more: https://facetwp.com/ If you want to manually do this, there’s numerous ways based on what specifically you’re referring to (blog posts? custom post types?): Sort posts by Date (DESC) and by Title (ASC) WordPress also has … Read more

Remove image of srcset

If you look in core, that filter is applied like so: $image_meta = apply_filters( ‘wp_calculate_image_srcset_meta’, $image_meta, $size_array, $image_src, $attachment_id ); Instead of using __return_empty_array you need to add a custom function to that filter to remove the srcset size you are trying to get rid of. Something like this. function my_srcset_function($image_meta) { if (!is_array($image_meta)) { … Read more

filter out

Removing the action is really what I intended as I’m not replacing the title. changing my last line to this works for what I was intending. remove_action( ‘wp_head’, ‘_wp_render_title_tag’, 1 );

create a shortcode with acf including a filter

This is not the full working code, just to illustrate how to add the shortcode and trigger the function. <?php // Check if ACF is available if(function_exists(‘get_field’)) { function modell_nach_personenzahl_variabel() { $args = array( ‘post_type’ => ‘womos’, ‘order’ => ‘ASC’, ‘orderby’ => ‘personen’, ‘field’ => $atts[‘personen’], ‘numberposts’ => -1, ‘meta_query’ => array ( array ( … Read more

How to add_filter only when content is not empty?

Based on your edits, you want one function to apply to two different filters. All you need to do is use the same function on both filters. I haven’t tested this, but it should work: function content_image_markup($content) { if( !empty($content) ) { // example of changing the content $content=$content . ‘ append this to content’; … Read more