• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

advanced custom fields wordpress custom class

phpwordpressadvanced-custom-fields


PHP Snippet 1:

/* Target Page 1 Button */
.page-1 .btn {
  background-color: red;
}
/* Target Page 2 Button */
.page-2 .btn {
  background-color: blue;
}

PHP Snippet 2:

<?php
// e.g. in functions.php
function extraButtonClass() {
  // Target by page slug or ID
  if(is_page('page-1')) {
    return ' red';
  } elseif(is_page('page-2')) {
    return ' blue';
  } else {
    return null;
  }
}

// In template:
<button class="btn<?php echo extraButtonClass(); ?>">My Button</button>

Related Snippets

how to prevent float variables displaying as scientific notation when printing [duplicate]

Unable to get password for the instance created from AMI

PHP Array split string and Integers

Vimeo API: how to save a vimeo into a subfolder?

Creating Combinations of Elements

Wordpress add responsive srcset header image to theme

Can I write PHP code across multiple lines per statement?

PHP | "The requested PHP extension bcmath is missing from your system."

How can I get a div content in php

How to change product Image when variables are selected in Shop and Archive Pages?

possible options to create pdf file using html elements to generate invoice in php and codeigniter

How to set a domain name with php artisan serve

How to use $this->session->set_userdata in codeigniter

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

Laravel: Why is my variable not being set while it's in the construct function of the controller?

About Contact Privacy policy Terms and conditions