How can I override the exisiting Schema.org markup from Yoast using GTM? - wordpress

I've configured my GTM with the JSON-LD markup I placed in GTM and its firing perfectly. However, if I will check it in structured data testing tool still the auto-generated markup by Yoast is showing.
Can I just remove or disable the Yoast schema? Will it not be harmful in terms of SEO?

To answer the first question, you can remove all the Yoast schema by adding the following to your functions.php (should be in your child theme):
function bybe_remove_yoast_json($data){
$data = array();
return $data;
}
add_filter('wpseo_json_ld_output', 'bybe_remove_yoast_json', 10, 1);
Tested working and per: https://www.bybe.net/yoast-seo-guide-disable-schema-json-ld-wordpress/

There's no harm in what Yoast is adding. You could leave it there. Or you could devise some JavaScript to find the script tag and remove it.

Related

More Than One OG URL Specified and only Yoast graph is open not Jetpack

I'm having some problem with the od: tags which is the most common issue.
Only Yoast is active for open graphs not Jackpack publicize and then how the og: tags are showing in the header of the page as shown above in the image.
would be grateful if anyone can help
There can be two possibilities:
The other og tag is printed in theme's header.php. If it's there then comment that code and you're good to go.
The OG tag is being generated by some function hooked to wp_head hook. Now it can be anywhere, in any file in plugin or theme. The best approach would be to check all the hooked functions for wp_head hook. You can do so by this code:
add_action("wp", function(){ print_r($GLOBALS['wp_filter']); echo '';exit; } );
Write this code in functions.php of your theme and look for all the functions which are hooked with wp_head hook. You can then comment the code in that particular function.
It is possible that your template adds the additional og:url header (from your page source it appears so). You need to disable the additional headers using either a switch in template settings or by manual edit.

Full Screen iframe in Wordpress

I am working SEO on wordpress, my goal is to rent out a page by using iframe to put my clients webpage all over mine, but in wordpress if I use iframe the toolbar and widgets remain there. Is there way of hiding everything and just leaving another web page on top of mine? Thank you for your time.
Please note that using an iframe might not contribute much in terms of SEO. Have a read through this article. What might be relevant:
iFrames are merely referencing the content, instead of duplicating it. When robots crawl the site and register the iframe tag, they will attribute the original source with any SEO credit instead of the page using the embedded content – i.e. the page with the iFrame.
That said:
To hide the admin toolbar, either disable it in your profile, via /wp-admin/profile.php. Or do this programmatically (in functions.php) with something like:
if (!is_admin) {
add_filter('show_admin_bar', '__return_false');
}
To remove widgets, try following the tutorial on justintadlock.com, in functions.php add something like:
add_filter( 'sidebars_widgets', 'disable_all_widgets' );
function disable_all_widgets( $sidebars_widgets ) {
$sidebars_widgets = array( false );
return $sidebars_widgets;
}

Can I remove the JSON-LD schema that Yoast adds to my WordPress site?

I would like to remove the JSON-LD schema that Yoast applies to my WordPress site so that I can add my own. I have already added my own, and Google Structured Data Testing says that it is OK, but basically I have 3 separate JSON-LD schemas instead of two because of Yoast.
You can see what I mean here: https://search.google.com/structured-data/testing-tool/u/0/#url=http%3A%2F%2Fwww.yogabearpc.com
Yoast has added the WebSite schema and it seems unnecessary or even damaging?
I wanted to disable this because of the sitelinks searchbox and the fact that I don't have a search function that works globally, just on the blog. Having the search box enabled for me would have undesirable effects.
The easier option may just be to prevent Google using the sitelinks searchbox without having to touch the functions files. You can prevent Google using sitelinks searchbox on your site by using the following meta:
<meta name="google" content="nositelinkssearchbox" />
If you want to disable Yoast's JSON-LD all together then here's a snippet from my blog and the code I use on my site:
SOURCE
How to disable Yoast SEO Schema JSON-LD completely
function bybe_remove_yoast_json($data){
$data = array();
return $data;
}
add_filter('wpseo_json_ld_output', 'bybe_remove_yoast_json', 10, 1);
Login to your WordPress dashboard and head over to the editor
within the tab menu appearance, find your functions file (normally
named functions.php) and add the code below just before the PHP tag is
closed at the bottom.
Simplest way to completely disable the Yoast SEO schema JSON-LD
Add this line to functions.php file:
add_filter( 'wpseo_json_ld_output', '__return_empty_array' );
Source
If you want to disable just Organization or just Website, add this to your theme's functions.php file:
function bybe_remove_yoast_json($data){
if ( (isset($data['#type'])) && ($data['#type'] == 'Organization') ) {
$data = array();
}
return $data;
}
add_filter('wpseo_json_ld_output', 'bybe_remove_yoast_json', 10, 1);
Unless the data Yoast produces is wrong, there is no harm in having it. Quite the contrary, having more structured data is better than having less.
If having it is "unnecessary" depends on your definition of what is necessary. Some consumers might be interested in it, others not.
My guess is that Yoast adds a WebSite entity because of Google’s sitelinks searchbox rich snippet result, which allows Google users to search your site directly from the Google search result.

How to use ajax pagination in wordpress

I have created custom post type 'portfolio' in my wordpress application.
I am using wp-pagenavi plugin for pagination of custom posts.Can anyone guide me how will I implement ajax pagination i.e load newer posts without reloading the whole page. Any help will be greatly appreciated...
/*******ajax pagination*******/
jQuery(document).on('click', '#pagination a', function(e){
e.preventDefault();
var link = jQuery(this).attr('href');
jQuery('#content').html('Loading...'); //the 'main' div is inside the 'content' div
jQuery('#content').load(link+' #main');
});
the .live() function has been depreciated so use .on() instead.
obviously the jQuery library is needed too.
Here's a couple of options you can try:
AJAXify WordPress Tutorial
AJAXify WordPress Plugin
I've used the first option, its a good tutorial. I know it works. You may need to modify it some though. I cannot vouch for the second option as I've never used it. Just a quick Google search turned it up though.

Wordpress wp_insert_post function

I am writing a php program to insert a wordpress post using wordpress functions. When I use the function wp_insert_post(), any <script> tags in my post content are removed. Is there is a way to override this in Wordpress?
The solution by pp19dd doesn't work anymore in newer versions of WordPress. The new way, as suggested by a WordPress developer (but not recommended, because of security issues):
filter had to be unset due to security problems with it. You could try doing kses_remove_filters() before inserting the post and kses_init_filters() after inserting the post if you are trying to avoid the kses filtering of the post fields. Just be wary since that defeats most of the security measures for inserting posts.
So:
kses_remove_filters();
wp_insert_post( $postdata );
kses_init_filters();
Source: https://wordpress.org/support/topic/bypass-sanitize_post-from-wp_insert_post

Resources