• 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

PHPSpreadsheet - How Do I Use Auto Migration Tool

Reorder attribute dropdown terms in Woocommerce single variable products

Prestashop webservice API creating cart rules

Zig-zag scan an N x N array

carbon generated datetime not stored correctly into the database

PHP -> Next nearest date defined by array of days in week

MySQL - Connection failed: No route to host

Clients authentication and user authentication with laravel

Sum array values of a column within each column of an array with 3 levels

Php - Sum up the numbers in an array one by one

Why rand() every time I refresh the page?

Manage independently the decimal number of the price of each product [duplicate]

how to loop through json response data using ajax jquery?

Center point of multiple gps coordinates with php

Laravel PHP: multiple project run at the same time [closed]

About Contact Privacy policy Terms and conditions