How to appending to the_content using add_filter with custom post type?
You’re completely overwriting the content instead of appending it. You need to do something like $content .= ‘Test text here’; instead.
You’re completely overwriting the content instead of appending it. You need to do something like $content .= ‘Test text here’; instead.
wp_title filter is deprecated since WordPress 4.4 (see here). You can use document_title_parts instead function custom_title($title_parts) { $title_parts[‘title’] = “Page Title”; return $title_parts; } add_filter( ‘document_title_parts’, ‘custom_title’ ); In custom_title filter, $title_parts contains keys ‘title’, ‘page’ (the pagination, if any), ‘tagline’ (the slogan you specified, only on homepage) and ‘site’. Set “title” the way you … Read more
You could use the query to filter the content as you intended by using the ‘meta_query’ with filtering options, and for the order part, just add/modify the following parameters: ‘orderby’ => ‘meta_value’ ‘meta_key’ => ‘location_level1_value’ ‘order’ => ‘ASC’ $wp_query = new WP_Query( array ( ‘post_type’ => ‘listing’, ‘posts_per_page’ => ‘9’, ‘post_status’ => ‘publish’, ‘meta_query’ => … Read more
UPDATE 2018-06-28 While the code below mostly works fine, here is a rewrite of the code for WP >=4.6.0 (using PHP 7): function add_course_section_filter( $which ) { // create sprintf templates for <select> and <option>s $st=”<select name=”course_section_%s” style=”float:none;”><option value=””>%s</option>%s</select>”; $ot=”<option value=”%s” %s>Section %s</option>”; // determine which filter button was clicked, if any and set section … Read more
You have at least two options: Globalize the desired variable, and then reference it inside the callback Wrap the score calculation logic with a function, then reference it inside the callback Globalize the Variable <?php global $score; $score = 42; //Some crazy calculation I don’t want to repeat. function add_score_to_title($title) { global $score; return ‘Quiz … Read more
Less than an answer, but just a list of things straight from my experience with it – maybe you’ve overlooked something. Debugging the request & its results Without diggin’ too deep into the update process, but the WP HTTP API uses the WP_HTTP class. It also offers a nice thing: A debug hook. do_action( ‘http_api_debug’, … Read more
Ok so I think I figured it out… Both of these work for the most part as you’d expect by sending http / php headers to the browser. wp_headers is actually a filter inside the send_headers() functions.You can use this to modify the headers before they’re sent to the browser with some exception. wp_headers won’t … Read more
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 to false and display page content in feed. $q->is_comment_feed = false; In feed template WordPress calls the_excerpt_rss() which calls get_the_excerpt() so using excerpt_length filter change the … Read more
There are issues in the answer marked as correct. It will break the alignment class functionality, and is not actually adding to the classList, instead it is overriding it. And you will only be able to use that one solution for your whole theme. Instead you can use “registerBlockStyle()” to add a style variation to … Read more
Yes there is, you can use the woocommerce_get_price filter hook to filter the value based on user role and return a price accordingly e.g: add_filter(‘woocommerce_get_price’, ‘custom_price_WPA111772’, 10, 2); /** * custom_price_WPA111772 * * filter the price based on category and user role * @param $price * @param $product * @return */ function custom_price_WPA111772($price, $product) { … Read more