Check to see if page exists problems

Why are you comparing $post->post_name to $this->title? You should be comparing slug to slug. Try changing your comparison from this: if( strtolower( $page->post_name ) == strtolower( $this->title ) ) …to this: if( strtolower( $page->post_name ) == strtolower( $this->slug ) ) Also, I might suggest keeping with the WordPress object conventions with your dynamically created pages, … Read more

Load comments per post on click with AJAX

Aha, I think my syntax was wrong. I changed: action: ‘do_ajax’, data: { ‘post_id’ : ’72’ //using a post id that I *know* has comments, for testing! }, to: data: { ‘action’ : ‘do_ajax’, ‘post_id’ : ’72’ }, and I’m getting the correct response from the console.log which shows: [{“comment_ID”:”1″,”comment_post_ID”:”1″,”comment_author”:”Mr WordPress”,”comment_author_email”:””,”comment_author_url”:”http:\/\/wordpress.org\/”,”comment_author_IP”:””,”comment_date”:”2012-08-28 19:55:20″,”comment_date_gmt”:”2012-08-28 19:55:20″,”comment_content”:”Hi, this is … Read more

Initiate only latest version of a class

CMB2 has a clever way of handling the same situation. It establishes a version constant that is a high number for the first release (9999), and on each subsequent release, the version constant is decremented. The version number is used for the priority of the action that instantiates the main class. This ensures that the … Read more

WP Plugin + OOP: Adding Menu Page doesn’t create required effect

the call at the anonymous function is done after all the executions of add_new_page. then you need to store all elements to create menu items. try to modify the class Helper like that public function __construct() // method to modify { add_action(“admin_menu”, [$this, “add_admin_menu_items”]); } public function add_new_page( $opt ) // method to modify { … Read more

Where is the “ancestors” post object attribute?

The reason you don’t see it if you dump object is because it’s not actual object property. WP_Post implements magical __get() method for ancestors and several more keys like that. When you access $post->ancestors() what you actually get is not some value from the object, but return of get_post_ancestors() function executed on it. So in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)