PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, May 15, 2022

[FIXED] How to add custom button in wordpress admin section

 May 15, 2022     php, wordpress     No comments   

Issue

I am trying to add "one custom button"(Send) in "wordpress admin panel", So i can send information to all users, But button not showing in my admin panel section,i tried with following code in "functions.php" file,where i am wrong ?

add_action('manage_$post_type_posts_custom_column', 'my_custom_column', 10, 2);
$column="Send";

function my_custom_column($column, $post_id) {
  if ($column == $my_column_name) {
    echo '<button>My Button</button>';
  }
  else
  {
      echo '<button>My Button</button>';
  }
}

Solution

You can try this code:

add_action( 'manage_post_type_posts_custom_column' , 'my_custom_column', 10, 2 );
function my_custom_column( $column, $post_id ) {
    $my_column_name='NAME-OF-THE-COLUMN';
    switch ( $column ) {
        case $my_column_name:
            echo '<button>My Button</button>';
            break;
    }
}

you actually forgot to add/assign $my_column_name to the actual column name you want to insert a button under.



Answered By - Web Developer
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing