Getting an extra post’s meta data?

You are building your array and iterating over it at each iteration of the outer Loop. Think about what happens. First iteration of the outer loop $get_year becomes array(‘2012’) and you iterate over it echoing “2012”. Second iteration $get_year becomes array(‘2012′,2013’) and you iterate over it echoing “2012” and “2013”. Do you see what happened? … Read more

Get content from WordPress posts in Boostrap modal window – Javascript side?

Since I’m guessing you’re not rendering that Javascript file with PHP, you’ll need to send the ID of the post to that anonymous function using something other than PHP. You could use a data attribute in your #clickme <a> like data-id=”<?php the_ID(); ?>” and then change your on click to: $(document).ready(function(){ $(“#clickme”).on (“click”, function(){ $(“#myModal-” … Read more

WordPress displays post on subcategory only

How can I remove the post from subcategory 1.2 on subcategory 1? Use the ‘category__in’ argument parameter instead of the ‘cat’ parameter. Here is a user function that does what you want. /** * Category post list. * * An unordered list of category posts links. Posts in subcategories * are not listed in parent … Read more

Post is in descendant category not working in home.php

home.php is an archive of posts, and when you view home.php and function in plugin run, (on ‘wp’ hook) there is no current post. So the function post_is_in_descendant_category call in_category($descendants, null) that can never return true if there is no current post. For this reason, you should run the plugin function on ‘the_post’ action hook, … Read more

Display amount of pending posts in back/front end

Easy native SQL query: global $wpdb; $sql = <<<SQL SELECT post_status, COUNT( * ) AS count FROM {$wpdb->posts} WHERE post_status=”pending” SQL; $result = $wpdb->get_results( $sql ); The result will be something like + ———– + —– + | post_status | count | + ———– + —– + | pending | 158 | + ———– + … Read more

Get latest author posts inside the loop

I think you are executing reset_postdata() too early, using the global $post object incorrectly inside the secondary loop and passing wrong argumentes to the secondary loop. Try this. Put the function to get the latest author posts in the functions.php file: function the_latest_author_posts($post) { //some content goes here regarding the post itself!!! $relatedargs = array( … Read more