• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Gokul Deepak

Gokul Deepak

GoCool and Debug

  • Home
  • Terraform
  • WordPress
  • Android
  • How to
  • About Me

Wordpress

WordPress – Display Ads only on posts not on pages

June 15, 2021 by Gokul Deepak S Leave a Comment

We may want to display ads on our WordPress website. While coming for customization we would be having many troubles.

Target: To show ads only on posts and not on pages

What do we need: WordPress website, Genesis Theme, Genesis Hook plugin

Solution:

  1. Install Genesis Hook Plugin from the plugins repository
  2. Go to Genesis -> Genesis Hook from the side menu in wordpress admin console
  3. Choose the place where you are going to place the ad. Let us consider you want to display the ad below the Header. So paste the below code under Genesis_after_head section
<?php if (!is_page()) {  ?>
<!-- Your Scripts -->
</script>
<?php } ?>

For example we have pasted the google adsense code

<?php if (!is_page()) {  ?>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- GokulDeepak SideBar -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-xxxx62423435"
     data-ad-slot="25xxxxxxxxxxxx"
     data-ad-format="link"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<?php } ?>

Filed Under: Wordpress

Genesis Sample Theme Full-Width Template

July 7, 2019 by Gokul Deepak S Leave a Comment

Front-page.php

<?php
// Template Name: Full Width
add_filter( 'genesis_attr_site-inner', 'be_site_inner_attr' );
/**
 * Adds the attributes from 'entry', since this replaces the main entry.
 *
 * @author Bill Erickson
 * @link http://www.billerickson.net/full-width-landing-pages-in-genesis/
 *
 * @param array $attributes Existing attributes.
 * @return array Amended attributes.
 */
function be_site_inner_attr( $attributes ) {
    // Adds a class of 'full-width' for styling this .site-inner differently
    $attributes['class'] .= ' full-width';
    // Adds an id of 'genesis-content' for accessible skip links
    $attributes['id'] = 'genesis-content';
    // Adds the attributes from .entry, since this replaces the main entry
    $attributes = wp_parse_args( $attributes, genesis_attributes_entry( array() ) );
    return $attributes;
}
// Displays header.
get_header();
genesis_do_breadcrumbs();
// Displays content.
the_post(); // sets the 'in the loop' property to true. Needed for Beaver Builder but not Elementor.
the_content();
// Displays comments (if any are already present and if comments are enabled in Genesis settings - disabled by default for Pages.
genesis_get_comments_template();
// Displays footer.
get_footer();

Style.css

/* Full Width Page
------------------------------------------------------ */
.site-inner.full-width {
    max-width: none;
    padding: 0;
    margin: 0;
}

Filed Under: Wordpress

All pages in my website works except wp-admin

December 3, 2018 by Gokul Deepak S Leave a Comment

I’m using wordpress. One day I have encountered this problem. I can access every page in my blog except /wp-admin.

The error said that there were too many redirects and error 500.

Many searches requested me to change the configuration in wp-config and modify that as SSL redirect as true/false. But that didn’t work. Finally I found that I can access wp-admin using: https://www.example.com/wp-admin/index.php

Try this format this will work.

If you want to make https://www.example.com/wp-admin work then simply modify in .htacess or nginx.conf

 

Filed Under: Wordpress

How to block access to the wp-content uploads folder

August 28, 2017 by Gokul Deepak S Leave a Comment

By default, everyone is able to access and browse through your wp-content folder by adding ‘wp-content/uploads’ to your domain name. This means they’ll be able to see all ‘Media’ files you have uploaded to WordPress. In this post, we are going to see How to block access to the wp-content uploads folder.
In a lot of cases, you don’t want this to happen, as some files aren’t supposed to be accessible to everyone. For instance, you might have an e-book uploaded, that you only want to give away to people that subscribe to your email list.
You can block access to these folders by editing the .htaccess file. for your site. This file is located in the root directory of your WordPress website.

Mission: block access to the wp-content uploads folder
There are multiple ways to access and edit the .htaccess file. You can use Filezilla or your hosting service’s cPanel file manager.If you’re using cPanel, click ‘File Manager’, then select the site you want to do this for.

Step 1: If you’re using cPanel, click ‘File Manager’, then select the site you want to do this for.
Step 2: Make sure you have ‘Show Hidden Files (dotfiles).’ Selected! If you don’t, you won’t be able to to see your .htaccess file.
Step 3: Click ‘Go’ to go to the root directory of your site.
Step 4: In File Manager, select your .htaccess file, then right-click, and click ‘Code Edit’.
Step 5: Click ‘Edit’.
Step 6: On a blank line add the following code:
Step 7: “Options -Indexes”
Step 8: Then click ‘Save’, to save the .htaccess file.
Mission Success

