How to apply content filter permanently?

//run once $allposts = get_posts(‘post_status=publish&numberposts=-1’); foreach ($allposts as $thispost) { wp_update_post( array( ‘ID’ => $thispost->ID, ‘post_content’ => fix_zip_code($thispost->post_content) ) ); } But as Rarst mentioned, backup your database before doing anything…

WordPress URL rewrite regex

From the wordpress documentations – https://codex.wordpress.org/Using_Permalinks Using %category% with multiple categories on a post When you assign multiple categories to a post, only one can show up in the permalink. The categories are ordered alphabetically. In each group of sub-categories the order will also be alphabetical. (see Manage Categories). The post will still be accessible … Read more

Custom post type permalink changing itself every other change

BETTER SOLUTION Actually, there is a note on the WP_Query reference: Note: Ticket #18408 For querying posts in the admin, consider using get_posts() as wp_reset_postdata() might not behave as expected. So instead of attempting to reset the global post data, the more proper solution is either: Use get_posts(): $seriesPosts = get_posts($args); foreach($seriesPosts as $p){ $select … Read more

Extract attribute values from every shortcode in post

Method #1 If available, I would use the: shortcode_atts_{$shortcode} filter to collect the attributes of a given shortcode. Example: $text=” “; $out = wpse172275_get_all_attributes( ‘gallery’, $text ); print_r( $out ); with the output: Array ( [0] => [1] => Array ( [ids] => 1,2 https://wordpress.stackexchange.com/questions/172275/extract-attribute-values-from-every-shortcode-in-post => file ) [2] => Array ( [ids] => 3 … Read more

Adding WordPress API Endpoint With Multiple Parameters

I have the same problem, i search on google finally with the help of the above answer i found out the solution. this may help others. $this->base = home register_rest_route( $namespace, “https://wordpress.stackexchange.com/” . $this->base . “https://wordpress.stackexchange.com/” . ‘products’ . “https://wordpress.stackexchange.com/”, array( array( ‘methods’ => WP_REST_Server::READABLE, ‘callback’ => array( $this, ‘rest_api_popular_products’), ), ) ); register_rest_route( $namespace, … Read more

Wrap element with in any number of elements with PHP

Can I use a similar technique to ‘wrap’ my everything in the body with another div? Absolutely. Almost everything is possible. But you’re going to have to do something a little hackish. The the_content filter doesn’t actually filter the content of the entire page. That particular filter is used throughout WordPress to filter a variety … Read more