Cara Memasang Iklan di Template Superfast Wallpaper Versi Mas Pingi

Cara Memasang Iklan di Template Superfast Wallpaper Versi Mas Pingi

1. Menghapus fisrt image di halaman single plus menambahkan adsense dibawah title.

Masuk ke Appearance > Theme Editor > template-parts > content-single.php

atau langsung menuju halaman ini: https://namadomain/wp-admin/theme-editor.php?file=template-parts%2Fcontent-single.php&theme=superfast

lalu langsung ganti kodenya menjadi berikut ini:

<?php
/**
 * Template part for displaying posts.
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package Superfast
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

// Disable thumbnail options via customizer
$thumbnail = get_theme_mod( 'gmr_active-singlethumb', 0 );
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php echo superfast_itemtype_schema( 'CreativeWork' ); ?>>
<div class="gmr-box-content gmr-single">

<header class="entry-header">
<?php the_title( '<h1 class="entry-title" ' . superfast_itemprop_schema( 'headline' ) . '>', '</h1>' ); ?>
<?php gmr_posted_on(); ?>
</header><!-- .entry-header -->
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- responsif -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-xx"
     data-ad-slot="xx"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<div class="entry-content entry-content-single" <?php echo superfast_itemprop_schema( 'text' ); ?>>
<?php
the_content();
?>
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php gmr_entry_footer(); ?>
<?php the_post_navigation(array(
'prev_text'                  => __( '<span>Previous post</span> %title', 'superfast' ),
'next_text'                  => __( '<span>Next post</span> %title', 'superfast' )
) ); ?>
</footer><!-- .entry-footer -->
</div><!-- .gmr-box-content -->
<?php do_action( 'idblog_core_author_box' ); ?>
</article><!-- #post-## -->

 Ganti kode xxx menjadi kode adsense pribadi!

2. Memasang kode iklan adsense dibawah postingan.

Masuk ke Theme editor, pilih Superfast Gallery Child > Theme Functions. Lalu ganti selulruh kodenya menjadi kode berikut ini:

<?php
/**
 * Superfast Gallery Child functions and definitions.
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Superfast Gallery Child
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/*
* Gallery post type
*/
if ( !function_exists('superfast_child_get_attachment_gallery') ) :
function superfast_child_get_attachment_gallery() {
global $post;
$title = get_the_title();
if( is_attachment() ) :
$args = array(
'orderby'           => 'date',
'post_type'         => 'attachment',
'post_status'    => 'inherit',
'post_parent' => $post->post_parent,
'posts_per_page'    => -1,
'exclude' => get_post_thumbnail_id()
);
else :
$args = array(
'orderby'           => 'date',
'post_type'         => 'attachment',
'post_status'    => 'inherit',
'post_parent' => $post->ID,
'posts_per_page'    => -1,
'exclude' => get_post_thumbnail_id()
);
endif;
$content = '';
$content .= '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- responsif untuk -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-xxx"
     data-ad-slot="xxx"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>';
$images = get_posts( $args );
if ( $images ) {
$content .= '<h3 class="widget-title">' . __('Gallery of ','superfast') . ' ' . $title . '</h3>';
$content .= '<div class="superfast-child-gallery"><ul>';
foreach ( $images as $attach ) {
$attachment_id = $attach->ID;
$img_url = wp_get_attachment_image_src( $attachment_id, 'medium' );
$image = $img_url[0];
$desc_img = get_the_title( $attachment_id );
$attachment_url = get_attachment_link( $attachment_id );
$content .= '<li>';
$content .= '<a href="' . $attachment_url . '" title="' . __('Image for ','superfast') . ' ' . $desc_img . '"><img src="'.$image.'" height="140" width="200" alt="' . $desc_img . '" title="' . $desc_img . '" /></a>';
$content .= '</li>';
}
$content .= '<ul></div>';
}
return $content;
}
endif;
if ( !function_exists( 'superfast_child_display_attachment_gallery' ) ) :
/**
* Insert content after the_content
*
* @since 1.0.0
* @return string
*/
function superfast_child_display_attachment_gallery( $content ) {
if( ( is_single() || is_attachment() ) && in_the_loop() ) {
$content = $content . superfast_child_get_attachment_gallery();
}
return $content;
}
endif; // endif superfast_child_display_attachment_gallery
add_filter( 'the_content', 'superfast_child_display_attachment_gallery', 1 );