As you can see, visiting any part of your WP-content directory now gives the error
403 Permission Denied
You do not have permission for this request /wp-content/uploads/
Done!

Filed Under: Wordpress

How to Display only Title in Category page Genesis

August 24, 2017 by Gokul Deepak S Leave a Comment

Here in this post, I have explained how to display only Title in Category page genesis like given below. I’m using Genesis Sample theme in explaining this method. Remeber this is the only free official theme so I have spent a minimum amount for a clean framework and customising each and every page according to my wish without paying for the child theme.

 

How to display only Title in Category page Genesis

 

In the above example, only the titles of the post are displayed. We can also customize the link color, or to display author name or not etc.

For teaching this method Sridhar Katakam is charging $50. Let me share this for free which I have learned from reading many posts.

Let us now see this step by step.

Step 1: Open Notepad and paste this code and save as category.php

<?php
/**
 * This file adds a custom archive page to any Genesis child theme.
 *
 * @author    Brad Dalton
 * @example   http://wpsites.net/web-design/how-to-show-only-titles-on-archive-pages-in-genesis/
 * @copyright 2014 WP Sites
 */

//* Remove the breadcrumb navigation
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );

//* Remove the post content
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );

//* Remove the post image
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );

//* Remove the post meta function
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );

genesis();

Step 2: Upload the file to our theme folder. For me /wp-content/themes/genesis-sample

Step 3: Add these line to style.css. You can also access style.css through Appearance-> Editor-> Stylesheet

.category .content .entry {
  margin-bottom: 0;
  padding-bottom: 0;
  padding-top: 20px;
}

.category .content .entry-title {
  font-size: 24px;
color: #000000;
background: #ffffff;
text-align: left;
text-decoration: none;
border-left: none;
border-right: none;
border-top: none;
border-bottom: none;
}
.category .content .entry-title a {
  font-size: 24px;
color: #c3251d;
background: #ffffff;
text-align: left;
text-decoration: none;
border-left: none;
border-right: none;
border-top: none;
border-bottom: none;

}

.category .content .entry-title a:hover{
text-decoration: underline;
color: #801813;
}


.category .archive-title{
display: none;
}
.category .entry-meta
{ display: none;}

You can play with this CSS by changing colors in the title of the post or remove ‘display:none’ to show entry-meta. Entry meta displays post date, author etc.

 

Hope now you know How to Display only Title in Category page Genesis

Filed Under: Wordpress Tagged With: How to, Studiopress

wp-admin redirect loop after SSL https activation

August 20, 2017 by Gokul Deepak S Leave a Comment

the website loads correctly but I can’t access wp-admin page in wordpress. This is after installing SSL certificate.

Method 1:  simply add this code in simply add this code in wp-config.php file in your root folder. you can access it through FTP. It worked like a champ for me.

/** SSL */  
define('FORCE_SSL_ADMIN', true);  
// in some setups HTTP_X_FORWARDED_PROTO might contain  
// a comma-separated list e.g. http,https  
// so check for https existence  
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)  
    $_SERVER['HTTPS']='on';

Method 2:

Add these lines in the wp-config.php file

define('WP_HOME','https://www.example.com/');
define('WP_SITEURL','https://www.example.com/');

Any one of the above two method will work. For me, the First method worked like a champ for wp-admin redirect loop after SSL https activation

Filed Under: Wordpress

  • Page 1
  • Page 2
  • Page 3
  • Go to Next Page »

Primary Sidebar

Popular Pages

  • Home
  • Important Docker Commands to remember
  • Terraform Cheat sheet
  • Learn with Gokul
  • How to remove Linux OS in Tamilnadu Government Free Laptop
  • Running crontab on AWS auto scaling group
  • CORS error in Apache Tomcat - Solved
  • Runcloud vs SiteGround Comparision
  • Strategy to prepare for Terraform Associate Exam Preparation
  • How to find the date of the Facebook group it was created

Archives

Categories

  • Android
  • Apache
  • AWS
  • Blogger
  • Computer Tips
  • DevOps
  • Docker
  • Earn
  • Facebook Tips
  • Git
  • Google Tips
  • Hosting
  • How to
  • Laptop Tips
  • Laptops
  • Linux
  • Mobile
  • MongoDB
  • Nginx
  • Node JS
  • Notepad++
  • PostgresQL
  • Terraform
  • Ubuntu
  • Wordpress
  • Xenforo

Tags

Android Android One AWS Bluehost Comparisions Custom ROM Elementor Facebook Genesis Genesis Sample Theme Google Drive How to Lineage OS Notes OnePlus One OwnCloud Rooting Smartphones Stock ROM Studiopress Tomcat Wordpress plugin

Copyright © 2025 · Maintained by GokulDeepak

 

Loading Comments...