Condition display metabox in case the post is saved

As an alternative to @m0r7if3r’s solution, the add_meta_boxes hook optionally passes two variables, the post type and post object. You can use this to conditionally add your metabox. New posts have the post status of ‘auto-draft’. add_action( ‘add_meta_boxes’, ‘myplugin_add_custom_box’,10,2); function myplugin_add_custom_box($post_type, $post) { if($post->post_status != ‘auto-draft’){ add_meta_box( ‘myplugin_sectionid’, __( ‘My Post Section Title’, ‘myplugin_textdomain’ ), … Read more

Change a url / link if a user is logged in?

Change the line with the URL: <a href=”https://wordpress.stackexchange.com/questions/70644/<?php echo get_option(“home’); ?>/”><div id=”logo”> … and check if the user is logged in: <a href=”https://wordpress.stackexchange.com/questions/70644/<?php if ( is_user_logged_in() ) { echo admin_url(“/themes.php?page=wptuts-settings’ ); } else { echo home_url( “https://wordpress.stackexchange.com/” ); } ?>/”><div id=”logo”> And echo get_option(‘home’); is not correct. See wp-includes/link-template.php:home_url() to understand why the real home … Read more

Creating conditional to display taxonomy term meta

I ended up adding an additional taxonomy meta class I was then able to use the following to get my phone number: <?php //Get the correct taxonomy ID by slug $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); //Get Taxonomy Meta $saved_data = get_tax_meta($term->term_id,’loc_phone’); ?> <?php if( $saved_data != “” ) { … Read more

How do I toggle pagination on/off in search results and category listings via a link?

I think it should work by hooking into pre_get_posts: function wpse_254661_remove_pagination( $query ) { if ( $query->is_main_query() && get_query_var( ‘onepageprint’, 0 ) ) { $query->query_vars[‘nopaging’] = 1; $query->query_vars[‘posts_per_page’] = -1; } } add_action( ‘pre_get_posts’, ‘wpse_254661_remove_pagination’ ); Like this you can modify your query right before it gets fetched and the query object gets passed by … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)