custom sort posts in archive/taxanomy page

Put something along these lines in your functions.php: add_filter( ‘pre_get_posts’, ‘custom_get_posts’ ); function custom_get_posts( $query ) { if( is_category() || is_archive() ) { $query->query_vars[‘orderby’] = ‘name’; $query->query_vars[‘order’] = ‘ASC’; } return $query; } reference here (see the second answer)

Enqueue scripts in the footer

From http://codex.wordpress.org/Function_Reference/wp_register_script: <?php wp_register_script( $handle, $src, $deps, $ver, $in_footer ); ?> This means you need to add the $deps and $ver values to wp_register_script() in order to set $in_footer. Like this: wp_register_script( ‘justifiedGallery’, plugins_url(‘js/jquery.justifiedGallery.min.js’, __FILE__), false, // or array(), or array(‘jquery’) if this depends on jQuery ‘1.0’, // or your plugin version, or the version … Read more

WP_Query orderby not working on custom post_type

OK, I figured it pour reading about Orderby Parameters in WP_Query more carefully. I needed to set votes to meta_key and orderby to meta_value_num: $args = array( ‘post_type’ => ‘entry’, ‘meta_key’ => ‘votes’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 10, ‘post_status’ => ‘publish’ ); $loop = new WP_Query($args);

what is “theme_setup” method for?

Methods in 3rd party plugin and theme classes can be called whatever the author wants them to be called. theme_setup() doesn’t mean anything special, and doesn’t even necessarily mean the same thing in different plugins. And since it’s not a special method to WordPress, they’re never going to be called automatically by WordPress, so the … Read more

append code after the_content not working

previous_post_link and next_post_link both output the link directly, which won’t work in your case because you’re trying to assign the result to a variable. Use get_previous_post_link() and get_next_post_link() instead- function add_pagin( $content ) { if ( is_singular(‘post’) ) { $content .= get_previous_post_link() . get_next_post_link(); } return $content; } add_filter( ‘the_content’, ‘add_pagin’ );

WooCommerce add custom product_type_option

Your code only creates the checkbox, you need also to save the value like that add_filter(“product_type_options”, function ($product_type_options) { $product_type_options[“wildcard”] = [ “id” => “_wildcard”, “wrapper_class” => “show_if_simple”, “label” => “Wildcard”, “description” => “Description”, “default” => “no”, ]; return $product_type_options; }); add_action(“save_post_product”, function ($post_ID, $product, $update) { update_post_meta( $product->ID , “_wildcard” , isset($_POST[“_wildcard”]) ? “yes” … Read more

WordPress developer

Even though technically WordPress is a Content Management System (CMS), I think of it as a framework. It provides templating, caching, routing, database abstraction, etc. If you want to be a WordPress developer you need to know PHP, obviously, but you also need know how WordPress uses PHP and get familiar with the “WordPress Way” … Read more