List Categories of the Parent Category of the Current Category

Assuming you have only two levels of categories, you could first retrieve the parent category and then list the child categories. Furthermore, calling get_children and wp_list_categories uses more resources than necessary, using only wp_list_categories would suffice. I’ve explained my answer in the following snippet that should behave exactly as you need it to! $category_id = … Read more

Problem with tag

You can display a shortcode by using two (or three) square brackets at the open and close, e.g. [[[pdf href=”http://www.constitution.org/usdeclar.pdf”]Declaration of Independence[/pdf]]] In my experience, a standalone shortcode just needs two whereas one that wraps needs three on each end, even though I’ve seen it said that it should work just two in either case.

The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”

The best way to customize a navigation menu is to use a custom ‘walker’ function.. Here are the steps how to achieve the customization that you want! Create a “wp-custom-nav-walker.php” file in your theme directory for a new custom ‘walker’ class. Extend the Walker_Nav_Menu class and copy the class’ function that you want to modify … Read more

Remove class that has been added by parent theme

If you want to apply a filter to the same content another function has filtered, change the priority argument (which should have been named _execution_order_) to a higher number. So … add_filter( ‘body_class’, ‘my_body_class’, 11, 2 ); … will make sure my_body_class() will be called after another_body_class() that has been registered with 10: add_filter( ‘body_class’, … Read more

Execute a function using ajax

<div id=”asinform”> <form id=”productpreview” action=”#”> <input type=”text” id=”asin” name=”asin” value=”” placeholder=”Enter ASIN”/> <input type=”hidden” name=”asin_form_post” value=”1″/> <input type=”submit” value=”Preview”/> </div> <div id=”asinpreview”> <!– Preview goes here –> </div> <script type=”text/javascript”> if ( typeof jq == “undefined” ) var jq = jQuery; jq(document).ready( function() { jq(“#productpreview”).submit(function() { var asin = jq(“#asin”).val(); jq.post( ajaxurl, { action: ‘amazon_product_preview’, … Read more