custom header text

For something like this, you can use WordPress’s built-in “Custom Fields” feature. Step 1 On your edit page, create a new Custom Field (if you don’t see the Custom Fields box on your edit screen, click on the grey”Screen Options” tab at the top-right of the page, and make sure the “Custom Fields” box is … Read more

Trying to get property of non-object wordpress error message

Given that the page works if you leave the original query alone, your solution is pretty simple. Leave the original query alone. You don’t need to overwrite that query in order to created secondary loops. Instead of this: query_single(‘dealers’, ‘publish’, ‘1’, $taxtype, $value); if (have_posts()) : while (have_posts()) : the_post(); You want: $myq = new … Read more

save_post action inside a custom metabox class not working

I have modified your code as following and it is working for me. I have removed the constructor from your code and added the code in method and called that method using object. if (is_admin()){ add_action(‘load-post.php’, array(‘Mighty_Metabox’ , ‘Custom_Mighty_Metabox’)); } //the class class Mighty_Metabox{ //the vars public $id = false; public $title = false; public … Read more

How can I call a specific file (via php) by referencing the logged-in username?

Try to do this: <?php global $current_user;?> <?php if(is_user_logged_in()) :?> <?php get_currentuserinfo();?> <?php if(is_array( $current_user->roles ) && in_array( ‘map_user’, $current_user->roles ) ) : ?> <div id=”mapContent”> <?php require(“/mapping/”.$current_user->user_login.”.html/”); ?> </div> <?php endif; ?> <?php endif; ?> Source codex.wordpress.org

Submit form to db

You are serializing your form data before posting it to your PHP function, but you do not unserialize it at the other end. Therefore your check for $_POST[‘attend’] == ‘yes’will always fail. Try the following (untested). function eventAttend() { $fields = array( ); parse_str( $_POST[‘data’], $fields ); if($fields[‘attend’] == ‘yes’) { global $wpdb; $wpdb->insert(‘wp_event_attendants’, array( … Read more

Using color schemes with Color Picker

Don’t save everything as individual options, save all of your options as an array under a single key. One query to load it and save it, then just do all your manipulation in php. example structure and output: $colors = array( ‘current_scheme’ => ‘user_scheme’, ‘preset_schemes’ => array( ‘red’ => array( ‘menu’ => ‘#CC0000’, ‘footer’ => … Read more

Display Custom Field in Sidebar if Value is Present

I think, you’re mistaken in how if works…? $post_meta = get_post_meta( $GLOBALS[‘wp_query’]->post->ID, ‘TourURL’, true ); if (! empty($post_meta)) echo ‘<p>Show Link</p>’; else echo ‘<p>No Link</p>’; This should do what you want – if I understood you correctly. // UPDATED

WordPress -> If Is Role Subscriber Show Image?

This <?php if ( current_user_can(‘contributor’) ) : ?> only checks the users capabilities and is used like this <?php if ( current_user_can(‘edit_post’) ) : ?> You could write a function like this in functions.php: function user_role_check( $role, $user_id = null ) { $user = wp_get_current_user(); if ( empty( $user ) ) return false; return in_array( … Read more

Finding and removing duplicates within WP Arrays

If you only want to collect the category+tag names into the output, you can try this <?php global $post; $words=array(); $tags = wp_get_post_tags($post->ID); foreach($tags as $tag){ $words[]=”%23″.$tag->name; } $cats = get_the_category($post->ID); foreach($cats as $cat){ $words[]=”%23″.$cat->name; } $words=array_unique($words); echo implode(” “,$words); ?>

go to home page when i select default in select-box

You can try this <script type=”text/javascript”> var dropdown = document.getElementById(“cat”); function onCatChange() { if ( dropdown.selectedIndex == 0 ) { location.href = “https://wordpress.stackexchange.com/questions/90797/<?php echo get_option(“home’);?>”; }else if ( dropdown.selectedIndex > 0 ) { location.href = “https://wordpress.stackexchange.com/questions/90797/<?php echo get_option(“home’);?>/?cat=”+dropdown.options[dropdown.selectedIndex].value; } } dropdown.onchange = onCatChange; </script>