Articles of theme development

How to limit wordpress menu depth in admin panel

Is it possible to limit maximum menu depth in admin panel /nav-menus.php? I need this because my theme won’t support more than two levels of menu, so there is no point in allowing a user to make deeper menus.

Filter, or any way to dynamically change theme screenshot image?

I’m building a web application on top of WordPress. Part of this will be to automatically reconfigure theme assets based on the industry my user is aligned to. For example, the theme will auto-select from a library of stock background or slide-show images, based on the logged-in user’s industry. I’d like the user to also […]

index.php is not loaded for single posts

I’m using the following code at the top of my index.php page in my theme and it never hits the is_single() code even on single posts. if ( have_posts() ) { echo “****************we have posts”; if ( is_single() ) { echo “******************It’s single”; } while ( have_posts() ) { the_post(); echo “<br >******************after the_post(): ” […]

Infinite Scroll not working in own theme

I’m developing my own theme and added this in a function which is called with the hook after_setup_theme to support infinite scroll: add_theme_support( ‘infinite-scroll’, array( ‘container’ => ‘content’, ‘footer’ => false, ‘wrapper’ => false ) ); I got this from http://jetpack.me/support/infinite-scroll/. content is the id of the container the new posts should go in. footer […]

How to load a different header based on post format?

I have a difficult question. What’s the best way to load a different header based on a post format? I guess I could load another loop around the header but I noticed the site does slow down. This is the code on my index.php: <?php get_header();?> <section id=”block”> <?php if ( have_posts() ) : while […]

How to add custom template tag in wordpress theme?

I am working on a WordPress site, it’s an online newspaper site. The theme I am developing, I want to add custom template functions like get_footer() or get_header(), so that I can save those HTML and PHP codes like the way footer.php stores. Thanks in advance.

Template Hierarchy for get_header()

I’m considering having different headers depending on the area of the site. So thought it might be possible to tap into the template hierarchy (or at the very least, re-use some of the code) and filter the output. Is this something that anyone has tried? Or could anyone point me in the direction of the […]

How to enqueue scripts depending on post formats?

So I’m trying to enqueue scripts used for some post formats like video and audio and I could find a way to check what post formats are going to be shown on the page. I tried print_r on some global variables but they doesn’t seems to have post_format in the post details, I tried $posts […]

Is it necessary to prefix every css class in a theme framework?

I’m working on a theme framework, prefix everything include css classes, so ‘main-content’ is ‘framework-main-content’, ‘header’ is ‘framework-header’, etc. Recently I took a look at the famous framework Genesis, and I see no prefix for css classes at all, the HTML markup so that looks clean and also the CSS code. It is no doubt […]

display 20 lines only with the_content

I like to display only 20 lines of post with the read more link using the_content( __( ‘Continue reading <span class=”meta-nav”>&rarr;</span>’ ) ); But it shows full content . How can i strip it .please help me !