Articles of theme development

Conditionally loading JavaScript based on the Advanced Custom Fields in the post

I am building a site/theme where post content is authored in a modular way (mostly, but not exclusively) with ACF’s flexible content field. These fields could have JavaScript functionality attached to them on the public front-end. You might have an image upload that has parallax applied to it or a text block that has a […]

Problem with is_active_sidebar?

I have registered a sidebar with the following code : function reg_l_sid(){ $args = array( ‘name’ => __( ‘left-sidebar’, ‘Tutorial-Blog’ ), ‘id’ => ‘left-sidebar’, ‘description’ => ”, ‘class’ => ”, ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’ ); register_sidebar( $args ); } add_action (‘widgets_init’,’reg_l_sid’); and the […]

Is there any need to use both wp_reset_postdata and wp_reset_query together?

Is there any need to use both wp_reset_postdata() and wp_reset_query() together? Is it a case that I would pick one of the two functions; is there any point in doing this after a query : wp_reset_postdata(); wp_reset_query();

How to remove menus section from WordPress theme customizer

I tried to remove Menus from WordPress customizer (see image) I tried the following code on functions.php file and every section was removed except Menus //Theme customizer function mytheme_customize_register( $wp_customize ) { //All our sections, settings, and controls will be added here $wp_customize->remove_section( ‘title_tagline’); $wp_customize->remove_section( ‘colors’); $wp_customize->remove_section( ‘header_image’); $wp_customize->remove_section( ‘background_image’); $wp_customize->remove_section( ‘menus’); $wp_customize->remove_section( ‘static_front_page’); $wp_customize->remove_section( […]

Include Max mega menu Plugin into theme

I want to add the Max Mega Menu plugin into my theme for a project. What i’ve done: copy and paste plugin folder into my theme include megamenu.php file into my theme function.php file Needed to work: include with theme active when theme active So, how can I include this plugin and activate it when […]

What tags should be used for themes to show the type of layout?

In the Tag Filter the old tags ‘fixed-width’ and ‘flexible-width’ were renamed to ‘fixed-layout’ and ‘fluid-layout’. Also new ‘responsive-layout’ tag appears. Should users duplicate new tag ‘fluid-layout’ with old tag ‘flexible-width’? Or is it safe to use only new tags?

current_user_can not always working properly

I have a custom WordPress theme that includes a members only section. In order to implement this, I have the following code at the top of my restricted pages. <?php if ( ! current_user_can (‘view_players_area’) ) { header(‘Location: ‘ . wp_login_url( “http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]” ) ); } ?> Most of the time, this works fine, however every […]

Some doubts about how to show posts in a custom theme?

I am pretty new in WordPress theme development and I have some doubt about this WP function used to show my post in the homepage: <?php if ( have_posts() ) : // Start the Loop. while ( have_posts() ) : the_post(); /* * Include the post format-specific template for the content. If you want to […]

How to add font in wordpress

I have a oswald.woff font file downloaded from some free fonts site. Using ftp i have created folder called fonts in the themes folders. (i.e /wp-content/themes/esplanade/fonts). In the fonts folder i put the oswald.woff file. @font-face { font-family: “Oswald”; font-style: normal; font-weight: 400; src: local(“Oswald Regular”), local(“Oswald-Regular”), url(“fonts/oswald.woff”) format(“woff”); } I use this font for […]

Retrieve all posts within tag OR category?

I’ve created a simple loop. And I have the following array for the query: $live_tags = array( ‘tag’ => ‘live’, ‘showposts’ => 5, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ); Where it says ‘tag’ => ‘live’, I need a logic that asks: if (‘tag’ == ‘live’ || ‘category’ == […]