WordPress | enqueue_scripts in a child’s theme returns error

The reason being that: get_template_directory_uri() actually returns the parent’s theme url. To fix it, I simply concatenated the remainder of the path. In this case, the code became: // loading menu toggle function | located in the child’s theme folder function menu_toggle_enqueue_script() { wp_enqueue_script( ‘menu-toggle’, get_template_directory_uri(). ‘-child’ . ‘/assets/js/menu.js’); } add_action(‘wp_enqueue_scripts’, ‘menu_toggle_enqueue_script’); I figured out … Read more

How to write inner join using posts_clauses?

First, his filter is explained in the manual and is found in the code. If you have questions about hooks and functions, the manual and code is a good place to start looking for answers. The post_clauses hook is passed the associative array to filter, so just manipulate the where and join indices as per … Read more

Adding multiple conditional tags in a function?

You want to put those category IDs into an array really, the IF can only handle one condition at a time, so you could change your if statement to be: if( is_category(’16’) || is_category(’12’) ) { In PHP, the || stands for OR, whilst && stands for AND, so your if statement is saying if … Read more

How to style first post differently and wrap the others in their own container

If you are trying to style the first post with different HTML and others with other HTML structures. Then this code may help. <div class=”dpe-flexible-posts row”> <?php $firstQuery = new WP_Query(‘showposts=1’); if ( $firstQuery->have_posts() ) { while ( $firstQuery->have_posts() ) { $firstQuery->the_post(); ?> <div <?php post_class(‘col-8’); ?>> <div class=”dpe-flexible-posts-inner magB30″> <div class=”post-thumbnail”> <a href=”<?php echo … Read more

Limit search to posts and pages

and add this to functions.php if you want to search only in posts and pages. function mk_searchfilter($query) { if ($query->is_search && !is_admin() ) { $query->set(‘post_type’,array(‘post’,’page’)); } return $query; } add_filter(‘pre_get_posts’,’mk_searchfilter’);

WordPress create permalink structure for custom post type with userid

From this question: You can do this with a couple of filters: <?php function wpse_112719_pre_post_link( $permalink, $post, $leavename ) { if ( strpos( $permalink, ‘%author%’ ) !== false ) { $authordata = get_userdata( $post->post_author ); $author_id = $authordata->ID; $permalink = str_replace( ‘%author%’, $author_id, $permalink ); } return $permalink; } add_filter( ‘pre_post_link’, ‘wpse_112719_pre_post_link’, 10, 3 ); … Read more

plugin backend help

I’m not completely sure what you want, but I noticed with position that echo not always give the right position try to build up a large string and then echo the complete results or just return the results. like this: $output .= echo $prefix; $output .= echo $tweetprefix; $output .= echo $cleaner[0]; $output .= echo … Read more