WordPress hide post from custom post-type on a single page

Instead of using the pre_get_posts hook simply modify your WP_Query to fetch posts with certain conditions. $loop = new WP_Query( array( ‘post_type’ => ‘projects’, ‘orderby’ => ‘rand’, ‘posts_per_page’ => 1, ‘meta_query’ => array( array( ‘key’ => ‘your_field_name’, ‘value’ => ‘the_value’ ), ), ) ); This, right from the beginning only fetches the posts that matches … Read more

Replace only the first CSS class

Not sure if a typo but in your question you say “replace the “thumb-w” CSS class with “thumb-w1” but in your code you have: $html = str_replace( ‘thumb-w’, ‘thumb-w 1’, $html); Should your code instead remove the space and be: str_replace( ‘thumb-w’, ‘thumb-w1’, $html);

Overriding a function in a WordPress plugin

If you must use the 3rd party function – why not just reformat the returned value? Date ($id) { $userActivityDate = Br::show_activity_date($id); date_timezone_set($userActivityDate, timezone_open(‘timezone You want it to be in’)); date_format($userActivityDate, ‘Y-m-d H:i:sP’); $return = apply_filters(‘user_activity’, $userActivityDate); } If the return value of the Br::show_activity_date is not directly useful in this manner, then I suggest … Read more