Does query_posts have an effect on get_the_category?

The “main” query on the page is saved to a global called $wp_query. That global determines a great deal about the page, including both content and which template is used to display that content. Using $wp_query overwrites that main query and can cause some very basic things to fail but get_the_category() is probably not one … Read more

Get the ID of the current post’s child category

Display every grandchildren on wordpress support forum seems pretty close. Here is the solution that was proposed: <ul> <?php $all = get_pages(); //You could use $args to retrieve posts how you want. foreach($all as $all) { if($all->post_parent) { if( get_page($all->post_parent)->post_parent ) { $tp = get_page($all->post_parent); if( !get_page( $tp->post_parent )->post_parent) { $grandchild_ids[] = $all->ID; } //catching … Read more

Saving return value from the_author_posts_link()

The author posts link returns the author name which is linked to posts written by him. I think what you need is the author name of the post. It can be retrieved with <?php echo get_the_author(); ?> and if in case you need the link to the posts by this author then use: <?php echo … Read more

Exclude subcategory from wp_query

This is pretty easy. WP_Query has different argument you can use to exclude a category. The (little) problematic part is how to exclude that category from all loops, being able to still directly querying it. You can use ‘pre_get_post’ action hook, check the ‘category_name’ argument of current query and if it’s different from ‘street-style’, exlude … Read more

Retrieve WordPress’ the_content() with jQuery

As @G.M pointed out, you need to levy the awesome AJAX API. In the example below, we fire a request to the AJAX handler, along with the parameter action=gallery_popup. $( “a” ).click( function () { $( “.gallery-pop-up-container” ).load( “/wp-admin/admin-ajax.php?action=gallery_popup” ); } ); In response to this request, WordPress will trigger an action of the same … Read more

Writing less unnecessary code with WordPress

Try this function cat_loop ($key){ $fashion_cat = array( ‘category_name’ => $key, ‘posts_per_page’ => 4, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post__not_in’ => $already_posted, ‘category__not_in’ => $private_categories ); // Add the loop. } cat_loop (‘fashion’); cat_loop (‘beauty’); cat_loop (‘lifestyle’); put the loop in function which has variable for the category_name … Read more

Fetching posts from wordpress function in ajax

If you read the documentation for locate_template you’ll see the problem. locate_template( $template_names, $load, $require_once ); $require_once (boolean) (optional) If true, the template file will be loaded with the php require_once function. If false, the template file will be loaded with the php require function. This parameter has no effect if $load is false. Default: … Read more