• Resolved berry metal

    (@erikalleman)


    Hi there,

    I am unable to exclude classes.

    Here is my HTML:

    flameshot_screenshot

    and here are my settings:

    flameshot_screenshot

    But links are excluded at the HTML elements as well, and that post entry title is a link, so widows shouldn’t be prevented on that link.

    I have cleared the wp-Typography plugin cache, my grid cache, and all my other caches, CDN, etc…

    Am I specifying something wrong in my settings?

    • This topic was modified 3 years, 1 month ago by berry metal.
    • This topic was modified 3 years, 1 month ago by berry metal.
Viewing 15 replies - 1 through 15 (of 50 total)
  • Plugin Author pepe

    (@pputzer)

    The ignored element has to be in the string that is passed to the wp-Typography filter function (i.e. most of the time, part of the content markup). Exclusion will not work for HTML in theme templates. That is a technical limitation of how WordPress filter hooks work.

    Thread Starter berry metal

    (@erikalleman)

    Could you explain where should the class or element be if not in theme templates in order to be able to exclude it?

    Thread Starter berry metal

    (@erikalleman)

    It seems that all link elements are already excluded in the settings. Since my title is a link, and that fact is not related to templates, why it won’t be excluded?

    • This reply was modified 3 years, 1 month ago by berry metal.
    Plugin Author pepe

    (@pputzer)

    Your post content almost certainly contains HTML elements, and your titles might. As stated in the FAQ, the “ignore” settings only work on elements/classes that are part of the content (both post titles and post content proper count as “content”, i.e. what’s in the database and not in PHP files).

    Why do you believe your title to be a link “unrelated to templates”?

    Thread Starter berry metal

    (@erikalleman)

    I understand now.
    I thought wp-Typography detects links universally by some other mechanism than looking in “the content”, because exclusion of links is excluded by default at the elements exclusion.
    It seems that it means only links in “the content”.
    If I add a span via the_title hook to all post titles, will that be in the content?
    Could you recommend a way to check what is actually in the content?
    Should I look in the database?
    I want to check if there are any elements or classes included by default in the wp post title…
    Thanks!

    • This reply was modified 3 years, 1 month ago by berry metal.
    • This reply was modified 3 years, 1 month ago by berry metal.
    • This reply was modified 3 years, 1 month ago by berry metal.
    Plugin Author pepe

    (@pputzer)

    There are not, unless you put them there when you were writing the post. If you add the span with a filter that runs earlier than wp-Typography’s, that should work, yes.

    Plugin Author pepe

    (@pputzer)

    PS: Links (a elements) are not ignored in the default configuration.

    Thread Starter berry metal

    (@erikalleman)

    Sorry then maybe I was the one who added a links to the excluded elements…
    Great, now I start to understand it.

    Thread Starter berry metal

    (@erikalleman)

    Hi again,

    I realized that my grid is actually not being affected by wp-Typography.

    After sorting out how to exclude content, can you advise how to include all my grid content to wp-Typography?

    My posts are made of post types that are assembled in a grid by a grid software.

    So I would need to include a post type into wp-Typography.
    Is that possible?
    Thanks.

    • This reply was modified 3 years, 1 month ago by berry metal.
    Plugin Author pepe

    (@pputzer)

    You can use the API to add wp-Typography processing to an appropriate filter hook – that really depends on what your grid plugin does in their post template. wp-Typography itself is not locked by post type, but I’m assuming your grid does not apply the the_content filter.

    Thread Starter berry metal

    (@erikalleman)

    These are my 2 dynamic queries in the grid filter, the first for my “item” post type that is fetched by the grid (this is where wp-Typography is not applied), and the second for my related post entries (that is where wp-Typography is getting applied):

    function prefix_query_args( $query_args, $grid_id ) {
    
        
        if ( 2 === $grid_id ) {
    
    global $post;
    
    $referer = wp_get_referer();
    $post_id = wp_doing_ajax() ? url_to_postid( $referer ) : $post->ID;
    
            $terms = wp_get_post_terms( $post->ID, 'relations' );
            $query_args['tax_query'] = array(
            array(
                'taxonomy'  => 'relations',
                'field'     => 'term_id',
                'terms'     =>  $terms[0],
            ),
        );
        $query_args['post_type'] = 'items';
        
        }
    
        return $query_args;
    
    }
    
    add_filter( 'wp_grid_builder/grid/query_args', 'prefix_query_args', 10, 2 );
    
    add_filter(
        'wp_grid_builder/grid/query_args',
        function( $query_args, $grid_id ) {
    
            global $post;
    
            if ( 3 === $grid_id ) {
    
                $referer = wp_get_referer();
                $post_id = wp_doing_ajax() ? url_to_postid( $referer ) : $post->ID;
                $related = get_post_meta( $post_id, 'related_post_ids', true );
    
                if ( ! empty( $related ) ) {
    
                    $query_args['post__in'] = explode( ',', $related );
                    unset( $query_args['category__in'] );
    
                }
            }
    
            return $query_args;
    
        },
        10,
        2
    );

    What is wrong with the first filter, so that wp-Typography does not get applied there?

    Plugin Author pepe

    (@pputzer)

    There is probably nothing wrong with those queries, but those are not the filters your are looking for. I was talking about the template/function used to display the result your grid.

    Plugin Author pepe

    (@pputzer)

    Do you still need help with this, @erikalleman?

    Thread Starter berry metal

    (@erikalleman)

    Hi,

    yes, I still need help with this.

    I use these filters:

    add_filter('wp_grid_builder/the_excerpt', [ 'WP_Typography', 'process' ] );
    add_filter('wp_grid_builder/the_content', [ 'WP_Typography', 'process' ] );

    But I need to add a conditional like this:

    if ( 2 === $grid_id ) {}

    But because there is no function in the filters above, I don’t know how to add the conditional.

    Could you (or someone else) help with the syntax?

    Thanks.

    Thread Starter berry metal

    (@erikalleman)

    Would something like this be valid?

     if ( 2 === $grid_id ) {
     add_filter('wp_grid_builder/the_excerpt', [ 'WP_Typography', 'process' ] );
     }
Viewing 15 replies - 1 through 15 (of 50 total)
  • The topic ‘cannot exclude element’ is closed to new replies.