Articles of functions

Custom Shortcode, functions PHP WP_Query loop

I have the following code in my functions.php file:- function featured_properties_func( $atts ) { $args = array( ‘posts_per_page’=> -1, ‘post_type’ => ‘properties’, ); $featured_query = new WP_Query( $args ); if( $featured_query->have_posts() ): while( $featured_query->have_posts() ) : $featured_query->the_post(); $featured_properties = get_the_title(); return $featured_properties; endwhile; endif; wp_reset_query(); } add_shortcode( ‘featured_properties’, ‘featured_properties_func’ ); When I output the shortcode […]

class=“parent” for wp_list_pages?

<div class=”menu”> <ul> <?php wp_list_pages(‘exclude=&title_li=’); ?> </ul> </div> creates the following output… <div class=”menu”> <ul> <li><a href=”#”>Page 1</a></li> <li><a href=”#”>Page with Subpages</a> <ul class=”children”> <li><a href=”#”>Page with another subpage</a> <ul class=”children”> <li><a href=”#”>subsubpage</a></li> </ul> </li> </ul> </li> <li><a href=”#”>Page 3</a></li> <li><a href=”#”>Page 4</a></li> </ul> </div> All pages with children have a ul class=”children” applied. Is […]

Output custom post shortcode. Help spot the error.

so I have written the below shortcode that outputs a list of custom posts. When I echo out the values it works fine. But when I do it a slightly different way and join variables it does not. It doesn’t really matter but I would like to now why. This works fine. function post_events($atts) { […]

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.

modify a function filter

I am using the latest version of wp-ecommerce (3.89) and a new filter has been introduced to enable role based access to certain dashboard features such as the sales page or upgrade capability. However, the default role in the core file is currently set to “administrator”. What I would like to do is take the […]

Fatal error: Call to undefined function post_exists()

I am using the function in my own class as I am using other wordpress functions in it. I am unable to understand why it is not able to find the function while ide “go to declaration” point me to file wp-admin/includes/post.php is wp-admin files functions do not exist as global.

Remove function or filter

Im working with a child-theme of WordPress-Bootstrap by 320press.com I want to get rid of the lead class added to the first paragraph of the content. I looked in WordPress codex in these articles: remove_action remove_filter But im not so experienced in PHP, only HTML – so i cant really tell if its a filter […]

Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php?

Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php? I have a mu-functions.php file in the mu-plugins folder. One function calls a javascript file (alerts.js) located in example.com/wp-content/mu-plugins/js/. How can I target the mu-plugins folder in my function? Currently, I am using get_site_url() . ‘/wp-content/mu-plugins/js/alerts.js’, Although not completely relevant to the […]

If category is in parent category?

I have function that check what is main top category of post. So i have category tree like this Foo -bar –foobar cat2 and if post is in foobar, my function post_is_in_descendant_category shows me “foo” and i can style that post with style-foo.css. What i want now is to make this same possible for styling […]

What is the difference between current_page_parent and current_page_ancestor?

In the function wp_page_menu there is an auto-generated classes to the list elements and the function generates current_page_parent and current_page_ancestor to a parent menu item if I clicked a child menu item (I mean if the current page is the child menu element). So now why does WordPress generate two different classes for the same […]