Support » Plugin: DK PDF » Exclude the pdf button text from the excerpt function

  • Resolved fciotola


    Exclude the pdf button text from the excerpt function:

    $post_type = ‘post’;

    // Get all the taxonomies for this post type
    $taxonomies = get_object_taxonomies( array( ‘post_type’ => $post_type ) );

    foreach( $taxonomies as $taxonomy ) :

    // Gets every “category” (term) in this taxonomy to get the respective posts
    $terms = get_terms( $taxonomy );

    foreach( $terms as $term ) : ?>

    <h2 class=”entry-title” ><?php echo $term->name; ?></h2>

    $args = array(

    ‘post_type’ => $post_type,
    ‘posts_per_page’ => -1, //show all posts
    ‘tax_query’ => array(
    ‘taxonomy’ => $taxonomy,
    ‘field’ => ‘slug’,
    ‘terms’ => $term->slug,
    ‘cat’ => ‘-3’

    $posts = new WP_Query($args);

    if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post(); ?>

    <article id=”prodotti”>

    <?php if(has_post_thumbnail()) { ?>
    ” title=”<?php echo get_the_title(); ?>”>
    <?php the_post_thumbnail(‘archive-custom-size’, array( ‘class’ => ‘aligncenter’ )); ?>

    <?php }
    /* no post image so show default */
    else { ?>
    /assets/img/default-img.png” alt=”<?php echo get_the_title(); ?>” title=”<?php echo get_the_title(); ?>” width=”110″ height=”110″ />
    <?php } ?>

    <h3 >” title=”<?php echo get_the_title(); ?>”><?php echo get_the_title(); ?></h3>

    <?php the_excerpt(); ?>

    </article><!– about-box –>

    <?php endwhile; endif; ?>

    <?php endforeach;

    endforeach; ?>

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author dinamiko


    Hi fciotola,

    How are you adding the PDF button?
    via DK PDF Settings / PDF Button / Post types to apply
    or manually adding [dkpdf-button] shortcode in each post?


    Thanks for the fast reply, I’m adding the pdf button via DK PDF Settings.

    Plugin Author dinamiko


    I’m not being able to reproduce the problem, I don’t see the PDF button in the_excerpt, I only see the button if I change the_excerpt for the_content.

    What you can try to do is filter the_excerpt and delete the button, something like this:

    function custom_excerpt_filter( $excerpt ) {
       $excerpt = str_replace( "[dkpdf-button]", "", $excerpt );
       return $excerpt;
    add_filter( 'get_the_excerpt', 'custom_excerpt_filter' );

    more info here:


    • This reply was modified 3 years, 3 months ago by dinamiko.

    you can see the problem here:

    How you can see in this page the label of the button is in the start of every single excerpt.

    Plugin Author dinamiko


    Hi fciotola,

    I don’t see the PDF button in the excerpts in your url, so I think you got it 🙂
    I’m going to close this ticket, feel free to reopen it anytime or create a new one.


    Plugin Author dinamiko


    Sorry, I see it now 🙂
    what you have to do is add this code to your theme functions.php

    function custom_excerpt_filter( $excerpt ) {
       $excerpt = str_replace( "Download PDF ", "", $excerpt );
       return $excerpt;
    add_filter( 'get_the_excerpt', 'custom_excerpt_filter' );

    try it and tell me if it works.


    Thanks Dinamiko it work like charm.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Exclude the pdf button text from the excerpt function’ is closed to new replies.