Output Post ID for all nav_items

html mark up for navigation will look like this <ul id=”menu-res” class=”main-menu”><li id=”menu-item-72″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-72″><a href=”#home”>Home</a></li> <li id=”menu-item-238″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-238″><a href=”#services”>Services</a></li> <li id=”menu-item-73″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-73″><a href=”#about”>About</a></li> <li id=”menu-item-75″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-75″><a href=”#skills”>Skills</a></li> <li id=”menu-item-346″ class=”menu-item menu-item-type-post_type menu-item-object-page menu-item-346″><a href=”http://www.yourstorepick.com/pro-site/”>Pro Site</a></li> <li id=”menu-item-347″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-347″><a href=”http://www.yourstorepick.com/wp-signup.php?pro-site=1″>Sign up</a></li> … Read more

WP_Query custom field pass the post id

1st query: $exclude_post_top_stories=””; // WP_Query arguments $args = array ( ‘post_status’ => array( ‘publish’ ), ‘posts_per_page’ => ‘-1’, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ); // The Query $exclude_query = new WP_Query( $args ); // The Loop if ( $exclude_query->have_posts() ) { while ( $exclude_query->have_posts() ) { $exclude_query->the_post(); // do something $exclude_post_top_stories[] = get_the_id(); } … Read more

php return username of currently viewed author profile

On an author archive page (assuming the plugin uses the core archives) get_queried_object() will return the WP_User object for the author. Something like: $author = get_queried_object(); if (is_a($author, ‘WP_User’)) { var_dump($author->data); } You should see the login, nicename, and display name in there. Use what you need.

Search by Attachment ID

The WP_Query class can match IDs as well as search terms. An idea would be to use the pre_get_posts action to detect if the search term is numeric and, if it is, set the query to work with attachments while passing the search as the ID. function wpse223307_allow_search_by_attachment_id( $query ) { //Only alter the query … Read more

How can I exclude a specific ID from this line of code?

On a seperate note, ‘caller_get_posts’ was deprecated in version 3.1 – use ‘ignore_sticky_posts’ with a boolean argument instead. ‘exclude’ is not a query argument so WordPress ignores it. Post exclusion via query is done using the key ‘post__not_in’ with a single post ID or array of IDs instead. However as @vancoder points out, the argument … Read more

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