Articles of functions

How to override this theme function in child theme

I’m working in a child theme and I need to override a function in order to remove some unwanted items on a top menu. So I have research a bit and found a lot of docs, really, like this, this and this among others but still not clear at all to me how to achieve […]

Adding javascript to functions.php causes problems with my template

I want a “Read on” link that moves to another part of the page when clicked. I understand the HTML bit and I have even used some nice scrolling. It works. But when implemented breaks part of my theme. The slider image is gone and the H1 text is all bunched up to the left. […]

video.js not enqueueing?

I’d really appreciate any light you folks could shed on this issue. I was tipped off by Firebug that the function ‘videojs’ is not defined, when it tried to run the block of script which links to the swf object: <script>videojs.options.flash.swf = “<?php echo get_template_directory_uri(); ?>/loose/video-js.swf”</script> So I opened firebug and went to the scripts […]

Custom posts – tag pagination

I’m using the following code to output the custom posts that belongs to a tag: add_filter(‘pre_get_posts’, ‘query_post_type’); function query_post_type($query) { if(is_category() || is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) { $post_type = get_query_var(‘post_type’); if($post_type) : $post_type = $post_type; else: $post_type = array(‘btp_work’); // replace cpt to your custom post type $query->set(‘post_type’,$post_type); endif; return $query; } } […]

Related Posts: Changing Function For Posts Per Page

I am working on, which features 8 related articles below the content in every post, defined by some tags. Now I wanted to reduce the number of “posts per page” from 8 to 4. Of course, I can easily achieve that by changing the functions.php, but as soon as the theme gets an update, […]

wp_usermeta – Read from database, but save function broken

I added a custom field to the profile-page of WordPress users called “uidnumber” and it reads values from the database just fine, however it just doesn’t save anything. I’d rather save it in wp_users instead if I could because the whole table is just that much more clear, however from what I’ve read, WordPress updates […]

Are innerHTML elements visible to jQuery functions?

For example, on my admin page i.e. dashboard side: //This is hidden until search results come back //which will be inserted as innerHTML within #searchResults <div id=”hideShow”> <h2>Search Results</h2> <div id=”searchResults”></div> </div> //This is visible all the time <div><form>some fields etc</form><button id=”buttonSearch”></div> And then: //javascript file start jQuery(document).ready(function($) { jQuery(“#hideShow”).hide(); jQuery(“#buttonSearch”).click(function() {, data, function(response) […]

How to use get_posts() function in functions.php

I am trying to load posts with ajax. But I am not getting any content of the posts. I am not posting my javascript since it is pretty straight. Here is my code in inc/helper-functions.php which is included in main functions.php. function get_my_posts(){ $posts_per_page = $_POST[‘posts_per_page’]; $category = $_POST[‘category’]; $args = array( ‘posts_per_page’ => $posts_per_page, […]

remove/hide wp-editor

I have created a meta-box for a certain page_template. So if the adminpage is loaded with the template it shows the metabox. This does not require the wp-editor to add content. So I would like to hide or disable it. I have searched the interwebs but they all came up with the disablement of the […]

Query for user roles

How do I query for a specific user role? if (is_user_logged_in() && user_role == “user”) {} The part I’m unsure about is user_role. Is there a way I can ask WordPress to check for a specific user role by name/string?