• Resolved nicktechtt

    (@nicktechtt)


    Man this is the best plugin for my blog, but I have one question. Is there any way that you can embed your plugin directly into a post via HTML code? You see when I share my blog posts to social sites, or when my site gets crawled all that appears is a short code and that’s no good, and its also bad for SEO because I don’t get the mix content or extra SEO ranking because of the embedded video as when I use YouTube’s embed code. Another good idea would be to start off with a shortcode but once post is created it leaves an embedded or iframe code This will be super.

    https://www.ads-software.com/plugins/related-youtube-videos/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Chris

    (@zenation)

    I don’t think that’s possible at this point – though I’m always open to suggestions.

    The misery starts with WordPress using square brackets for the shortcode and not some variation of the HTML commenting tag, e.g. <!--[shortcode]--> The big advantage here would be that if a shortcode cannot be handled (maybe because a plugin has been uninstalled) this HTML code would not be rendered the browser.

    If you would turn the shortcode into “hard” (static) HTML you would run into broken content pretty fast since you rely on external YouTube sources to exist forever (or any given time).

    You <i>could</i> turn the shortcode into more dynamic Javascipt. But JS wouldn’t help in terms of SEO, I guess. I even didn’t know that videos are taken into account, to be honest.

    Do you have working examples of other shortcode plugins that can do what you’re looking for?

    Thread Starter nicktechtt

    (@nicktechtt)

    Ok my request is based around auto blogging and content curation one plugin in particular is wprobot, where in the backend you in put some codes like this {URL} {video} and it creates post from external sources similar to your plugin. their video related content is usually off and pulls unrelated content, however they allow you to input other external codes, as is or via Html, this is where your plugin comes in, it works great but when you look at the final post in plain text you see a shortcode and not a youtube url or iframe or object code

    I hope I make sense?

    Plugin Author Chris

    (@zenation)

    You might add this function (at your own risk) to your theme’s function.php
    But you should definitely test this on a different environment, not your live server, to make sure this is what you want.

    This will always(^^) replace the RYTV shortcode before saving a post, respectively it’s been created. So you cannot change the shortcode parameters any more since there’s only the HTML code left.

    function do_rytv_shortcode_before_creating_post( $data, $postarr ) {
    
    	if( isset( $data['post_content'] ) ) {
    
        // This is based WP's do_shortcode() function code
        $pattern                = '\[(\[?)(relatedYouTubeVideos|RelatedYouTubeVideos|relatedyoutubevideos)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
    
        $newContent             = preg_replace_callback( "/$pattern/s", 'do_shortcode_tag', stripslashes( $data['post_content'] ) );
    
        $newContent             = addslashes( $newContent );
    
        if( $newContent !== $data['post_content'] ) {
    
          $data['post_content'] = $newContent;
    
        }
    
      }
    
      return $data;
    
    }
    add_filter( 'wp_insert_post_data' , 'do_rytv_shortcode_before_creating_post', 100 );  // has to come AFTER "WP Robots"! If 100 is not try an even higher number.
    Thread Starter nicktechtt

    (@nicktechtt)

    will test it and let you know

    Thread Starter nicktechtt

    (@nicktechtt)

    Like you said I did a test on a practice site and what happened is when I placed the code in the functions.php file the site crashed only displaying a white blank page.

    Maybe I am doing it wrong?

    Thread Starter nicktechtt

    (@nicktechtt)

    // has to come AFTER “WP Robots”! If 100 is not try an

    even higher number.

    I do not understand what that means.

    Plugin Author Chris

    (@zenation)

    The white blank page I cannot explain (from here) since the code itself should technically be fine. It’s just that I wouldn’t feel to o comfortable making “hard conversion” before saving/creating a post.

    > 100 or higher
    The function will be called right before WP is saving or inserting a post. But WP Robots will also be called then and convert its own shortcodes like {URL} and {video} and so on. The number is like priorizing what function to call before the other.

    I’m not sure if this is because of the formatting of your post on this board but maybe the white page is caused by the code comment moved to the next line. Try without it so the last line would just be
    add_filter( 'wp_insert_post_data' , 'do_rytv_shortcode_before_creating_post', 100 );

    If that’s still not working I’m afraid I can’t help you any further.

    Thread Starter nicktechtt

    (@nicktechtt)

    Good news and bad news, well i got the code to work well with the output being an Youtube object embed, but it is showing a default video on all posts https://www.youtube.com/embed/1lyu1KKwC74 “Bitter Sweet Symphony” is the name of the video on all pages.

    You’re so close

    Thread Starter nicktechtt

    (@nicktechtt)

    Hey Chris is it possible that the custom function that you gave me to output the video as an embed code, can you make it output just the plain simple URL of the video instead of the object code?

    Thread Starter nicktechtt

    (@nicktechtt)

    Never mind that request I figured it out

    nicktechtt how did you make it output the plain simple url?

    Thread Starter nicktechtt

    (@nicktechtt)

    I used to tweak the API but this method stopped working after a plugin updated when I retried it in the new version it crashes my site.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Related Videos and SEO’ is closed to new replies.