Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

get-posts

Weird query with get_posts and WP_Query

August 5, 2022August 4, 2022 by Magenaut

Attempting to make a search in a custom post type “comunicados” inside a shortcode in a custom plugin I send this to get_posts()

Categories Q&A, Wordpress Tags get-posts, wp-query Leave a comment

How to get a custom post with the largest ID (not the last post by date)

August 5, 2022August 4, 2022 by Magenaut

I would like to get the (one) post with the last ID, even if it is not the last post by date. The post belongs to a custom post type.

Categories Q&A, Wordpress Tags get-posts Leave a comment

When should you use WP_Query vs query_posts() vs get_posts()?

August 5, 2022August 4, 2022 by Magenaut

It seems like half the tutorials in the Codex and around the blogosphere use query_posts() and half use WP_Query.

Categories Q&A, Wordpress Tags get-posts, query, query-posts, wp-query Leave a comment

When to use WP_query(), query_posts() and pre_get_posts

August 4, 2022August 3, 2022 by Magenaut

I read @nacin’s You don’t know Query yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using query_posts() for all my querying needs. Now I’m a little bit wiser about using WP_Query(), but still have some gray areas.

Categories Q&A, Wordpress Tags get-posts, pre-get-posts, query-posts, wp-query Leave a comment

Regenerate Slugs From Title of Posts

August 4, 2022August 3, 2022 by Magenaut

is it possible to regenerate the slugs programmatically after changing the titles of the post? Numerous post titles were updated and the slug was not updated with the title so I need to regenerate all these slugs.

Categories Q&A, Wordpress Tags get-posts, slug Leave a comment

How to get attachment file name not attachment URL

August 4, 2022August 3, 2022 by Magenaut

I’m using this code to list the image attachments of a post:

Categories Q&A, Wordpress Tags attachments, get-posts Leave a comment

How to use the_posts_navigation for wp_query and get_posts?

August 4, 2022August 3, 2022 by Magenaut

WordPress have the_posts_navigation function since 4.1.0. But I don’t know how to use with wp_query or get_posts. the following code is in a template file of page.
wp_query method:

Categories Q&A, Wordpress Tags get-posts, navigation, wp-query Leave a comment

Get Posts Under Custom Taxonomy

August 4, 2022August 3, 2022 by Magenaut

I am not getting the posts under custom taxonomy(fabric_building_types). I am getting cat_id and cat->name also but not able to get the posts.

Categories Q&A, Wordpress Tags categories, custom-taxonomy, get-posts, posts, taxonomy Leave a comment

Only get_posts of certain post formats

August 3, 2022August 2, 2022 by Magenaut

I’m trying to create a archive list with only my “normal” post format articles (not link, aside, quote, etc formats).

Categories Q&A, Wordpress Tags archives, get-posts, php, post-formats Leave a comment

Get posts by meta data OR title

August 3, 2022August 2, 2022 by Magenaut

I have a working query that calls all my posts that have a certain meta value for one of two meta keys:

Categories Q&A, Wordpress Tags get-posts, query, query-posts, wp-query Leave a comment
Older posts
Newer posts
← Previous Page1 Page2 Page3 Page4 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress