Articles of theme development

What might cause a featured image not to display?

I’m writing a child theme for the editr theme and the featured image is not displaying for a new post. The featured images do display for demo content. For the new post, the following markup is rendered: <div class=”featured” data-img_bg=””> <img src=”” alt=”” style=”display: block;”> </div> The relevant section of the template is: <?php if […]

Searching post types

Is it possible to take a user input from a search form, use that to search a custom post type via the WP_Query class and then redirect the user to a page template to display the results? For example, Assume you have a search input that takes city, state or zip You then enter in […]

How to make Isotope and WordPress work together?

I am trying to make my WordPress theme using Isotope plugin. So far, I have such a result after doing that was suggested: I believe that Isotope Masonry should not look like this. I am really puzzled as to what I am doing wrong. Below is my code: functions.php function profolio_scripts () { wp_enqueue_style( […]

Trouble in enquing all js files under certain directory

I am using _s theme .I have all js files under js folder.My code function _s_scripts() { $js_dir = get_template_directory_uri() . “/js/”; foreach(glob($js_dir.’/*.*’) as $file) { $label = str_replace(“.”, “”, $file); wp_enqueue_script($label, $js_dir . $file . ‘.js’, array(‘jquery’), ‘1.0.0’); } } add_action( ‘wp_enqueue_scripts’, ‘_s_scripts’ ); Upon inspecting I found no jquery files loaded.PS I want […]

Is there a way to retrieve the calling template part?

If I include a template part within header.php like this: <?php get_template_part(‘templates/social-icons’); ?> Is there a way to retrieve the template name header.php within this template part? i.e the name of the template which is including social-icons.php? So in social-icons.php I want to retrieve the name ‘headers.php’ dynamically so that I can include social-icons.php elsewhere […]

How to fix WordPress images not showing up in local hosted XAMPP server?

I have recently been trying to establish a working method of developing WordPress sites locally by making use of an XAMPP server. The issue is that any images that I attempt to use refuse to show up when I load the page in a browser. I’m using the <?php echo get_template_directory(); ?>/library/images/name_of_the_svg_image file path, and […]

Injecting pre-defined text from custom page template to editor

I am creating a custom page template: < ?php /* * Template Name: sliding content * Description: Sliding category contents */ get_header(); ?> <div id=”primary” class=”content-area”> <main id=”main” class=”site-main” role=”main”> <?php while ( have_posts() ) : the_post(); ?> <div class=”post”> <h2 id=”post-<?php the_ID(); ?>”><?php the_title();?></h2> <div id=”accordion”> <?php the_content();?> </div> </div> <?php endwhile; // end […]

What's the right way to implement functions in footer.php

I have a WordPress website with a child-theme of ‘twentyfifteen’ I created. I added a PHP code that changes the footers background depending on the template displayed. This is my code part: /************************/ /***** Footer Color *****/ /************************/ $this_template = get_current_template(); //echo $this_template; switch ($this_template) { case “about-us”: $templates_color = ‘white’; break; case “homepage”: $templates_color […]

Confused by the behaviour of “front page” / “home” templates

I stumbled upon a confusing issue while trying to customize the appearance of the front page of my blog ( without changing the behaviour of the other blog posts index pages ( The problem is that I can’t seem to find a way to add a template for the front page that doesn’t affect the […]

Pagination fuction in shortcode always displays on top

Pagination function in shortcode always displayed on the top. Please have a look on below code /*————————————————————————-*/ /* Custom Pagination */ /*————————————————————————-*/ function suareztheme_pagination($pages = ”, $range = 2){ $showitems = ( $range * 2 ) + 1; global $paged; if(empty($paged)) $paged = 1; if($pages == ”){ global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages){ $pages = […]