jtm12
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Get Images from Media Library and Sort by Alt TagI need to correct the code above.
Here is the code that works for me to order images from the media library by the alt tag:
<?php $query_images_args = array 'post_type' => 'attachment' 'category_name' => 'colors', 'post_mime_type' => 'image', 'post_status' => 'inherit', 'posts_per_page' => 30, 'meta_key' => '_wp_attachment_image_alt', 'orderby' => '_wp_attachment_image_alt', 'order' => 'ASC' ); $query_images = new WP_Query( $query_images_args ); if($query_images->have_posts()) : while($query_images->have_posts()) : $query_images->the_post(); ?> <h4><?php the_title(); ?></h4> <?php echo $images = wp_get_attachment_image( $query_images->posts->ID, 'large', '', array( "class" => "img-fluid mx-auto d-block", "alt" => get_post_meta(get_the_ID() , '_wp_attachment_image_alt', true))); ?> <?php endwhile; ?> <?php endif; ?> <?php wp_reset_postdata(); ?>`
Forum: Developing with WordPress
In reply to: Get Images from Media Library and Sort by Alt TagThis was resolved.
Forum: Developing with WordPress
In reply to: Get Images from Media Library and Sort by Alt TagI made the changes, including deleting the meta_key line completely, and the code below worked perfectly! Thank you.
<?php $query_images_args = array( 'post_type' => 'attachment', 'category_name' => 'colors', 'post_mime_type' => 'image', 'post_status' => 'inherit', 'posts_per_page' => 30, 'orderby' => '_wp_attachment_image_alt', 'order' => 'ASC' );$query_images = new WP_Query( $query_images_args );
if($query_images->have_posts()) :
while($query_images->have_posts()) :
$query_images->the_post(); ?><h4><?php the_title(); ?></h4>
<?php echo $images = wp_get_attachment_image( $query_images->posts->ID, ‘large’, ”, array( “class” => “img-fluid mx-auto d-block”, “alt” => get_post_meta(get_the_ID() , ‘_wp_attachment_image_alt’, true)));
?>
`Last post, I promise.
So it turns out that GTM has a built-in YouTube trigger for embedded YouTube videos.
It’s very easy to set up, relatively speaking (GTM can be a bit overwhelming at first), and the following tutorial explains it so well with images that I won’t recreate those instructions here:
https://marketlytics.com/analytics-faq/track-youtube-videos-google-tag-manager/
I have no affiliation with that website.
I did update your plugin on my website to the latest version and made sure these instructions work on the latest version. They do.
I tried the instructions on a website where I just have a YouTube video embedded with no plugin. Works there, too.
And all those GTM built-in video variables (video URL, video title, video duration, etc.) that I mentioned earlier work if you set up YouTube tracking using the instructions in that link.
However, that’s the only type of video that the variables work with (so far). I don’t have them working with a video uploaded through WordPress.
Thank you for letting me code out loud through all this. It pushed me to keep going.
I’m not sure how much to post on what I’ve learned in GTM the past two weeks. Please delete this if it is too much information.
Changing the player type to JavaScript from an iframe in the settings worked perfectly. Thank you for that instruction.
A problem still exists with embedded YouTube videos, which continue to use an iframe.
On a desktop with the YouTube videos, I believe users see a thumbnail type image uploaded to the video with your plugin, if a photo has been uploaded,
and the play button generated by the plugin, so those are clickable, and GTM can access those and record the YouTube video click.On mobile, my testing suggests that the YouTube video itself shows, and I haven’t found a clickable element there, yet.
Based on my work so far, I believe that setting up a tag in Google Tag Manager to capture clicks on videos displayed through your plugin requires three parts (and this is working on my website):
–Custom JavaScript under “Variables” to grab the right element(s).
–A trigger listening for a click on .vjs-big-play-button (the player button), .poster (the image background), or video-js#aiovg-player-1 (the clickable element on mobile).
–A tag that sends the element(s) grabbed in Step 1 to Google Analytics as an event.
I’m in the process of developing my JavaScript skills now, so I went with separating my Custom JavaScript entries into three functions rather than trying to do this with one.
User Defined Variables are at the bottom of the Variables section in GTM. I used the Custom JavaScript option, not the JavaScript Variable option.
The different Custom JavaScript functions address the fact that different video elements load from the plugin depending on whether the user is on a desktop or mobile device and looking at an uploaded video or embedded video.
The first Custom JavaScript entry grabs the SRC in videos that I have uploaded. Those are named with something I recognize, so the SRC is relevant and understandable.
function() {
var getVideoSrc = document.querySelector(‘.vjs-big-play-button’).parentNode.childNodes[0].src
return getVideoSrc;
}I named this entry Get Player SRC.
The second Custom JavaScript entry grabs my uploaded image (using the plugin) of the YouTube videos I have embedded because the YouTube URLs (random numbers and letters) do not identify the video for me. A video title would be better.
function() {
var posterName = document.getElementById(‘aiovg-player-1’).getAttribute(‘poster’);
return posterName;
}I named this second entry Get YouTube Video Image.
The third Custom JavaScript entry gets the SRC on a mobile device of a video I uploaded to the site. The div structure on mobile devices appears to be different, so moving up and down the DOM takes less steps.
function() {
var mobilePlayerSRC = document.getElementById(‘aiovg-player-1’).childNodes[0].getAttribute(‘SRC’);
return mobilePlayerSRC;
}I named the third entry Get Mobile Video Player SRC.
Again, the YouTube videos on mobile have nothing for GTM to record as a click because everything is in the iframe, as far as I can tell. I have no solution yet for capturing those clicks.
Once those user-defined Custom Variables are set up, it’s time to make the trigger.
Under Triggers, create a new trigger.
I selected Click All Elements in the top area, and then Some Clicks in the middle area. For my filter, I chose Click Element and Matches CSS selector, and then I entered in the field the following:
button.vjs-big-play-button, div.vjs-poster, video-js#aiovg-player-1
The commas signify “or.”
I named the trigger Video Button Trigger.
For the Tag, which sends the info to Google Analytics, I chose the following. I selected Google Analytics: Universal Analytics for the Tag Type and Event for Track Type.
I entered Event Video Button Click in the category (you can type anything).
I chose my three potential variables in the Action section, and that looks like this (I added the pipes between them, but I might take them out):
{{Get Desktop Video Player SRC}} | {{Get YouTube Video Image}} | {{Get Mobile Video Player SRC}}
And I used for the Label section the page path. That’s selectable and looks like this: {{Page Path}}
I left Noninteraction Hit as false. I want Google to record a hit.
I entered my GA account under Google Analytics settings.
And in the Triggers area, I selected my Video Button Trigger.
I called the tag Send to GA Video Clicks, and I saved it.
I am quite sure this is not the most elegant way to do this, but it’s a start.
Also, in GTM’s Variables section, there are many video variables (duration, title, length, percent, provider) that I have not figured out how to use … yet. I have them activated. The data is not being recorded. Those may hold a better solution.
I hope this helps someone.
That’s a great solution. I will play with it this week.
Thanks so much.
I have learned a lot about Google Tag Manager since I posted my original question. The big challenge with this plugin will be that clicks on an iframe are not transmitted to GTM automatically. No click is recorded in the GTM dashboard.
One solution for those with access to the iframe code itself is to install separate GTM snippets into the iframe and have those send info to the page where the iframe is embedded. I’m still fumbling around trying to figure out how to do that, even if not the proper way to start with.
If I paste the GTM snippets into the player-iframe.php head and body, they don’t show up in the source code when I look at a page with the video player embedded in an iframe.
Since you said this functionality was on your to do list, I thought sharing this iframe issue would save you some time as you got started.
Thank you for your quick reply.
I am thrilled to hear this is on your to do list.
And thank you for the code.
If I get something working, I’ll let you know.
Forum: Plugins
In reply to: [All-in-One Video Gallery] Replace spinning play button with static buttonAs always, thank you for the excellent help. That worked perfectly.
The website with the Foo Gallery plugin is indeed set to https in the general settings. I will go ahead and use your solution now.
I noticed the style sheet problem with the tablesorter plugin on the other site when I switched the WordPress general settings from http to https.
The table is on the home page, and the tablesorter functionality broke immediately when I made the switch.
I googled for hours trying to find someone else who had that issue and didn’t come up with anything. And I didn’t see any issues with my enqueue method.
I should have realized I was looking at the same issue on both sites.
Thanks so much for your help.
I decided to contact my host, Hostmonster, before responding to you.
I haven’t used your plugin fix yet because I realized that you solved a problem for me on another of my sites where the tablesorter plugin wasn’t loading when I switched the site to https.
I wanted Hostmonster to see the problem.
The Hostmonster tech person I chatted with said to do the following, which he did on his end, and he said the style sheet was loading https afterward, similar to the other style sheets. I should have double-checked before I let him go, because that’s not what I’m seeing. But here was his suggestion:
Just need to update the http redirect code to .htaccess file
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]]Is that was your plugin does to force https? I’d like to understand the actual fix since I know Hostmonster has the potential to create this problem on all my sites.
I apologize for asking you another question after you actually solved your plugin’s issue.
Thanks.
Forum: Plugins
In reply to: [404 Notify] No link to page in notification emailNo need to apologize.
I have continued to test the plugin and haven’t been sure what update to provide here.
I removed the redirects that I thought were redundant. I also uninstalled the plugin and then reinstalled it after those redirects were removed. I’m still not getting working links in the notification.
I feel like I have done something with the redirects that is tripping up your plugin, but I may not be able to figure out the problem. I don’t want to remove them all, though that would be a good way to see if that solves the problem. There are hundreds of redirects now.
We know the plugin worked when I installed it.
I think we should let it go.
I really appreciate your help in describing how the plugin works so I could try to walk through the issue.
Thank you.
Forum: Plugins
In reply to: [404 Notify] No link to page in notification emailIt looks like I installed the plugin sometime before July 12, and the link in the first notification that I received on July 12 worked. Nothing worked after that. That’s about the time I started trying to fix links not working.
I’ll just run through what I did, and you might be able to see how I tripped up the plugin.
I originally built the site years ago as HTML with no SSL certificate. There was a second domain name pointed at the site through my host. Still is. I paid no attention to the site.
I rebuilt the site this year as a WordPress site and changed it to https://
I did a lot of Googling to see what pages were ranking and was surprised to see the old parked domain URLs were showing up everywhere, but not the old real domain URLs. Still not sure why. And all the old parked URLs without the https in search pages were throwing 404 errors.
I installed your plugin and the SEO Redirection plugin and over many days redirected old URLs with the real domain to changed URLs on the new site. And then I redirected all the old URLs from the parked domain to the new site, though that felt like overkill, but it made the links work in search pages.
I’ll give examples.
Real domain: http://mysite.com
Parked domain: http://mysitetoo.comEvery URL with http://mysite.com/something was redirected to https://mysite.com/replacementpage.
And every URL with http://mysitetoo.com/something was redirected to https://mysite.com/replacementpage.
Upon investigation just now, I’m seeing that I redirected http://mysitetoo.com to https://mysite.com.
My question to you is: If I redirected the parked site to the new site through the SEO Redirection plugin and the host also is forwarding the parked domain to the new domain, have I accomplished what you just described I might have done?
I should remove the redirected entry for http://mysitetoo.com. I didn’t give it a thought when I did it, but it does seem like a poor choice due to the redundancy.
I really appreciate you investigating this. Hopefully, my error will save others from creating the same issue.
Forum: Plugins
In reply to: [All-in-One Video Gallery] Is it possible to prevent archive page?I think I solved it and saved you the trouble of looking.
After you replied to me originally, I pasted your code into a TextEdit document open on my MacBook before I put it into the functions.php file using TextWrangler. Apple says on its website that TextEdit can be used to edit HTML. But maybe not. I’m on an older MacBook.
The code seems to have picked up a hidden character or something.
Tonight, I was going to video me putting your code into the functions.php before I submitted the ticket.
I used the code from my TextEdit document and got the error again. Then I thought I’d better take the code directly from your reply and paste it into the function.php file on the chance that I missed a semicolon or something. That code worked fine.
I compared the two sets of code, and they are identical, at least the characters that I can see.
I repeated using the TextEdit code and got the error again.
My methods are flawed, but your code is fine. My apologies for raising any concerns.
Thank you.
Forum: Plugins
In reply to: [All-in-One Video Gallery] Is it possible to prevent archive page?Well, it seems like a good solution on paper.
But I’m getting an error on the site when I put the code in the functions file, and I don’t see the problem. If I remove the code, the issue goes away.
The error is: Parse error: syntax error, unexpected ‘ ‘ (T_STRING)
It is occurring on this line, according to the error message:
if ( is_archive() && is_post_type_archive( ‘aiovg_videos’ ) ) {
I have retyped the line by hand. Replaced the single quote marks by hand to ensure they are not the curly type. Removed the is_archive part, the ampersands and extra parenthesis mark and tried to use just the is_post_type_archive part. Removed the “to do” action and just left those lines blank. Compared your code with other solutions using is_post_type_archive().
I can’t figure out what is causing the error.
But thank you for getting back to me so quickly. I know the direction I need to go now.