Hot answers tagged

6

Here's a script that you can enqueue into your admin panel. It will add a new tab to the category tabs called "Active". Whenever a checkbox is checked, it gets added to the "Active" tab list, you can also click links in the "Active" tab list to remove them ( uncheck them ). Add this as an external script, custom-tabs.js maybe: jQuery( document ).ready( ...


5

You need to specify a post type in your WP_Query arguments when you need to query any other post type accept the build in post type post. By default, post_type is set to post, so when no specific post type is set manually by the user, WP_Query will query posts from the post type post Additionally, caller_get_posts have been deprecated for a very very long ...


4

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['utm_campaign']== 'nonextpagecampaign') && (false !== strpos( $post->post_content, '<!--nextpage-->' )) ) { // Reset the global $pages: ...


3

If we look at the WP_REST_Controller::get_collection_params() method, we can see the minimum is 1 and the maximum is 100: 'per_page' => array( 'description' => __( 'Maximum number of items to be returned in result set.' ), 'type' => 'integer', 'default' => 10, 'minimum' => 1, '...


3

There really is no sane way to accomplish this, specially if you have posts that are assigned to more than one tag (which is almost always the case). What is very sure, you have you work cut out for you. Here are some thought and ideas you can persue: POSTS WITH MULTIPLE TERMS If posts have more than one tag (or any term for that matter) assigned to them, ...


3

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 correct utm_campaign GET parameter if( 'nonextpagecampaign' !== filter_input( INPUT_GET, 'utm_campaign', FILTER_SANITIZE_STRING ) ) return $pages; ...


1

Here's an approach similar to what @Milo suggests. Let's say we have: $tags = wp_get_post_tags( 123 ); If we need to filter out the term with term_id 15, we can use wp_list_filter: $_tags = wp_list_filter( $tags, [ 'term_id' => 15 ], 'NOT' ); where the NOT is the operator for excluding it. If we also need to pluck out a single attribute we can ...


1

METHOD 1 - wp_get_post_terms() We can make use of the wpse_exclude parameter to exclude and array of terms from the list of post terms. wp_get_post_tags() internally uses wp_get_post_terms() which uses wp_get_object_terms(). When looking at the source of the latter, we see that we can make use of the wp_get_object_terms filter to filter the output from the ...


1

What am i missing? 'tag' may be a valid argument for get_posts() via WP_Query, but requires the tag slug in that case. Try using 'tag_id' instead. get_posts() apparently enables 'category', but expects the the ID, even though in WP_Query the same argument is 'cat' (vs. 'category_name', et al). A little confusing, perhaps, altogether. I know it still ...


1

Pieter's answer does work, but it displays all sticky posts even on pages when we want to display filtered posts (to a given category for instance). The following works for me. Adding this to functions.php only displays stickies within the subset of filtered posts : add_filter('the_posts', 'bump_sticky_posts_to_top'); function bump_sticky_posts_to_top($...



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