functions

taxonomy – Possible to merge these two functions? – WordPress Website Design Article

I have these two functions. The difference is that one is filtering custom taxonomy (is_tax) and the other is filtering generic WordPress tags (is_tag). The work as I’d like them to be it seems that the code is being duplicated. This is Taxonomy: add_action( ‘pre_get_posts’, ‘sort_conference_by_date_tax’ ); function sort_conference_by_date_tax( $query ) { if ( $query->is_main_query() && !is_admin() ) { if ( $query->is_tax() ) { $query->set(‘orderby’, ‘meta_value’); $query->set(‘meta_key’, ‘start_date’); $query->set(‘order’, ‘DESC’); } } } This is for Tags (Standard WordPress) add_action(…

Read More

Function Composition in JavaScript with Array.prototype.reduceRight — SitePoint – Website Design Article

Functional programming in JavaScript has rocketed in popularity over the last few years. While a handful of its regularly-promoted tenets, such as immutability, require runtime workarounds, the language’s first-class treatment of functions has proven its support of composable code driven by this fundamental primitive. Before covering how one can dynamically compose functions from other functions, let’s take a brief step back. What is a Function? Effectively, a function is a procedure that allows one to perform a set of imperative…

Read More

functions – Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons – WordPress Website Design Article

I’m trying to change the svg of the ellipses for the mobile menu. It’s called in this file: template-functions.php so I did a hook on my child theme functions.php to replace it, like so: function replace_ellipses() { if ( function_exists(‘twentynineteen_add_ellipses_to_nav’) ) { remove_filter( ‘wp_nav_menu’, ‘twentynineteen_add_ellipses_to_nav’, 10, 2 ); } function twentynineteen_add_new_ellipses_to_nav( $nav_menu, $args ) { if ( ‘menu-1’ === $args->theme_location ) : $nav_menu .= ‘<div class=”main-menu-more”>’; $nav_menu .= ‘<ul class=”main-menu”>’; $nav_menu .= ‘<li class=”menu-item menu-item-has-children”>’; … This is only a…

Read More

php – Shortcode content output but not in correct place – WordPress Website Design Article

I have created a shortcode that gets information from an ACF repeater field… function display_websites_shortcode() { ob_start(); // check if the repeater field has rows of data if( have_rows(‘streaming’) ): while ( have_rows(‘streaming’) ) : the_row(); // Your loop code echo ‘<a href=”‘ . the_sub_field(‘website_url’) . ‘” >’ . the_sub_field(‘website_source’) . ‘</a>’; endwhile; else : // no rows found echo ‘<p>No Websites Available</p>’; endif; return ob_get_clean(); } add_shortcode( ‘display_websites’, ‘display_websites_shortcode’ ); The output/loop works but… This is only a snippet…

Read More