0

I want to get this function from functions.php file

function twentyseventeen_excerpt_more( $link ) {
    if ( is_admin() ) {
        return $link;
    }

    $link = sprintf( '<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
        esc_url( get_permalink( get_the_ID() ) ),
        /* translators: %s: Name of current post */
        sprintf( __( 'Continue readingggg<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ), get_the_title( get_the_ID() ) )
    );
    return ' &hellip; ' . $link;
}
add_filter( 'excerpt_more', 'twentyseventeen_excerpt_more' );

And in my shorcode file to remove the 'Continue readinggg' text with empty string for example (or simply remove it). How can i do it ? I have to use into this statement:

if($content=='true'){
                                                the_content();
                                            }
                                            if( $excerpt=='true' ) {
                                                if( $readmore=='true' ) {
                                                    echo get_the_excerpt()."<a href='".get_permalink($article_id)."'><button>Read More</button></a>";
                                                } else {
                                                    the_content();
                                                }
                                            }

How it can be done ?

0

2 Answers 2

1

You should call the same filter in your shortcode but with a higher priority :

your_shortcode_function() {
   // Your code
   add_filter( 'excerpt_more', 'my_excerpt_code', 20 );
}
function my_excerpt_code($link) {
   return '';
}

The twentyseventeen function has a default priority of 10, if you put a higher priority, it will be executed after, so it should erase the link.

Edited :

Ok, if you just want to remove the excerpt with the_content, you can use this :

the_content(null, false);

As you can see here : https://developer.wordpress.org/reference/functions/the_content/ It should remove the "see more" button.

Sign up to request clarification or add additional context in comments.

1 Comment

I've edited my question. Can you plelase take a look ?
0

in case someone needs this. Here is my approach:

function get_current_url() {
    $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https://" : "http://";
    $host = $_SERVER['HTTP_HOST'];
    $uri = $_SERVER['REQUEST_URI'];
    $fullURL = $protocol . $host . $uri;
    return $fullURL;
}

global $currentURL;
global $currentID;
$currentURL = get_current_url(); 
$currentID = url_to_postid($currentURL);

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.