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.

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

Problem enqueuing scripts on not single posts

With a couple minor modifications, I was able to run your function with your desired outcome (sitewide except on single post/cpt pages & in admin area). The current preferred method of returning the stylesheet uri is with the get_stylesheet_directory_uri(), not by using get_bloginfo(‘stylesheet_directory’): From the WordPress Codex Function Reference page: ‘stylesheet_directory’ – Returns the stylesheet … Read more

How do I pull avatar from post using BuddyPress? [closed]

Try this: $author_id = get_the_author_meta(‘ID’); echo bp_core_fetch_avatar ( array( ‘item_id’ => $author_id, ‘type’ => ‘full’ ) ); Defaults: array( ‘item_id’ => false, ‘object’ => ‘user’, ‘type’ => ‘thumb’, ‘avatar_dir’ => false, ‘width’ => false, ‘height’ => false, ‘class’ => ‘avatar’, ‘css_id’ => false, ‘alt’ => ”, ’email’ => false, ‘no_grav’ => false, ‘html’ => true, … Read more

Rewrite Question Mark in Post Template with URL Parameter for clean URLs

Your should add rewrite endpoint template on theme activation hook and init hook. Also there is some little checks to perform to prevent errors. function sjc_theme_activate(){ sjc_theme_add_rewrite_endpoint(); flush_rewrite_rules(); } //for more info http://codex.wordpress.org/Plugin_API/Action_Reference/after_switch_theme add_action( ‘after_switch_theme’, ‘sjc_theme_activate’ ); function sjc_theme_deactivate(){ flush_rewrite_rules(); } //for more info http://codex.wordpress.org/Plugin_API/Action_Reference/switch_theme add_action( ‘switch_theme’, ‘sjc_theme_deactivate’ ); function sjc_add_query_vars($vars) { $vars[] = ‘template’; … Read more