• 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

Get WooCommerce product variation attribute terms in admin products general box

MOODLE: What does it mean to aggregate h5p assets?

Unable to get password for the instance created from AMI

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

codeigniter 4 running error first time with xampp

curl returning 301 error after migrating to https

Add Metadata, headers (Expires, CacheControl) to a file uploaded to Amazon S3 using the Laravel 5.0 Storage facade

WooCommerce: Add/display Product or Variation custom field everywhere

loop through an anchor id

Laravel MSSQL Server Connection not working

Cant seem to get the Pagination to work on my WooCommerce REST API application?

GRPC installed successfully on ubuntu but php is looking for it in another folder

The sum of the user's points

Not able to override collapsible.js in magento 2

Update Total in checkout of Woocommerce with Ajax Request

About Contact Privacy policy Terms and conditions