Ganti xxx menjadi kode iklan pribadi.

3. Menaruh 2 gambar dan 2 iklan di halaman postingan/single post.

Masuk ke Customize > Semi Wallpaper > Single Post Page. Lalu setting seperti ini:

1st image = Top Content
2nd Image = After 3rd Paragraph

1st Adsense = taruh iklan responsif
2nd Adsense - taruh iklan responsif

Masih di menu Semi Wallpaper. Sekarang masuk ke bagian Image Attachment page > Adsense Before Image. Lalu masukkan kode iklan adsense.

4. Memasang iklan Related Post atau dibawah postingan persis

Masuk ke Theme Superfast Gallery Child > Theme Functions
atau langsung masuk ke url berikut ini: https://namadomain/wp-admin/theme-editor.php?file=functions.php&theme=superfast-gallery

Lalu hapus dan copas saja kode berikut ini:

<?php
/**
 * Superfast Gallery Child functions and definitions.
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Superfast Gallery Child
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/*
* Gallery post type
*/
if ( !function_exists('superfast_child_get_attachment_gallery') ) :
function superfast_child_get_attachment_gallery() {
global $post;
$title = get_the_title();
if( is_attachment() ) :
$args = array(
'orderby'           => 'date',
'post_type'         => 'attachment',
'post_status'    => 'inherit',
'post_parent' => $post->post_parent,
'posts_per_page'    => -1,
'exclude' => get_post_thumbnail_id()
);

else :
$args = array(
'orderby'           => 'date',
'post_type'         => 'attachment',
'post_status'    => 'inherit',
'post_parent' => $post->ID,
'posts_per_page'    => -1,
'exclude' => get_post_thumbnail_id()
);
endif;

$content = '';
$content .= '
<a class="cat-links">Related Posts<a>
<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- responsive -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-xxx"
     data-ad-slot="xxx"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>
';

$images = get_posts( $args );
if ( $images ) {
$content .= '<h3 class="widget-title">' . __('Gallery of ','superfast') . ' ' . $title . '</h3>';
$content .= '<div class="superfast-child-gallery"><ul>';
foreach ( $images as $attach ) {
$attachment_id = $attach->ID;
$img_url = wp_get_attachment_image_src( $attachment_id, 'medium' );
$image = $img_url[0];
$desc_img = get_the_title( $attachment_id );
$attachment_url = get_attachment_link( $attachment_id );
$content .= '<li>';
$content .= '<a href="' . $attachment_url . '" title="' . __('Image for ','superfast') . ' ' . $desc_img . '"><img src="'.$image.'" height="140" width="200" alt="' . $desc_img . '" title="' . $desc_img . '" /></a>';
$content .= '</li>';
}
$content .= '<ul></div>';
}
return $content;
}
endif;

if ( !function_exists( 'superfast_child_display_attachment_gallery' ) ) :
/**
* Insert content after the_content
*
* @since 1.0.0
* @return string
*/
function superfast_child_display_attachment_gallery( $content ) {
if( ( is_single() || is_attachment() ) && in_the_loop() ) {
$content = $content . superfast_child_get_attachment_gallery();
}
return $content;
}
endif; // endif superfast_child_display_attachment_gallery
add_filter( 'the_content', 'superfast_child_display_attachment_gallery', 1 );

SELESAI

0 Response to "Cara Memasang Iklan di Template Superfast Wallpaper Versi Mas Pingi"

Posting Komentar