• 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

Laravel Displaying image from database

PHP 8 - libxml_disable_entity_loader() has been deprecated. How do I replace the functionality it provides?

Best way to scrolldown onpageload

Can't find vendor/autoload.php for Ratchet

Eloquent insert id with sequence next value

I want to use codeigniter foreign character library in my custom PHP project how i can use it?

Laravel phpunit test failing authorization

wordpress : How to specify the cause "This site can’t be reached"

Call authenticate manually in router middleware

carbon generated datetime not stored correctly into the database

How to create a cookie to store the timestamp of when a page is first loaded with php

How can I make a full text index of the column?

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

php curl requesting twice

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

About Contact Privacy policy Terms and conditions