Support

Account

Forum Replies Created

  • Since my client is pressuring me a lot, I ditched srcset temporary to get a proper title.

    <?php          
          if( have_rows('kunden') ):
            while( have_rows('kunden') ) : the_row(); ?> 
              <?php 
                   $image = get_sub_field('bild');
                   $size = 'thumbnail';
                   $thumb = $image['sizes'][ $size ];
                   if( !empty( $image ) ): ?>
                     <div class="medium-3 columns">
                       <img />" alt="<?php echo esc_attr($image['alt']); ?>" title="<?php echo esc_attr($image['title']); ?>" />
                     </div>
                    <?php endif; ?>
            <?php endwhile;
                  else :
                  endif; 
                          ?>

    Since wp_get_attachment doesn’t return the right img title by default, I tried workarounds. The ones I found where messing up the site or didn’t work at all and my own didn’t work as well.

    After rethinking the title attribute, I just decided to get rid of it.

    Used

    add_filter('wp_get_attachment_link', 'opt_remove_title_attr');
    add_filter('wp_get_attachment_image', 'opt_remove_title_attr');
    add_filter('wp_nav_menu', 'opt_remove_title_attr');
    add_filter('wp_page_menu', 'opt_remove_title_attr');
    add_filter('wp_list_categories', 'opt_remove_title_attr');
    add_filter('wp_list_pages', 'opt_remove_title_attr');
    add_filter('wp_get_archives', 'opt_remove_title_attr');
    add_filter('get_archives_link', 'opt_remove_title_attr');
    add_filter('post_thumbnail_html', 'opt_remove_title_attr');
    function opt_remove_title_attr($return){
        return preg_replace('<code>title=&quot;(.+)&quot;</code>', '',$return);
    }  

    To get rid of any title and used the code I used before, now it works like a charm, with no title attribute and srcset.

    Maybe this helps someone having the same issue.

  • It returns the image with srcset and title=”home”. And yes the Title Attribute. Alt attribute is working, but title is a must for my client.

    <img width="400" height="400" src="***/wp-content/uploads/General-Motors.jpg" class="attachment-thumbnail size-thumbnail" alt="General Motors" loading="lazy" srcset="***/wp-content/uploads/General-Motors.jpg 400w, ***/wp-content/uploads/General-Motors-300x300.jpg 300w" sizes="(max-width: 639px) 98vw, (max-width: 1199px) 64vw, 400px" title="Home">

    I censored the URL it’s https:// if that makes any difference (which I guess it doesn’t)

  • Thanks for getting involved and confirm my research. I’ll take this to the WordPress Forums or Github.

  • We narrowed it down to Oembed now, if we use the embed code Vimeo provides and use a text field it works. But we also discovered that the same problems occur in Gutenberg if you add a video so it may not be am ACF Problem at all but a WordPress Core Problem.

  • You better put this into a new post. This Thread is 7 Years old.

  • This is extremly embarassing but one of my team added a greek question mark to my code…

    Edit: It’s not in this code but in another part of the sites code, so if anyone needs a tripple nesting code example that works, here it is.

  • Since deleting the suppress-filter it’s working fine for me and ACF is running like a charm again, no odd behavior whatsoever, but I know that it’s still affecting every query, I’m narrowing it down to certain Post Types.

    I just want to know if it’s the suppress-filter that interfered with ACF or am I overlooking something?

  • Looks like you walked into a temporary Error, for me (germany) it’s working fine.

    Is it working for you now as well?

  • This was exactly was I was looking for, great answer, but for any PHP newbies, who will likely use it with opening and closing tags I added a “revised” Version, I myself hat trouble with the code because I forgot the “:”.

    Anyways perfect Code for the Problem, using Repeater is not an alternative for blocks.

    <?php $field = get_field('video_feature');
    if ($field && $field['video_description'] && $field['video_description']): ?>
  • Only the WYSIWYG Editor is capable of interpreting Shortcodes, else you have to echo the shortcode

    
    $shortcode = get_field('shortcode');
    echo do_shortcode(' . $shortcode . ');

    Cheers
    Johannes

  • I think this way to harsh, I’d like to have a more complex documentation myself and would love to have it as a PDF aswell so that I can develop without internet connection on the road.

    But Elliot is giving this plugin away for free and the Pro Developer Licence price is a Joke compared to other less use-full plugins, imho it’s the best there is, you can do all with it.

    And if you all-ready are writing your own docs why not share them with Elliot so he can add them. The documentation is the best for a plugin I have ever seen, of course some things are missing (which Elliot covers sometimes on YT).

  • A cronjob based approach would be the best way, store the values in variables and change the variable with code executed by a cronjob, I found a quite extensive thread on Stackoverflow

    Stackoverflow

    To summarise it I quote one of the Threads in case it gets closed

    [shortened quote] The script will only run if you have a cron-job or someone access the page. (and a cron job is basically the computer accessing the page at a specific time!)

    If you want a variable dependant on time of day simply use a if statement

    (pseudo code)

    if(now() < $time){
        $var = 1;
    }else{
        $var = 2;
    }

    This means that anyone who visits the page before $time gets $var1 and after gets $var2

    You will also find an introduction to cronjobs here

    Cron Jobs

    The big question is if you are familiar with cron jobs and if your hosting environment allows them.

    I hope this will put you on the right track!

    Cheers
    Johannes

Viewing 12 posts - 1 through 12 (of 12 total)