• 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

PHP password_verify

how to upload binary image to sql server using php laravel

Filter array by skipping every nth element from the end

Symfony - "framework.test" config is not set to true

"cannot list resources" error from WooCommerce REST API

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

How to pass data to all views in Laravel 5?

PHP: How to quickly split a key=value file into associative array

I can't delete my image when it is liked because of the foreign key in mysql

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

Symfony Error: "An exception has been thrown during the rendering of a template"

Prevent blank space in pdf pages (DomPdf)

Laravel Collections. Is there some kind of assertStructure method?

Could not decode a text frame as UTF-8.

About Contact Privacy policy Terms and conditions