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

    (@zenation)

    Hi,
    you could use a workaround:

    [relatedYouTubeVideos relation=”keywords” terms=”myFirstKeyword” filter=”+postTitle anotherKeyWordOrTheSameAgain”]

    Thread Starter Neo1337

    (@eminecraft)

    Hi Chris,

    I use in theme, so I try like:


    'relation' => 'keywords',
    'terms' => 'keyword1',
    'filter' => '+postTitle keyword2 keyword3',
    'max' => '1',
    'width' => '250',
    'height' => '150',
    'lang' => 'en',
    'class' => 'left horizontal bg-black center',
    'preview' => false,
    'exact' => true,
    'viewRelated' => false

    But seem to not works, I get one video for all articles (different title for each article).

    I get better result with:


    'relation' => 'postTitle',
    'filter' => 'keyword1 keyword2 keyword3',

    And If I can do something like as:


    'relation' => 'postTitle keyword1',
    'filter' => 'keyword2 keyword3',

    I can get much better results. I don’t thing postTitle work in a filter.

    Regards,
    Alex

    Plugin Author Chris

    (@zenation)

    Mhhh. Works for me?! My first guess is that you should try ‘extact’ => false. That might be too restrictive. If this still fails you can do a little test.

    Assuming you have something like this

    /* Do your configuration */
    $data = $RytvAPI->validateConfiguration(
      array(
        'relation'    => 'keywords',
        'terms'       => 'keyword1',
        'filter'      => '+postTitle keyword2 keyword3',
        'max'         => '1',
        'width'       => '250',
        'height'      => '150',
        'lang'        => 'en',
        'class'       => 'left horizontal bg-black center',
        'preview'     => false,
        'exact'       => true,
        'viewRelated' => false
      )
    );

    add the line

    var_dump( $data );exit;die();

    Then take a quick look a the result: There will be something like ‘search’ => string ‘keyword1 YourPostTitle keyword2 keyword3’ in the output. Copy that value, search for that (wrapped in double quotes if you want exact/true matches) on Youtube.com and compare your results.
    And don’t forget to delete that code line again since you don’t want your site visitors to see this ??

    • This reply was modified 7 years, 4 months ago by Chris.
    Thread Starter Neo1337

    (@eminecraft)

    Seem to work much better with the exact filter off.

    Also, it any way to make video responsible? or to use like as?


    'width' => '100%',
    'height' => '100%',

    Regards,
    Alex

    Plugin Author Chris

    (@zenation)

    Hi Alex,
    the width and height parameters only take postive integer numbers.

    I think the best thing would be to add your own css class (‘class’ => ‘newClassname’) and do the responsive adjustments based on that.

    Regards,
    Chris

    • This reply was modified 7 years, 4 months ago by Chris.
    • This reply was modified 7 years, 4 months ago by Chris.
    harry murtie

    (@masterseoonline)

    thanks for your great plugin,
    just want to make sure two things, because this plugin is very amazing

    1. I want to filter / remove some unnecessary (even vulgar) keywords from my post title, for example:
    my post title: how to block porn sites and nude from kids – please read
    I want to remove the keyword “porn and nude” using:
    filter = "-intitle: porn -intitle: nude"
    thus becoming:
    “how to block sites and from kids”
    is it correct? or can i use:
    filter = "-postTitle nude porn"
    then what’s the difference?

    2. after learning from some of the problems that I experienced, and some other users like here may be:
    https://www.ads-software.com/support/topic/my-ryv-is-not-working-i-dont-know-why/
    https://www.ads-software.com/support/topic/php-7-compatibility-141/

    the problem is not really on this “nice plugin”.
    but on internal google spam filter
    first if traffic is high and post too much (up to hundreds of thousands)
    so the use of cache will be rare,
    and this will make “query request error” in google console.

    maybe the solution is:
    -how to use multiple youtube api / custom youtube api on post type, If i want to hard-code the related videos in my theme or custom post type?
    (so query requests can be split on some youtube api based on post type or page or other)

    so where can i add a second apikey code?

    <?php
    /* Load the "Related YouTube Videos" API class if it does not exist yet. */
    if( !class_exists( 'RelatedYouTubeVideos_API' ) ) {
    
      $file = str_replace( '/', DIRECTORY_SEPARATOR, ABSPATH ) . 'lib' . DIRECTORY_SEPARATOR . 'RelatedYouTubeVidoes' . DIRECTORY_SEPARATOR . 'API.php';
    
      if( file_exists( $file ) ) {
        
        include_once $file;
        
      }
    
    }
    /* Only continue if the API class could be loaded properly. */
    if( class_exists( 'RelatedYouTubeVideos_API' ) ) {
    
      $RytvAPI  = new RelatedYouTubeVideos_API();
      
      /* Do your configuration */
      $data     = $RytvAPI->validateConfiguration(
        array(
         'relation' => 'postTitle',
         'max'      => '3',
         'width'    => 150,
         'height'   => 150,
         'lang'     => 'en',
         'region'   => 'de',
         'class'    => 'left center inline bg-black',
         'preview'  => true
        )
      );
    
      /* Search YouTube. */
      $results  = $RytvAPI->searchYouTube( $data );
    
      /* Generate the unordered HTML list of videos according to the YouTube results and your configuration.  */
      $html     = $RytvAPI->displayResults( $results, $data );
      
      echo $html; // Or do with it whatever you like ;)
    
    }
    ?>

    -or may be able to add a proxy to request a query

    last but not least, thanks for your amazing plugin

    • This reply was modified 7 years, 4 months ago by harry murtie.
    • This reply was modified 7 years, 4 months ago by harry murtie.
    Plugin Author Chris

    (@zenation)

    Hi and thanks for the feedback.

    1) This is not how the filtering works.
    2) Neither the filtering you’re looking for, nor use of mutiple API keys work out of the box with this plugin.

    At least the filtering is an interestin feature and I made a note to implement proper filtering via WP’s add_filter function in a future version.

    That said, for both your use cases, you can be done by implementing your own wrapper class in PHP that lets you do all of that. For example:

    <?php
    // The original class is still required since the new wrapper class will extend its functionality from it.
    if( !class_exists( 'RelatedYouTubeVideos_API' ) ) {
    
      $file = str_replace( '/', DIRECTORY_SEPARATOR, ABSPATH ) . 'lib' . DIRECTORY_SEPARATOR . 'RelatedYouTubeVidoes' . DIRECTORY_SEPARATOR . 'API.php';
    
      if( file_exists( $file ) ) {
        
        include_once $file;
        
      }
    
    }
    
    if( class_exists( 'RelatedYouTubeVideos_API' ) ) {
    
      /**
       * This is a NEW, CUSTOM API WRAPPER CLASS
       */
      if( !class_exists( 'Custom_RYTV_API' ) ) {
    
        class Custom_RYTV_API extends RelatedYouTubeVideos_API {
    
          public function __construct( $argDevKey, $argCachetime = 24 ) {
        
            parent::__construct();
      
            $this->apiKey               = trim( strip_tags( $argDevKey ) );
    
            $this->options['devKey']    = $this->apiKey;
            $this->options['cachetime'] = (int) $argCachetime;
      
          }
      
          public function validateConfiguration( $argConfig, $argQueryReplacements = array() ) {
        
            $data               = parent::validateConfiguration( $argConfig );
        
            $queryReplacements  = (array) $argQueryReplacements;
        
            foreach( $queryReplacements as $needle => $replacement ) {
          
              $data['search']     = str_ireplace( $needle, $replacement, $data['search'] );
          
            }
        
            return $data;
        
          }
        }
    
      }
      
      $newApiKey = 'whateveritis';
    
      // You should now be able to manually set an API key.
      /// For each API key, you have to instanciate a "new Custom_RYTV_API" object
      $CustomRYTVApi = new Custom_RYTV_API( $newApiKey, $customCacheTime = 24 );
    
      // Your list of (non-casesensitive) terms that shall be replaced with whatever you like
      $rytv_queryFilter = array(
        'porn'  => '',
        'nude'  => ''
      );
    
      $data     = $CustomRYTVApi_1->validateConfiguration(
        array(
         'relation' => 'postTitle',
         'max'      => '3',
         'width'    => 150,
         'height'   => 150,
         'lang'     => 'en',
         'region'   => 'de',
         'class'    => 'left center inline bg-black',
         'preview'  => true
        ),
        // Pass along your filter list
        $rytv_queryFilter
      );
      
      $results  = $CustomRYTVApi->searchYouTube( $data );
    
      $html     = $CustomRYTVApi->displayResults( $results, $data );
      
      echo $html; // Or do with it whatever you like ;)
    
    }
    • This reply was modified 7 years, 4 months ago by Chris.
    harry murtie

    (@masterseoonline)

    thanks you sir, i will try it i like this plugin.
    and yes it may need to feature globally to remove badwords / unnecessary words from post title before doing a search query.
    can not wait for the next update.

    harry murtie

    (@masterseoonline)

    it seems the code above does not work for me
    it displays the following error:

    Warning: Declaration of Custom_RYTV_API::validateConfiguration($argConfig, $argQueryReplacements = Array) should be compatible with RelatedYouTubeVideos_API::validateConfiguration($args = Array) in D:\pws\xampp\htdocs\wpmu\wp-content\themes\flatsome\template-parts\posts\single.php on line 50

    and the code on line 50 is :

    50 class Custom_RYTV_API extends RelatedYouTubeVideos_API {

    and badword filters do not seem to work either

    and actually I also want to add some changes to the plugin, like “array_rand” api key

    $random_api = array_rand ($multiapi, 1);
    $newApiKey = $multiapi [array_rand ($multiapi, 1)];

    is that possible?
    or change every 4-5hours?
    and then display the result with shortcode function

    • This reply was modified 7 years, 4 months ago by harry murtie.
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Add keywords in title’ is closed to new replies.