custom field – How to make a complete Meta Box part of a complete Post Type?

I receive the code complete, but I don’t know how to make the Post Type loads the MetaBox when creating a new Post, here is the Post Type:

if ( ! function_exists('cpt_campaign_details') ) {

// Register Custom Post Type
function cpt_campaign_details() {

    $labels = array(
        'name'                  => _x( 'Campaign Details', 'Post Type General Name', 'text_domain' ),
        'singular_name'         => _x( 'Campaign Detail', 'Post Type Singular Name', 'text_domain' ),
        'menu_name'             => __( 'Campaign Details', 'text_domain' ),
        'name_admin_bar'        => __( 'Campaign Detail Post', 'text_domain' ),
        'archives'              => __( 'Campaign Details Archives', 'text_domain' ),
        'attributes'            => __( 'Campaign Detail Attributes', 'text_domain' ),
        'parent_item_colon'     => __( 'Parent Campaign Detail:', 'text_domain' ),
        'all_items'             => __( 'All Campaign Details', 'text_domain' ),
        'add_new_item'          => __( 'Add New Campaign Detail', 'text_domain' ),
        'add_new'               => __( 'Add New', 'text_domain' ),
        'new_item'              => __( 'New Campaign Detail', 'text_domain' ),
        'edit_item'             => __( 'Edit Campaign Detail', 'text_domain' ),
        'update_item'           => __( 'Update Campaign Detail', 'text_domain' ),
        'view_item'             => __( 'View Campaign Detail', 'text_domain' ),
        'view_items'            => __( 'View Campaign Detail', 'text_domain' ),
        'search_items'          => __( 'Search Campaign Details', 'text_domain' ),
        'not_found'             => __( 'Not found', 'text_domain' ),
        'not_found_in_trash'    => __( 'Not found in Trash', 'text_domain' ),
        'featured_image'        => __( 'Featured Image', 'text_domain' ),
        'set_featured_image'    => __( 'Set featured image', 'text_domain' ),
        'remove_featured_image' => __( 'Remove featured image', 'text_domain' ),
        'use_featured_image'    => __( 'Use as featured image', 'text_domain' ),
        'insert_into_item'      => __( 'Insert into Campaign Detail', 'text_domain' ),
        'uploaded_to_this_item' => __( 'Uploaded to this Campaign Detail', 'text_domain' ),
        'items_list'            => __( 'Campaign Details list', 'text_domain' ),
        'items_list_navigation' => __( 'Campaign Details list navigation', 'text_domain' ),
        'filter_items_list'     => __( 'Filter Campaign Details list', 'text_domain' ),
    $args = array(
        'label'                 => __( 'Campaign Detail', 'text_domain' ),
        'description'           => __( 'This post is used to manage all Campaign details', 'text_domain' ),
        'labels'                => $labels,
        'supports'              => array( 'title', 'thumbnail', 'page-attributes' ),
        'taxonomies'            => array( 'category', 'post_tag' ),
        'hierarchical'          => true,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'menu_position'         => 5,
        'menu_icon'             => 'dashicons-megaphone',
        'show_in_admin_bar'     => true,
        'show_in_nav_menus'     => true,
        'can_export'            => true,
        'has_archive'           => true,
        'exclude_from_search'   => false,
        'publicly_queryable'    => true,
        'capability_type'       => 'page',
    register_post_type( 'campaign_details', $args );

add_action( 'init', 'cpt_campaign_details', 0 );


And here is the Meta Box:

class CampDeta_Resu {

    public function __construct() {

        if ( is_admin() ) {
            add_action( 'load-post.php',     array( $this, 'init_metabox' ) );
            add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );


    public function init_metabox() {

        add_action( 'add_meta_boxes',        array( $this, 'add_metabox' )         );
        add_action( 'save_post',             array( $this, 'save_metabox' ), 10, 2 );


    public function add_metabox() {

            __( 'Campaign Details Results', 'text_domain' ),
            array( $this, 'render_metabox' ),


    public function render_metabox( $post ) {

        // Retrieve an existing value from the database.
        $cade_re_results_numbers = get_post_meta( $post->ID, 'cade_re_results_numbers', true );
        $cade_re_results_legend = get_post_meta( $post->ID, 'cade_re_results_legend', true );

        // Set default values.
        if( empty( $cade_re_results_numbers ) ) $cade_re_results_numbers = '';
        if( empty( $cade_re_results_legend ) ) $cade_re_results_legend = '';

        // Form fields.
        echo '<table class="form-table">';

        echo '  <tr>';
        echo '      <th><label for="cade_re_results_numbers" class="cade_re_results_numbers_label">' . __( 'Number', 'text_domain' ) . '</label></th>';
        echo '      <td>';
        echo '          <input type="text" id="cade_re_results_numbers" name="cade_re_results_numbers" class="cade_re_results_numbers_field" placeholder="' . esc_attr__( '', 'text_domain' ) . '" value="' . esc_attr( $cade_re_results_numbers ) . '">';
        echo '          <p class="description">' . __( 'This is the number that will appear over the legend. Example: 5.4M | 8.4M+ | 5x', 'text_domain' ) . '</p>';
        echo '      </td>';
        echo '  </tr>';

        echo '  <tr>';
        echo '      <th><label for="cade_re_results_legend" class="cade_re_results_legend_label">' . __( 'Legend', 'text_domain' ) . '</label></th>';
        echo '      <td>';
        echo '          <input type="text" id="cade_re_results_legend" name="cade_re_results_legend" class="cade_re_results_legend_field" placeholder="' . esc_attr__( '', 'text_domain' ) . '" value="' . esc_attr( $cade_re_results_legend ) . '">';
        echo '          <p class="description">' . __( 'This text will go below the number and will define what the number means. Example: Total print reach | Visits | Engagement growth', 'text_domain' ) . '</p>';
        echo '      </td>';
        echo '  </tr>';

        echo '</table>';


    public function save_metabox( $post_id, $post ) {

        // Sanitize user input.
        $cade_re_new_results_numbers = isset( $_POST( 'cade_re_results_numbers' ) ) ? sanitize_text_field( $_POST( 'cade_re_results_numbers' ) ) : '';
        $cade_re_new_results_legend = isset( $_POST( 'cade_re_results_legend' ) ) ? sanitize_text_field( $_POST( 'cade_re_results_legend' ) ) : '';

        // Update the meta field in the database.
        update_post_meta( $post_id, 'cade_re_results_numbers', $cade_re_new_results_numbers );
        update_post_meta( $post_id, 'cade_re_results_legend', $cade_re_new_results_legend );



new CampDeta_Resu;

I googled “add a created metabox to a post type” and a lot of things like that and there is a lot of tutorials but unfortunately I can’t make it work.

php – Add new post meta data after updated_post_meta?

Here’s the situation.

Basically, I’m trying to add user ID (to the newly created post meta data) that hearted the post.

My current code:

add_action('updated_post_meta', 'add_likers_id_to_post_meta');
function add_likers_id_to_post_meta ( $meta_id, $post_id, $meta_key, $meta_value ) {
        $user_id = get_current_user_id();

    if ( '_heart_this' == $meta_key ) {
         if ( 'liker1' == '' ) {
                update_post_meta( $post_id, 'liker1', $user_id );


The above should work like this:

There’s an already existing post with meta data _heart_this.

When the current user updates the meta data _heart_this, the new post meta_key liker1 will be created with meta_value of that user ID.

But the above code do not work.

I know I’m missing something.

Any help would be appreciated.


UPDATE: I have worked around a bit differently.

First, I will add custom meta data to the post, when the new post is created (using save_post). Having in mind that the post won’t be updated.

add_action('save_post', 'add_post_meta_data_fields_for_likers', 10,3);
function add_post_meta_data_fields_for_likers ( $post_id ) {

                add_post_meta( $post_id, 'liker1', '0' );

And then I will use update_post_meta to update with the user ID, when the post is hearted:

add_action('updated_post_meta', 'update_liker1_id_when_hearted');
function update_liker1_id_when_hearted ( $meta_id, $post_id, $meta_key, $meta_value ) {

        $user_id = get_current_user_id();

    if ( '_heart_this' == $meta_key ) {
         if ( 'liker1' == '0' ) {
                update_post_meta( $post_id, 'liker1', $user_id );



This seems to do the job.
hope this helps for others.

seo – Website’s title and meta description don’t show up in google search

seo – Website’s title and meta description don’t show up in google search – Webmasters Stack Exchange

post meta – if get_post_meta function returns empty – Do Not Display HTML

I am working on a website with some custom PHP.

The post uses “Custom Fields”, where the custom field “pdf_name” is added to the post when there is a PDF document to attach to it. The value would be the URL to that PDF.

If there is no PDF, this custom field is not used and thus gives no (URL) value.

To use this, I go into “single.php” to add a function like so:

$pdf_name = get_post_meta($post->ID, 'pdf_name', true);

Then I add the HTML:

<a class="pdfDownload" href="<?php bloginfo('url'); ?>/wp-content/uploads/<?php echo $pdf_name; ?>">PDF Download</a>

The HTML text link, “PDF Download”, will appear on all post displays, whether or not there is a PDF linked to it. This results in a 404 page if someone clicks the text link that has no PDF URL returned to it.

I want to hide this PDF text link if the $pdf_name function finds no PDF URL to use.
In other words, it finds and returns as no value.


if it is easier, when there is no PDF URL value, replace the HREF HTML with a basic non-linked text like “No PDF Available”.

Note: I am using a Child theme, so the theme single.php file is duplicated there.

Can anyone help with this?

search engines – Old business name appearing at the end of meta titles on Google – how do I get rid of it?

I’m having some issues with how meta titles are appearing on Google. Some pages have our old business name added onto the end of their meta titles, even though the old name doesn’t appear anywhere on our CMS. This is only an issue with Google, as on other SERPs they appear correctly (same meta title just without the old business name).

The old business name isn’t in the page source, and we’ve done a scan of directories for any old references and haven’t found anything, so I’m not sure where it’s picking it up from or how to amend it?

If anyone has any ideas I would really appreciate them.


Magento 1: Images’ “meta data” lost after uploading product photos to Magento 1.9 website

Magento 1.9.4
Porto theme

I have been putting a lot of work in adding “meta data” on all the images on the website. I do this on Adobe Photoshop. It seems to have disappeared.

Is there anything on Magento that would do this? What can I do so that the ‘meta data’ remains on the product images in Magento?


The original product photo which we upload has 244 KB while the image on the website is only 24.1 KB. This likely means that it gets downsized and the meta tags are stripped in the process. How can we change it so that it keeps the meta tags during the downsizing process?

css – Trying to hide HENTRY (Author Meta Data) from a Post ID

I am trying to hide the hentry class from a particular post ID – not sure why it doesn’t work for me….

Here’s the HTML

<header class="entry-header">
        <h1 class="entry-title">Post A</h1>

    <div class="entry-meta">
            <span class="posted-on">
        <a href="XX" title="3:51 am" rel="bookmark">
          <time class="entry-date published" datetime="XXXX">June 22, 2021</time>
        <span class="byline">
        <span class="author vcard"><a class="url fn n" href="XXX" title="XXX">
        <span class="__cf_email__" data-cfemail="XXX">[email&#160;protected]</span></a></span></span>
                <span class="comments-link"><a href="XXX">Leave a comment</a></span>
                    <!-- .entry-meta -->

    <!-- .entry-header -->

And this is my CSS:

.postid-7 .hentry .entry-meta {
    display: none;

Not sure where I am going wrong here….

meta tags – metatag TVSeries type “Page not eligible for rich results known by this test”

I’ve configured metatags for the “TVSeries” type but the Google Rich Results checker says “Page not eligible for rich results known by this test” even though the markup is there in the rendered HTML. Frustratingly, my metatags validate perfectly if I change the type to “Movie”.

<script type="application/ld+json">{
    "@context": "",
    "@graph": [
            "@type": "TVSeries",
            "@id": "",
            "name": "The Book Group",
            "description": "u003Cpu003EComedy series about an American living in Scotland who starts a book discussion group, created and written by Annie Griffin. Michelle Gomez is Janice McCann, a frustrated and unappreciated football wife who is searching for her value and purpose in life.u003C/pu003Ennu003Cpu003E u003C/pu003E",
            "image": {
                "@type": "ImageObject",
                "representativeOfPage": "True",
                "url": ""
            "dateCreated": "u003Ctime datetime=u00222002-04-12T12:00:00Zu0022u003EFri, 04/12/2002 - 12:00u003C/timeu003E",
            "actor": {
                "@type": "Person",
                "name": "Michelle Gomez",
                "url": "",
                "sameAs": [
                "logo": {
                    "@type": "ImageObject",
                    "representativeOfPage": "True",
                    "url": ""
            "@type": "WebSite",
            "@id": "",
            "name": "The Book Group | Very Gomez - The Michelle Gomez Database",
            "url": "",
            "publisher": {
                "@type": "Person",
                "@id": "",
                "name": "Nova Howard",
                "url": "",
                "sameAs": [
                "logo": {
                    "@type": "ImageObject",
                    "representativeOfPage": "True",
                    "url": "",
                    "width": "220",
                    "height": "220"

google – Phone number in meta description bad or good for local rankings NAP

Once again I’m at it with increasing people’s local rankings and I’ve learnt so much about local rankings in the past 2 weeks it feels like my brain is gonna pop anyway, question is fairly simple for someone who engages in local rankings and I appreciate the question may be a little guess work but isn’t SEO mostly guessing anyway?

From what I’ve read and learned that Google works of a system called nap for local rankings (With many other factors but this question is purely based on NAP). For people who care about local rankings NAP stands for Name of Business / Address of Business / Phone Number for Business.

Now what what I’ve read you don’t need the whole NAP to be on one website, a P or just a N can help towards your local rankings. It’s believed that NAP rewards more than just P and N for example but knowing Google they might have a diversity checker which is my concern what your get to in a moment.

Now of course sites weight differently where your business is posted, it’s certainly going to be more credible if your NAP details are on your national phone book than say a blog site, so taking in this consideration too.

Pure Guess (Not apart of the question but none the less makes a good read on my belief).

Now my guess work would make me believe that the formula would look something like (N)+(A)+(P)x(T)

So (N)name would be 1 or 0 to indicate present or not
So (A)dress would be 1 or 0 to indicate present or not
So (P)hone would be 1 or 0 to indicate present or not
So (T)rust would be 1-100 to indicate level of trust

So a phone number appearing on youtube might look something like 0+0+1×95= 95 and a NAP appearing on your national phone book might look something like 1+1+1×100= 300

Please note that I’m not saying this is the sole factor and I’m sure its way more complex that this with things like other factors on the page, off the page (Reviews, Links, Clicks) and so on but its still a contributor).

The Question

My question is fairly simple and I’d imagine hard to impossible to have an actual definite answer to this but maybe someone has seen official wording else where on this, is it bad to include address or phone number in the Meta Description? The reason I ask is that one of my competitors has these elements in the meta descriptions and their local rankings are absolutely superb, the problem I have with this is scrap bot sites like ‘Similar Too’ ‘Seo Rankings’ and 1,000’s of the other scrap box networks that scrap site and then make urls with your site information are mostly limited to your meta description what this means that your phone number, address and sometimes even your company name if the domain is exact will appear as AP, and even NAP on thousands of websites.

So, is it a bad strategy to include phone number and address in meta description, everything I read into would suggest its good of course with the downside of maybe lowering quality of description for click thoughts but top rankings would increase this 10 folds anyhow..

Hide users on users.php with a specific meta value

I am using the User Switching plugin in order to allow sales agents to place an order on behalf of a customer.
I want to allow sales agents to switch into their customers only instead of all customers. I have used toolset to create custom user meta field wpcf-sales-rep.

this link here seems relevant, the code below let me hide all customers from sales agents so i know it works, just needs to be modified somehow.


function rudr_hide_all_administrators( $u_query ) {
    // let's do the trick only for non-administrators
    $current_user = wp_get_current_user();
    if ( $current_user->roles(0) != 'administrator' ) { 
        global $wpdb;
        $u_query->query_where = str_replace(
            'WHERE 1=1', 
            "WHERE 1=1 AND {$wpdb->users}.ID IN (
                SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta 
                    WHERE {$wpdb->usermeta}.meta_key = '{$wpdb->prefix}capabilities'
                    AND {$wpdb->usermeta}.meta_value NOT LIKE '%customer%')", 

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies 5000 Private Proxies - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies New Proxy Lists Every Day Buy Cheap Private Proxies; Best Quality USA Private Proxies