WordPress theme options error

First, change your code into the following: $value = get_option( ‘mytheme_value’ ); query_posts ( “meta_key=post_views_count&orderby=meta_value_num&order=DESC&meta_value={$value}”); When you use single quotation marks, php isn’t parsed in the string, and functions (like get_option) will never be called from within a string. Therefore, call the function get_option first, and put the value in a double quoted string (which … Read more

Change WordPress Upload Folder using wp handle upload

Don’t store user uploads in your theme folder! I would suggest you store them in a sub-directory of the default uploads folder. You can use the upload_dir filter to temporarily change the path: function wpse_183245_upload_dir( $dirs ) { $dirs[‘subdir’] = ‘/abc’; $dirs[‘path’] = $dirs[‘basedir’] . ‘/abc’; $dirs[‘url’] = $dirs[‘baseurl’] . ‘/abc’; return $dirs; } And … Read more

responsive.css in the WordPress should be prioritized

If you want to make sure the second stylesheet loads after the first, you can use the third argument of wp_enqueue_style to set a dependency, eg: wp_enqueue_style( ‘styles’, THEMEROOT . ‘/css/style.css’, array() ); wp_enqueue_style( ‘responsive’, THEMEROOT . ‘/css/responsive.css’, array(‘styles’) ); As for having all the styles in responsive.css override style.css, that is going to entirely … Read more

How to show a ‘correct’ message after submit a form?

I solved the problem. First I check if there are errors and then I add a custom redirect url like this: if ( count($error) == 0 ) { wp_redirect( get_permalink() . ‘?updated=true’ ); } And finally I added a message using ‘GET’ method: <?php if ( $_GET[‘updated’] == ‘true’ ) : ?> <p class=”form-submit-success” style=”color: … Read more

Custom Menus: dynamic highlighting problem with custom home link

I achieved this with some jQuery: $(“#sidebar ul li”).each(function () { if ($(this).find(“a”).attr(“href”) == window.location.href) { $(this).addClass(“current-menu-item”); } }); (My nav is in a div with the id ‘sidebar’, you will need to change the first selector). It checks if the href of the links is the same as the current URL, and if so, … Read more

Unique session WordPress

You can do this by changing LOGGED_IN_KEY constant in your wp-config.php before logging in. define(‘AUTH_KEY’, ‘put your unique phrase here’); Update: it’s better to invalidate all secret keys. They can be generated by WordPress own generator here: https://api.wordpress.org/secret-key/1.1/

Custom gallery in wp3.5

I guess you were sorta correct, @david.binda, lol! After a lot of reading, and experimenting, I added the code below to the else statement in my functions file, and it appears to be working as it did before, although the process seems a lot “bulkier” with the new gallery trying to do it’s thing. $post_content … Read more