{"id":5785934,"date":"2015-02-13T14:46:50","date_gmt":"2015-02-13T14:46:50","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/message-if-no-items-are-returns\/"},"modified":"2016-08-22T16:30:49","modified_gmt":"2016-08-22T16:30:49","slug":"message-if-no-items-are-returns","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/message-if-no-items-are-returns\/","title":{"rendered":"Message if no items are returns"},"content":{"rendered":"<p>Hi Paul,<br \/>\nI&#8217;m really finding your plugin very useful.<\/p>\n<p>I&#8217;m using it to pull a list of information leaflets based on what they&#8217;re tagged and display them using display_item_callback in my functions.php<\/p>\n<p>The leaflets are tagged with &#8216;expired&#8217; or &#8216;not-expired&#8217; and won&#8217;t display if leaflet is missing the &#8216;not-expired&#8217; tag. I have 50 odd pages that display leaflets based on the department or specialty and sometimes the leaflets expire before they are renewed.<\/p>\n<p>The only thing I haven&#8217;t been able to figure out is how to display a message if no leaflets are returned. I&#8217;m not experienced enough in php to know how to add a check in my functions.php<\/p>\n<p>I have<\/p>\n<pre><code>function pdfs_mediatags($post_item)\n{\n$media_src = wp_get_attachment_url($post_item-&gt;ID);\nreturn &#039;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;&#039;.$media_src.&#039;&quot; title=&quot;&#039;.$post_item-&gt;post_title.&#039; class=&quot;media-tag-list clearfix&quot; id=&quot;media-tag-item-&#039;.$post_item-&gt;ID.&#039;&quot;&gt;&#039;.$post_item-&gt;post_title.&#039;&lt;\/a&gt;&lt;\/td&gt;&lt;td&gt;&#039;.mysql2date(&quot;j M Y&quot;, $post_item-&gt;post_date).&#039;&lt;\/td&gt;&lt;\/tr&gt;&#039;;<\/code><\/pre>\n<p>I know this isn&#8217;t good practice, but I managed to edit your mediatags_shortcodes.php file like so, which gives me what I need, but obviously as you update your plugin, I&#8217;ll need to keep a track of this<\/p>\n<pre><code>function mediatags_shortcode_handler($atts, $content=null, $tableid=null)\n{\n\tglobal $mediatags;\n\n\tif ((!isset($atts[&#039;return_type&#039;])) || ($atts[&#039;return_type&#039;] != &quot;li&quot;))\n\t\t$atts[&#039;return_type&#039;] = &quot;li&quot;;\n\n\tif (!isset($atts[&#039;after_list&#039;])) {\n\t\tif (isset($atts[&#039;before_list&#039;])) {\n\t\t\tif ($atts[&#039;before_list&#039;] == &quot;ul&quot;)\n\t\t\t\t$atts[&#039;after_list&#039;] = &quot;&lt;\/ul&gt;&quot;;\n\t\t\telse if ($atts[&#039;before_list&#039;] == &quot;ol&quot;)\n\t\t\t\t$atts[&#039;after_list&#039;] = &quot;&lt;\/ol&gt;&quot;;\n\t\t} else {\n\t\t\t$atts[&#039;after_list&#039;] = &quot;&lt;\/ul&gt;&quot;;\n\t\t}\n\t}\n\n\tif (!isset($atts[&#039;before_list&#039;])) {\n\t\t$atts[&#039;before_list&#039;] = &quot;&lt;ul&gt;&quot;;\n\t}\n\n\tif (!isset($atts[&#039;error_message&#039;])) {\n\t\t$atts[&#039;error_message&#039;] = &quot;&quot;;\n\t}\n\n\tif ((!isset($atts[&#039;display_item_callback&#039;])) || (strlen($atts[&#039;display_item_callback&#039;]) == 0))\n\t\t$atts[&#039;display_item_callback&#039;] = &#039;default_item_callback&#039;;\n\n\/\/\tif (isset($atts[&#039;post_parent&#039;])) {\n\/\/\t\tif (($atts[&#039;post_parent&#039;] == &quot;this&quot;) || ($atts[&#039;post_parent&#039;] == &quot;self&quot;)) {\n\/\/\t\t\t$atts[&#039;post_parent&#039;] = $post-&gt;ID;\n\/\/\t\t}\n\/\/\t}\n\t$atts[&#039;call_source&#039;] = &quot;shortcode&quot;;\n\n\t\/\/echo &quot;atts&lt;pre&gt;&quot;; print_r($atts); echo &quot;&lt;\/pre&gt;&quot;;\n\n\tif (!is_object($mediatags))\n\t\t$mediatags = new MediaTags();\n\n\t$output = $mediatags-&gt;get_attachments_by_media_tags($atts);\n\tif ($output)\n\t{\n\t\tif (isset($atts[&#039;before_list&#039;]))\n\t\t{\n\t\t\t$output = $atts[&#039;before_list&#039;] . $output;\n\t\t}\n\n\t\tif (isset($atts[&#039;after_list&#039;]))\n\t\t{\n\t\t\t$output = $output .$atts[&#039;after_list&#039;];\n\t\t}\n\t}\n\telse {\n\t\t$output = $output .$atts[&#039;error_message&#039;];\n\t}\n\treturn $output;\n\n}<\/code><\/pre>\n<p>Is there a way of doing this with hacking your code?<\/p>\n<p>Many thanks<br \/>\nHuseyin<\/p>\n<p>https:\/\/wordpress.org\/plugins\/media-tags\/<\/p>\n","protected":false},"template":"","class_list":["post-5785934","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5785934","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5785934\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=5785934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}