embigmotive
embigmotive

Reputation: 11

Removing the excerpt read more link WP REST API

I've recently installed WordPress REST API on one of my blog sites and have been using it to allow me to pull in blog posts into another static site. I have been using the following PHP to pull in the articles and their content:

<?php

    $json = file_get_contents('http://news.cribrater.com//wp-json/posts?filter[posts_per_page]=2');
    $posts = json_decode($json);

    foreach ($posts as $p) {

      echo '<li>';
      echo $p->featured_image ? '<figure class="wordpress-loop-bg-image" style="background: url(' . $p->featured_image->guid . ') no-repeat center; background-size: cover; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; ">' : '';
      echo '<figcaption><p>' . date('M j, Y', strtotime($p->date)) . '</p>  </figcaption></figure>';
      echo '<h4><a href="' . $p->link . '">'. $p->title . '</a></h4>';
      echo '' . $p->excerpt . '';
      echo '</li>';

    }

?>

My issue is that I can't figure out how to hide the "Read More" link that appears after the "excerpt". I can't edit the WordPress site functions file as I do need the "Read More" link for that site but would like it to be hidden on the static site.

Any help would be appreciated. Thanks.

Upvotes: 1

Views: 2389

Answers (1)

Marco Romano
Marco Romano

Reputation: 456

You can write

 .moretext {
           display: none
    }

Or use this functions in your functions.php and write what you want or leave empty.

function modify_read_more_link() {
    return '<a class="more-link" href="' . get_permalink() . '">Your Read More Link Text</a>';
}
add_filter( 'the_content_more_link', 'modify_read_more_link' );

Take a look in the post there are good answer: https://codex.wordpress.org/Customizing_the_Read_More

Upvotes: 0

Related Questions