Guest User

Untitled

a guest
Oct 9th, 2023
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.23 KB | None | 0 0
  1. <?php
  2.  
  3. // Get the current page URL
  4. $current_url = home_url( $_SERVER['REQUEST_URI'] );
  5.  
  6. // Define the FAQ page URL
  7. $course_archive_url = 'https://example.com/courses';
  8.  
  9. // Check if the current page is the Courses page
  10. if ( $current_url == $$course_archive_url ) {
  11.  
  12.     add_filter( 'rank_math/frontend/robots', function( $robots ) {
  13.  
  14.         // Change the robots tag to index
  15.         $robots['index'] = 'index';
  16.        
  17.         // Return the modified robots array
  18.         return $robots;
  19.     });
  20.  
  21.     /**
  22.      * Filter to change the page title.
  23.      *
  24.      * @param string $title
  25.      */
  26.     add_filter( 'rank_math/frontend/title', function( $title ) {
  27.  
  28.         $title = "Courses Archive – Example";
  29.  
  30.         return $title;
  31.     });
  32.  
  33.     /**
  34.      * Allow changing the meta description sentence from within the theme.
  35.      *
  36.      * @param string $description The description sentence.
  37.      */
  38.     add_filter( 'rank_math/frontend/description', function( $description ) {
  39.  
  40.         $description = "Description here yo!";
  41.  
  42.         return $description;
  43.     });
  44.  
  45.     /**
  46.      * Add <meta name="keywords" content="focus keywords">.
  47.      */
  48.     add_filter( 'rank_math/frontend/show_keywords', '__return_true');
  49.  
  50.     /**
  51.      * Allow changing the meta keywords from the default Focus Keywords.
  52.      *
  53.      * @param string $keywords Keywords.
  54.      */
  55.     add_filter( 'rank_math/frontend/keywords', function( $keywords ) {
  56.  
  57.         $keywords = "Courses, Masterclasses, Guitar";
  58.  
  59.         return $keywords;
  60.     });
  61.  
  62.     /**
  63.      * Allows developers to change the OpenGraph image within theme.
  64.      *
  65.      * The dynamic part of the hook name. $network, is the network slug. Can be facebook or twitter.
  66.      *
  67.      * @param string $attachment_url The image we are about to add.
  68.      */
  69.     add_filter( "rank_math/opengraph/facebook/image", function( $attachment_url ) {
  70.         $attachment_url = "https://example.com/media/general/branding/courses-banner.jpg";
  71.         return $attachment_url;
  72.     });
  73.     add_filter( "rank_math/opengraph/twitter/image", function( $attachment_url ) {
  74.         $attachment_url = "https://example.com/media/general/branding/courses-banner.jpg";
  75.         return $attachment_url;
  76.     });
  77.  
  78.  
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment