• Hi,
    First of all, thank you very much for your plugin.

    I want to have some nice and clean html, seo friendly output as the following example:

    <section>
    <article>
    <a href="#"><img src="#" /></a>
    <h2><a href="#">Post title</a></h2>
    </article>
    </section>

    It is posible to not modify the core of plugin (so I can have updates), with the html structure that I need? (e.g. like a special function in functions.php).

    Thanks,

    https://www.ads-software.com/plugins/contextual-related-posts/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ajay

    (@ajay)

    Hi,

    You could create a piece of code like this where ever you want to display the code.

    I haven’t tested this one.

    if(function_exists('get_crp_posts_id')) {
    global $post;
    $scores = get_crp_posts_id( array('postid' => $post->ID, 'limit' => 7 ) );
    $posts = wp_list_pluck( $scores, 'ID' );
    $args = array(
      'post__in' => $posts,
      'posts_per_page' => 7,
      'ignore_sticky_posts' => 1
    );
    $my_query = new WP_Query($args);
    if ($my_query->have_posts()) {
    while ($my_query->have_posts()) {
    $my_query->the_post();
    echo '<a href="' .  get_permalink( get_the_ID() ) . '">';
    the_title();
    echo '</a>';
    wp_reset_postdata();
    wp_reset_query();
    }
    }
    else {
    }
    }
    Thread Starter fii.digital

    (@noidoi)

    Thanks for the answer.

    Let’s say that I have a large amount of articles, and I want to use the cache functionality – the one that fill the crp_related_posts custom field. In that case I can use the function

    <?php if(function_exists('echo_ald_crp')) echo_ald_crp(); ?>

    to call crp, and the function will return the content of custom field.

    So:
    How can I have that simple HTML example in that custom field? (in the crp plugi file you have defined the default markup for the function – that’s what I want to change).

    The above example works perfectly, but I have to optimize the load.

    Thanks a lot for your support.

    Plugin Author Ajay

    (@ajay)

    Hi,

    I think it might be possible to actually avoid custom code and just use the HTML fields under Customize the output in Output Options.

    HTML to display before the list of posts: <section>
    HTML to display before each list item: <h2>
    HTML to display after each list item: </h2>
    HTML to display after the list of posts: </section>

    Can you try this and see if it works? With this option, the img will also be wrapped within the h2.

    Thread Starter fii.digital

    (@noidoi)

    I tried this solution prior to my first message.

    I want to have simple and in a way semantic markup. This is the way that all others articles are displayed, I have a single class for them, and the media-queries are linked to base classes, so:

    <section>
    <article>
    <a href="#"><img src="#" /></a>
    <h2><a href="#">Post title</a></h2>
    </article>
    
    <article>
    <a href="#"><img src="#" /></a>
    <h2><a href="#">Post title</a></h2>
    </article>
    </section>

    it’s the markup that I search for.

    In the future, maybe, in the options panel, it will be nice if you add some custom markup template like:

    <article>%title%</article>
    <h2>%title%</h2>
    <img src="%image%" />

    or something like this.

    Thanks for your time. I will find a solution for my strictly markup ??

    Plugin Author Ajay

    (@ajay)

    Hi,

    The custom template is a pro feature that I’m working on.

    On the markup point, I understand that you’re main concern is regarding the caching. In theory, you should be able to easily throw in the caching option.

    Instead of echoing the output above, you can save it in a variable and then use an update_meta to add it to the custom field.

    I also had this problem and went ahead and revised the $output on lines 100 and 122 to get the HTML I wanted.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom HTML output’ is closed to new replies.