Guest User

Untitled

a guest
Jan 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. <?php
  2. add_filter('wpseo_title', 'vozrastofilter_title');
  3. function vozrastofilter_title($title) {
  4. if( is_page(352) ) {
  5. $age_tag = (int)$_GET['age_tag'];
  6.  
  7. if ( $age_tag ) {
  8. $yoast_title = get_post_meta( get_the_ID(), '_yoast_wpseo_title', true );
  9.  
  10. $title_period = "";
  11. if($age_tag == 1000) $title_period = "Ребенок-школьник";
  12. if($age_tag == 11) $title_period = "11 мес.";
  13. if($age_tag == 10) $title_period = "10 мес.";
  14. if($age_tag == 9) $title_period = "9 мес.";
  15. if($age_tag == 8) $title_period = "8 мес.";
  16. if($age_tag == 7) $title_period = "7 мес.";
  17. if($age_tag == 4) $title_period = "4-6 мес.";
  18. if($age_tag == 1) $title_period = "1-3 мес.";
  19. if($age_tag == 700) $title_period = "7 лет";
  20. if($age_tag == 600) $title_period = "6 лет";
  21. if($age_tag == 500) $title_period = "5 лет";
  22. if($age_tag == 400) $title_period = "4 года";
  23. if($age_tag == 300) $title_period = "3 года";
  24. if($age_tag == 200) $title_period = "2 года";
  25. if($age_tag == 100) $title_period = "1 год";
  26.  
  27. $title = $yoast_title.' - '.$title_period;
  28. }
  29. }
  30. return $title;
  31. }
  32.  
  33. add_filter( 'wpseo_metadesc', 'vozrastofilter_description', 10, 1 );
  34. function vozrastofilter_description($description) {
  35. if( is_page(352) ) {
  36. $age_tag = (int)$_GET['age_tag'];
  37.  
  38. if ( $age_tag ) {
  39. $yoast_description = get_post_meta( get_the_ID(), '_yoast_wpseo_metadesc', true );
  40.  
  41. $title_period = "";
  42. if($age_tag == 1000) $title_period = "Ребенок-школьник";
  43. if($age_tag == 11) $title_period = "11 мес.";
  44. if($age_tag == 10) $title_period = "10 мес.";
  45. if($age_tag == 9) $title_period = "9 мес.";
  46. if($age_tag == 8) $title_period = "8 мес.";
  47. if($age_tag == 7) $title_period = "7 мес.";
  48. if($age_tag == 4) $title_period = "4-6 мес.";
  49. if($age_tag == 1) $title_period = "1-3 мес.";
  50. if($age_tag == 700) $title_period = "7 лет";
  51. if($age_tag == 600) $title_period = "6 лет";
  52. if($age_tag == 500) $title_period = "5 лет";
  53. if($age_tag == 400) $title_period = "4 года";
  54. if($age_tag == 300) $title_period = "3 года";
  55. if($age_tag == 200) $title_period = "2 года";
  56. if($age_tag == 100) $title_period = "1 год";
  57.  
  58. $description = $yoast_description.' Значение фильтра - '.$title_period;
  59. }
  60. }
  61. return $description;
  62. }
  63.  
  64. add_filter( 'wpseo_canonical', 'vozrastofilter_canonical' );
  65. function vozrastofilter_canonical($url) {
  66. if( is_page(352) ) {
  67. $age_tag = (int)$_GET['age_tag'];
  68. $yoast_canonical = get_post_meta( get_the_ID(), '_yoast_wpseo_canonical', true );
  69.  
  70. $url = get_permalink().'?age_tag='.$age_tag;
  71. }
  72.  
  73. return $url;
  74. }
  75.  
  76. add_filter( 'wpseo_next_rel_link', 'remove_rel_next_cat_mozhno' );
  77. function remove_rel_next_cat_mozhno($link) {
  78. if ( is_category(4) ) {
  79. $link = '';
  80. }
  81.  
  82. return $link;
  83. }
  84.  
  85. add_filter( 'wpseo_next_rel_link', '__return_false' );
  86. add_filter( 'wpseo_prev_rel_link', '__return_false' );
Add Comment
Please, Sign In to add comment