Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author DaveE

    (@dpe415)

    Hi Adriano,

    Thanks for using the plugin. If I understand your question correctly, you’d like widget to have no text output if it doesn’t find any posts. If that is your question, it is possible. You’ll want to create a custom HTML template first. Then in your custom HTML template, you want to remove the following lines of code:

    <?php else: // We have no posts ?>
    	<div class="dpe-flexible-posts no-posts">
    		<p><?php _e( 'No post found', 'flexible-posts-widget' ); ?></p>
    	</div>
    <?php

    By removing the code in the PHP else block, the widget will display nothing if there are no results.

    By the way, it appears the site you referenced is written in Italian. If you created an Italian translation for Flexible Posts Widget, I would love to include it with the plugin. Would you be open to sharing your translation files (PO & MO) with me?

    Thank you!

    Thread Starter Adriano G. V. Esposito

    (@adriano-esposito)

    Hi Dave, thanks for your help!

    I did not translate the po/mo but I can translate it for you if you want.

    Plugin Author DaveE

    (@dpe415)

    That would be great. To create the Italian MO & PO file, you’d want to download the plugin’s POT file and open it in an editor like Poedit. Poedit will create the correct PO & MO files for you after you’ve translated the text strings in the POT file.

    if this is not up your alley or too much work, I completely understand. Thanks again!

    Thread Starter Adriano G. V. Esposito

    (@adriano-esposito)

    I already did this kind of stuff in the past. I will do and I’ll send to you the whole po/mo pair ??

    Thread Starter Adriano G. V. Esposito

    (@adriano-esposito)

    Back to the topic: I noticed I have in my already customized template file this rows echoed:

    echo "<div class=\"dpe-flexible-posts no-posts\">";
    echo "<p><?php _e( 'No post found', 'flexible-posts-widget' ); ?></p>";
    echo "</div>";

    I really dont know why… I dont remember… Anyway your original template widget.php do not show this code so it is entirely a problem of mine. Sorry ??

    Plugin Author DaveE

    (@dpe415)

    if you remove or comment out those three lines, you should get the results you’re looking for.

    Thread Starter Adriano G. V. Esposito

    (@adriano-esposito)

    Yeah.

    The bigger problem was that in this line

    echo "<p><?php _e( 'No post found', 'flexible-posts-widget' ); ?></p>";

    php code did not work, obviously, because it was render as a string, and I noticed in the html code rendered by the browser the 2 php tags showed. Now I just go back to your default code and the html rendered is good.

    Thank you anyway.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘PHP code commented when a category is empy’ is closed to new replies.