Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #738335

    Hi,

    I don’t want to display code in any page and other post, just i want to display in Home page.

    So i put code in “google site link search box” above the <head> tag

    <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "WebSite",
      "url": "http://career.guru99.com/",
      "potentialAction": {
        "@type": "SearchAction",
        "target": "http://career.guru99.com/search?q={search_term_string}",
        "query-input": "required name=search_term_string"
      }
    }
    </script>
    #738740

    Hey kriru,

    Ok, thanks for that. I’m not sure what problem you are having though?

    Best regards,
    Rikard

    #739697

    Hi

    I have put code in “google site link search box” above the <head> tag.

    I want to display code only single page. (Only Display Home Page)

    #741050

    Hi!

    Please use the is_page or is_front_page conditional function.

    // https://developer.wordpress.org/reference/functions/is_page/
    // https://codex.wordpress.org/Function_Reference/is_front_page\

    Or remove the code from the header.php file then add this in the functions.php file.

    add_action('wp_head', 'wp_head_mod_gs');
    function wp_head_mod_gs() { 
    	if(is_front_page()) {
    	?>
    		<script type="application/ld+json">
    		{
    		  "@context": "http://schema.org",
    		  "@type": "WebSite",
    		  "url": "http://career.guru99.com/",
    		  "potentialAction": {
    		    "@type": "SearchAction",
    		    "target": "http://career.guru99.com/search?q={search_term_string}",
    		    "query-input": "required name=search_term_string"
    		  }
    		}
    		</script>
    <?php	
    	}
    }
    

    Regards,
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.