• 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

Whats the point of running Laravel with the command 'php artisan serve'?

How to solve cURL error 60: SSL certificate in Laravel 5 while Facebook authentication

How to set dynamic `home` and `siteurl` in WordPress?

MISSING UPDATES FOR: MEDIA Drupal 9

PHP mail function is sending blank message body

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

Send POST data via raw JSON with Postman

best way to store error messages in Laravel (session or variable)

oauth-private.key does not exist or is not readable

Results page in other window

Generate random username based on full name php

How to create a video stream from a single dynamic image in PHP

How to use PHPCBF to fix one issue at a time?

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

MySQL - Connection failed: No route to host

About Contact Privacy policy Terms and conditions