• 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 remove index.php and index from the URL using htaccess | PHP

How can I format this number correctly using PHP?

Sort a multidimensional array by integer inside of a string value which is two levels down

PHP header location absolute URL

301 Redirect to remove query string on homepage only

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

How to find the date a user created their Google account

PHP function Not Working As Expected From functions.php Include File

Laravel Command Schedule Not Working Properly

Unit (real unit test) of test laravel relationship

How to fix Call to undefined method AppModelsTableName::factory?

Change user role if checkout custom checkbox is checked in WooCommerce

Make survey at laravel 5.4 and MySQL

Yii2 redirecting to previous page after login

How to properly start Laravel 8 with Bootstrap & authentication

About Contact Privacy policy Terms and conditions