WordPress.org

Forums

Flexible Posts Widget
[resolved] PHP code commented when a category is empy (8 posts)

  1. Adriano G. V. Esposito
    Member
    Posted 1 year ago #

    Hi,

    I use your very nice widget with no problems.

    I just noticed that when a cat has no posts in the widget appears a PHP code HTML commented, like this:
    <div class="dpe-flexible-posts no-posts"><p><!--?php _e( 'No post found', 'flexible-posts-widget' ); ?--></p></div>

    I would like to know if it is a possibility to modify this behavior in mode I have no PHP code at all insteat that commented.

    Thank you very much!

    Site: http://www.cambiamolascuola.org/

    http://wordpress.org/plugins/flexible-posts-widget/

  2. DaveE
    Member
    Plugin Author

    Posted 1 year ago #

    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!

  3. Adriano G. V. Esposito
    Member
    Posted 1 year ago #

    Hi Dave, thanks for your help!

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

  4. DaveE
    Member
    Plugin Author

    Posted 1 year ago #

    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!

  5. Adriano G. V. Esposito
    Member
    Posted 1 year ago #

    I already did this kind of stuff in the past. I will do and I'll send to you the whole po/mo pair :-)

  6. Adriano G. V. Esposito
    Member
    Posted 1 year ago #

    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 :D

  7. DaveE
    Member
    Plugin Author

    Posted 1 year ago #

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

  8. Adriano G. V. Esposito
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Flexible Posts Widget
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic