Function to pull data from user meta not working

The problem is that when you pass the $key argument on get_user_meta() function, you don’t pass a valid argument. The $key must be a string according to the documentation page. It represents the value of meta_key in the wp_usermeta table. If with wpcf-client-lvl is actually a variable that contains the name of the field ( … Read more

WordPress Website with Login system

Okay, here is a simple example. init action loads before loading WordPress website. So we can use it to check some special conditions for allowing access to users. You should use this in functions.php function user_custom_redirect() { if ( ‘something’ === ‘something else’ ) { // let user view WordPress website } else { // … Read more

Child theme functions.php

You should put your code in your child theme’s functions.php file. I believe that the documentation you reference is referring to the fresh state of the functions.php file and the fact that you don’t need to copy a parent theme’s functions into a child theme to use them.

Insert a field with PREG_REPLACE – strange behaviour

You need to use get_field function here instead of the_field. function wrapImagesInDiv($content) { if ( in_category( ‘projects’ ) ) { $pattern = ‘/(<img[^>]*class=\”([^>]*?)\”[^>]*>)/i’; $replacement=” <div class=”owl-wrapper”> <div class=”owl-item $2″> “.get_field(‘description’).’ $1 </div> </div>’; $content = preg_replace($pattern, $replacement, $content); } return $content; } add_filter(‘the_content’, ‘wrapImagesInDiv’); Function get_field returns the value but the_field prints the value.

Help with a function in a widget

First, if meta key is isbn_metadata is the meta_key you should specify this meta key instead of _isbn. Second, get_post_meta return an array unless you set the third parameter to true. So, you can do this: function get_kalahari_affiliate_link() { $isbn_metadata = get_post_meta( get_the_ID(), ‘isbn_metadata’, true ); if( ! empty( $isbn_metadata ) ) { $link = … Read more

Child Theme’s Read More Text

As this line of code is hardcoded in the index.php file rather than called via a function you only really have two options: Write your own function to call this code (with your chosen read more text), then replace the relevant section in the child theme’s index.php file with a call to this function. The … Read more

Remove a Plugin function through theme’s function.php?

Same way you would remove it from anywhere else, be it a plugin or theme or whatever. add_action(‘plugins_loaded’,’remove_whatever’); function remove_whatever() { if (class_exists(‘PixGridder’)) { remove_action( ‘wp_enqueue_scripts’, array( PixGridder::get_instance(), ‘front_styles’ ) ); } } Might want to use a better function name than “remove_whatever” though. 🙂

How to display 2 function calls in same line?

Put the two functions on same line, like this: <?php the_author_posts_link(); ?> <?php the_time(‘g:i a’); ?> If this doesn’t work, first get the values and then output them, like this: <?php $author_name = get_author(); $author_link = get_author_posts_url( get_the_author_meta( ‘ID’ ) ); $post_time = get_the_time(‘g:i a’); ?> <p> <a href=”https://wordpress.stackexchange.com/questions/166166/<?php echo $author_link; ?>” title=”<?php echo $author_name; … Read more