• I need to increase the number of Most Used Tags in post editor and I tried to add this code but didn’t work.

    function increase_most_used_tags($args) {
    $args['number'] = 20; // Change the number to the desired amount of tags
    return $args;
    }
    add_filter('tag_cloud_widget_args', 'increase_most_used_tags');

    Anyway to increase it from 10 to any larger number?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    The most used tags editor field is not generated from a tag cloud even though it kind of looks like it. It’s populated from a REST API request. The query string &per_page=10 is passed. I’m unsure how we’d modify an API request so it’d be more to our liking.

    If you cannot find a way to do that, you could use the ‘pre_get_terms’ action hook to modify the actual tag query. The trouble will be in identifying the query resulting from the editor’s API request from all other term queries. Possibly checking that certain query vars are a particular value could identify the right query. Verifying REST_REQUEST is defined and true will help narrow down the number of different queries you’d need to differentiate from.

    Thread Starter simsim1986

    (@simsim1986)

    @bcworkz

    Thanks for your reply I tried using js to modify the REST API with this code

    function custom_admin_inline_js() {
    ?>
    <script type="text/javascript">
    (function($) {
    $(document).ajaxSend(function(event, jqxhr, settings) {
    if (settings.url.indexOf('/wp/v2/tags') !== -1 && settings.url.indexOf('per_page=10') !== -1) {
    settings.url = settings.url.replace('per_page=10', 'per_page=20');
    }
    });
    })(jQuery);
    </script>
    <?php
    }
    add_action('admin_footer', 'custom_admin_inline_js');

    but still no luck, is there any direct way to do it?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.