{"id":308,"date":"2020-02-18T08:17:57","date_gmt":"2020-02-18T08:17:57","guid":{"rendered":"https:\/\/stockpack.co\/blog\/?p=308"},"modified":"2022-11-10T08:46:56","modified_gmt":"2022-11-10T08:46:56","slug":"how-to-filter-the-visible-stock-image-providers-select","status":"publish","type":"post","link":"https:\/\/stockpack.co\/blog\/how-to-filter-the-visible-stock-image-providers-select\/","title":{"rendered":"How to filter the visible stock image providers select"},"content":{"rendered":"\n<p>In the StockPack plugin at the time of this post, all the providers are available by default in the provider selector. This is so that you can search stock images from Adobe Stock, Unsplash, Pixabay, and Depositphotos without leaving the WordPress admin. You can now change that from the settings, or with the <strong>stockpack providers filter<\/strong>.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Changing providers from settings<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"519\" src=\"https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-2022-11-10-at-10.42.17-1024x519.png\" alt=\"\" class=\"wp-image-575\" srcset=\"https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-2022-11-10-at-10.42.17-1024x519.png 1024w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-2022-11-10-at-10.42.17-300x152.png 300w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-2022-11-10-at-10.42.17-768x389.png 768w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-2022-11-10-at-10.42.17.png 1160w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Provider selector setting in StockPack<\/figcaption><\/figure>\n\n\n\n<p>From the setting, page uncheck the providers you want to remove from your list. Then click save.<br>The provider filter overwrites the options here, so make sure to remove the filter if you want to use the settings.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Remove a provider from the list<\/h2>\n\n\n\n<p>The filter we introduced is called `stockpack_providers` and it feeds the providers array allowing easy change. <\/p>\n\n\n\n<p>Here&#8217;s an example of removing Pixabay from the list by using the <strong>stockpack providers filter<\/strong>:<\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"php\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">&lt;?php\n\nfunction stockpack_providers( $providers ) {\n\treturn [\n\t\t'Deposit Photos' => __( 'Deposit Photos', 'stockpack' ),\n\t\t'Adobe Stock'    => __( 'Adobe Stock', 'stockpack' ),\n\t\t'Unsplash'       => __( 'Unsplash', 'stockpack' ),\n\t];\n}\n\nadd_filter( 'stockpack_providers', 'stockpack_providers', 20, 1 );<\/pre><\/div>\n\n\n\n<p>You will need to add the code in your theme\u2019s&nbsp;<a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/www.wpbeginner.com\/glossary\/functions-php\/\" target=\"_blank\">functions.php<\/a>&nbsp;file or a&nbsp;<a href=\"https:\/\/www.wpbeginner.com\/beginners-guide\/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin\/\">site-specific plugin<\/a>.<\/p>\n\n\n\n<p><em>The code works by specifying which providers to be shown, so it&#8217;s important to note that this will keep the list based on options you add. <\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Hide the provider selector<\/h2>\n\n\n\n<p>If you want to hide the provider selector you can just return an empty array. In that case, the default will be the only option, and the select will disappear. <\/p>\n\n\n\n<p>To control the default you need to access <a rel=\"nofollow noreferrer noopener\" href=\"https:\/\/stockpack.co\/providers\">https:\/\/stockpack.co\/providers <\/a>and select the one you need.<\/p>\n\n\n\n<p>Here&#8217;s the code to remove the providers select from StockPack:<\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"php\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">&lt;?php\n\nfunction stockpack_providers( $providers ) {\n\treturn [];\n}\n\nadd_filter( 'stockpack_providers', 'stockpack_providers', 20, 1 );<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Keep only free options<\/h2>\n\n\n\n<p>To only keep free options in the providers selector, you can use this code:<\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"php\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">&lt;?php\nfunction stockpack_providers( $providers ) {\n    \nreturn [\n    \u2018Pexels\u2019 => __( \u2018Pexels\u2019, \u2018stockpack\u2019 ),\n    \u2018Pixabay\u2019 => __( \u2018Pixabay\u2019, \u2018stockpack\u2019 ),\n    \u2018Unsplash\u2019 => __( \u2018Unsplash\u2019, \u2018stockpack\u2019 ),\n    ];\n    \n}\n\nadd_filter( \u2018stockpack_providers\u2019, \u2018stockpack_providers\u2019, 20, 1 );<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">When should you use the stockpack providers filter<\/h2>\n\n\n\n<p>As StockPack grows, more and more providers will be added, so this will come in handy, as having too many options might be confusing for some users. <\/p>\n\n\n\n<p>If you are a development agency and you would like to offer this to the clients you build websites for, you might restrict their choices so they can get more focused, but also if you provide some credits as part of your development package.<\/p>\n\n\n\n<p>The stockpack provider filter can also be used with user levels and capabilities in case you want some of the editors to have access to some free providers while others would have access to paid providers.<\/p>\n\n\n\n<p>If you are in doubt you can also reach us via support and we will be happy to help. You might also be interested to learn that StockPack allows you to <a href=\"https:\/\/stockpack.co\/blog\/add-stock-images-in-elementor\/\">add stock images in Elementor<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the StockPack plugin at the time of this post, all the providers are available by default in the provider selector. This is so that you can search stock images from Adobe Stock, Unsplash, Pixabay, and Depositphotos without leaving the WordPress admin. You can now change that from the settings, or with the stockpack providers &#8230; <a title=\"How to filter the visible stock image providers select\" class=\"read-more\" href=\"https:\/\/stockpack.co\/blog\/how-to-filter-the-visible-stock-image-providers-select\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":309,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11],"tags":[],"class_list":["post-308","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-documentation","category-help"],"_links":{"self":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":8,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":578,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions\/578"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/media\/309"}],"wp:attachment":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/categories?post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/tags?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}