I have a WordPress website and a registration system in it. Lets say I have the following Google Ad example:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456" crossorigin="anonymous"></script>
<!-- Homepage Leaderboard -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1234567890123456"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
How can I display the Ad only to guest users? I've been stuck with this for days. Is there a plugin? or can I edit the user roles somewhere?
<?php if( false === is_user_logged_in() ) { ?>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456" crossorigin="anonymous"></script>
<!-- Homepage Leaderboard -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1234567890123456"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<?php } // endif ?>
Related
I am a beginner with wordpress and I want to ask somebody to help me. I would like to track page 404. I have 2 analytics codes. One of them is displayed on every page. The other is for displaying only on the 404 pages. I don't know where and how to put the second analytics code which is for page 404 only. I ask for an advice :)
The code is below:
<?php if (is_404()) { ?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-X', 'auto');
ga('send', 'pageview', '/404.html?page='+document.location.pathname + document.location.search + '&from=' + document.referrer);
</script>
<?php } else { ?>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X');
</script>
<?php } ?>
Thank you in advance!
You can use the following, it will need to go inside of the <head> which will be located in the header.php file of your active theme:
<?php if(is_404()) { ?>
Paste 404 only tracking here
<?php } else { ?>
Paste normal tracking here
<?php } ?>
You'll need to add both of your tracking codes where I've labelled but that will show them on the relevant pages.
I am facing problem in Facebook sharing post. When I try to share any post link of my website Facebook black image. I have also fetch data from Facebook debugger and found this error "The 'og:image' property should be explicitly provided, even if a value can be inferred from other tags."
I am using wordpress theme with default Open Graph
<!--Facebook Open Graph-->
<?php if ( defined('WPSEO_VERSION') ) {}else{?>
<!--FB page title-->
<meta property="og:title" content="<?php if (! function_exists('bp_is_active') ) {if (is_single() || is_page()) {echo esc_attr(get_the_title());} else {bloginfo('name');}}else {if (is_single() || is_page() && !is_buddypress()) {echo esc_attr(get_the_title());} elseif(is_buddypress()){wp_title();} else {bloginfo('name');}} ?>" />
<!--FB description-->
<meta property="og:description" content="<?php if (is_single()) {echo substr(strip_tags($post->post_content), 0, 200); echo '...';} else {bloginfo('description');} ?>"/>
<!--FB url-->
<meta property="og:url" content="<?php if ( is_home() || is_front_page() ){echo esc_url(home_url('/'));} else{the_permalink();} ?>"/>
<!--FB image-->
<meta property="og:image" content="<?php if (is_single()) {$fbthumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'slider-three'); echo esc_url($fbthumb[0]);} else {echo esc_url(get_option('exm1_facebook_default'));}?>" />
<!--FB type-->
<meta property="og:type" content="<?php if (is_single()) { echo "article"; } else { echo "website";} ?>"/>
<!--FB site name-->
<meta property="og:site_name" content="<?php bloginfo('name'); ?>"/>
<?php } ?>
<?php wp_head(); ?>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.10&appId=546337812226292';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
When I debug on Facebook, Fabook debugger show me og.image url and I try to view image but it's look not found page. I am also using EWWW Image Optimizer plugin for image optimization. I don't know What i do now and why wordpress not showing image on default url. Please help me. Website: http://urdukhabrain.pk
If you are look at the source of your page, you will see that og:image tag is missing:
view-source:http://urdukhabrain.pk/
You will need to ensure that your code correctly populates the og:image tags.
Check the following doc for Using Objects.
Here are some of my experiences:
Always note that the character count of an image name may be an issue. Reduce it to a 12-character name and re-test via debug: https://developers.facebook.com/tools/debug/
Use image recommendations for Facebook: 1200 x 630
For my website I use Advance Custom Field for Wordpress and now i'd like to create a custom field for skype call.
I create a custom field text for "skype" and I add this on my single.php
<?php if ( get_post_meta( get_the_ID(), 'skype', true ) ) : ?>
<p><span class="list">
<?php _e( 'Skype: '); ?>
</span>
<?php the_field('skype'); ?>
</p><?php endif; ?>
I try to add this
<a href="skype: yourskypeid?call">
<img src="http://cdn.dev.skype.com/uri/callbutton_32px.png"
alt="Skype Me™!" style="border: none;margin: 32px; vertical-align: -41px">
</a><br />
Get Skype and call me for free.<br />
to have a skype button to call but it doesn't work.
Can you help me please?
<script type="text/javascript" src="http://www.skypeassets.com/i/scom/js/skype-uri.js"></script>
<div id="SkypeButton_Call_prince_1">
<script type="text/javascript">
Skype.ui({
"name": "call",
"element": "SkypeButton_Call_YOURSKYPENAME_1",
"participants": ["YOURSKYPENAME"],
"imageSize": 32
});
</script>
</div>
For more See here Skype Call Button
also this should work..
Call Yourskypeid
iam trying to control supersized slideshow with this code
<script type="text/javascript">
function ToggleSlideShow(){
api.playToggle();
}
</script>
</head>
<body>
//Check frontpage
<?php if (is_front_page() ) { ?>
//not frontpage
<?php } else { ?>
//call script and pause slideshow!
<script type="text/javascript">
ToggleSlideShow();
</script>
<?php } ?>
But it dosnt work, can anyone please help?
I gave up :-) instead i just loaded a different header using the if_front_page()
I help maintain a website for a church and we have just noticed that our Google results have somehow been spoofed. The result and links point to the church's website, but the text descriptions are all wrong. I have checked the actual code of the site (head is copied below) and nothing is amiss. There are no strange files on our server, nor is there anything wrong with the site itself.
My question is how is this possible and is there any way to correct it?
<?php
/**
* The Header for our theme.
*
* Displays all of the <head> section and everything up till <div id="main">
*
* #package WordPress
* #subpackage Twenty_Ten
* #since Twenty Ten 1.0
*/
global $fumco;
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php
/*
* Print the <title> tag based on what is being viewed.
*/
global $page, $paged;
wp_title( '|', true, 'right' );
// Add the blog name.
bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
echo " | $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php
/* We add some JavaScript to pages with the comment form
* to support sites with threaded comments (when in use).
*/
if ( is_singular() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
/* Always have wp_head() just before the closing </head>
* tag of your theme, or you will break many plugins, which
* generally use this hook to add elements to <head> such
* as styles, scripts, and meta tags.
*/
wp_head();
?>
<script src="<?php bloginfo('template_directory');?>/js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<!-- Slider script -->
<script src="<?php bloginfo('template_directory');?>/js/scripts.js" type="text/javascript" charset="utf-8"></script>
<!-- Home page tabs -->
<script type="text/javascript" charset="utf-8">
$(function () {
var tabContainers = $('div.tabs > div');
tabContainers.hide().filter(':first').show();
$('div.tabs ul.tabNavigation a').click(function () {
tabContainers.hide();
tabContainers.filter(this.hash).show();
$('div.tabs ul.tabNavigation a').removeClass('selected');
$(this).addClass('selected');
return false;
}).filter(':first').click();
});
</script>
<!-- Script for TypeKit font implementation -->
<script type="text/javascript" src="http://use.typekit.com/kgp1dfc.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<!-- Facebook Wall Feeds -->
<script type="text/javascript" src="<?php bloginfo('template_directory');?>/js/jquery.neosmart.fb.wall.js"></script>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory');?>/js/jquery.neosmart.fb.wall.css" media="screen">
<!-- Scripts for implementing drop down menus -->
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory');?>/css/superfish.css" media="screen">
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory');?>/css/superfish-navbar.css" media="screen">
<script type="text/javascript" src="<?php bloginfo('template_directory');?>/js/hoverIntent.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory');?>/js/superfish.js"></script>
<script type="text/javascript">
$.fn.setAllToMaxHeight = function(){
return this.height( Math.max.apply(this, $.map( this , function(e){
return $(e).height()
}) ));
}
// initialise plugins
jQuery(function(){
jQuery('ul.sf-menu').superfish();
adjustNavigation();
$('.menu-col').setAllToMaxHeight();
if ($('.accordion').length > 0) {
$('.accordion .ac-header').click(function() {
panel = $(this).parents('.ac-panel');
$('.ac-content', panel).slideToggle();
})
}
jQuery('.twitter-feeds a').attr('target', '_blank');
$("#frmsga").submit(function() {
var emailfilter=/^\w+[\+\.\w-]*#([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
$("#txtname, #txtemail").removeClass('error-input');
var is_valid = true;
if ($("#txtname").val()==""){
$("#txtname").addClass('error-input').focus();
return false;
}
if (emailfilter.test($("#txtemail").val())==false) {
$("#txtemail").addClass('error-input').focus();
return false;
}
return true;
});
});
$(window).resize(function() {
adjustNavigation();
});
function adjustNavigation() {
var padLeft = jQuery('#site-title').offset().left;
jQuery('ul.sf-menu li:eq(0)').css('margin-left',padLeft+'px');
jQuery('ul.sf-menu > li').each(function(index, value) {
jQuery('li:eq(0)', this).css({
'margin-left':padLeft+'px'
});
jQuery('li:eq(0) a', this).addClass('mnu-first');
});
}
function sga_submit() {
var emailfilter=/^\w+[\+\.\w-]*#([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
$("#txtname, #txtemail").removeClass('error-input');
var is_valid = true;
if ($("#txtname").val()==""){
$("#txtname").addClass('error-input').focus();
is_valid = false;
}
if (emailfilter.test($("#txtemail").val())==false) {
$("#txtemail").addClass('error-input').focus();
is_valid = false
}
return is_valid;
}
</script>
<style type="text/css">
.single .<?php echo $fumco->news_page_id;?> {background-position: 0 -30px;}
.single .<?php echo $fumco->news_page_id;?> a {color: #b27262;}
</style>
</head>
It's possible your site got hacked somehow. Look at the cached copy that Google has: http://webcache.googleusercontent.com/search?q=cache:S79-C5g4-2gJ:firstchurchorlando.org/+&cd=1&hl=en&ct=clnk&gl=us
Not only will you see tons of keywords and that your title tag has changed, but here is what's interesting and probably the source of the issue:
<!-- All in One SEO Pack 1.6.15.2 by Michael Torbert of Semper Fi Web Design[82,129] -->
<meta name="description" content="Duty Free Philippines Sale Items, Lucky Strike In Az # Genuine Duty Free Cigarettes Online" />
<meta name="keywords" content="Duty, Free, Philippines, Sale, Items, Lucky, Strike, In, Az, " />
Investigate the all in one SEO pack plugin, change all website passwords... that should solve your issue