• Resolved pixelkicks

    (@pixelkicks)


    Hi,

    I’m using the wpp_get_mostpopular function, and trying to customize the post_html variable.

    Using the example code as such, it works correctly:

    <li>{thumb} <a href='{url}'>{text_title}</a> </li>

    However I want to modify it to the following, but it doesn’t display anything at all:

    <li> <a href='{url}'>{text_title}{thumb}</a> </li>

    Why is this? Shouldn’t it allow me to format the output as I wish?

    Thanks,

    Chris.

    https://wordpress.org/plugins/wordpress-popular-posts/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hey, Chris!

    However I want to modify it to the following, but it doesn’t display anything at all

    It sounds like you didn’t escape the quotes properly, breaking the function. Please post the full code so I can take a look.

    Thread Starter pixelkicks

    (@pixelkicks)

    Hi Hector,

    The example you’ve given doesn’t say you need to escape the quotes. Here’s what I’m using:

    <?php
    $posthtml = "<li><a href='{url}'>{text_title}{thumb} </a> </li>";
    ?>
    <?php wpp_get_mostpopular("range=weekly&limit=8&order_by=views&title_length=8&title_by_words=1&thumbnail_width=237&thumbnail_height=177&stats_views=0&freshness=1&post_html=".$posthtml);
    ?>

    Simply moving the {thumb} variable inside the a tag causes it not to work.

    Plugin Author Hector Cabrera

    (@hcabrera)

    This works for me:

    <?php
    wpp_get_mostpopular( "range=weekly&limit=8&order_by=views&title_length=8&title_by_words=1&thumbnail_width=237&thumbnail_height=177&stats_views=0&freshness=1&post_html=\"<li><a href='{url}'>{thumb} {text_title}</a> </li>\"" );
    ?>

    However, notice that the {thumb} tag returns a linked thumbnail (eg. <a href="URL-HERE"><img src="IMG-URL-HERE"></a>). You’d be embedding an A tag inside another one with that code, which is not valid HTML.

    I believe using WPP’s filter hooks on your case might be more appropriate. Check this sample code, might be useful for you.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘"post_html" problem using PHP code’ is closed to new replies.