Articles of id

Set post tags using tag ID

I want to set post tags to a new value. Is there a way to use the tag ID to do it? The wp_set_post_tags only accepts the tag name or an array of tag names. <?php wp_set_post_tags( $post_ID, $tags, $append ) ?> The reason why I want to set the tag using the ID is […]

Get post or page id early

Is there a good solution to get the queried object id really early … and i mean really early? I got a hook on after_setup_theme where i need to get the post or page id. $wp_query->queried_object_id is null at that point. I did it like so till now: function getID() { $actual_link = “http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”; $theID […]

WP_Query custom field pass the post id

I’m using WP_Query with ACF(Advanced Custom Fields) I’m building a news portal, and I’m trying to pass related stories from 1 post which is top_story = true. In another WP_Query I want to print the related articles to the post_id which is top_story and the id of that post, which normally can change. My queries […]

How to view WordPress' default category IDs?

It seems that WordPress has default categories with default (and unchangeable) IDs. For example, the uncategorized category seems to always have an id of 1. Is this always the case? Is there any official documentation for this (and other default category IDs)? Question (big picture) How to view a list of these default categories and […]

Custom post type returns bad post ID

I added custom post type and I have first problem. I don’t know why but if I use $post->ID, independently of post ID it always gave me the same value. I’m using this function <?php the_post(); ?> to display content of post. What can I do with it?

How to get page_id for url rewrite or how to use page slug for calling a page?

I would like to simply create an url rewrite that takes the third argument and matches it to its corresponding pages, ignoring the other two arguments. domain.com/argument1/argument2/page-slug = ‘index.php?page_id=XXX’; Is it possible to call a page via it’s slug instead of it’s ID, or can I somehow generate the id, based on a pages slug? […]

php return username of currently viewed author profile

I’m at a loss. I have profiles developed for my wordpress website, and I want to display content on my page-profile.php that is specific per user profile. I’ve looked all around the codex and only found stuff like this: https://codex.wordpress.org/Function_Reference/get_user_meta that only gets the current logged in user and this:https://codex.wordpress.org/Function_Reference/get_the_author that gets the current post […]

Buddypress activity id

I am working on buddypress activity loop. I want to get current activity id or all activity parameters in entry.php file. but i am not able to get activity id. I am trying to use bp_activity_id(); But not able to get id. Please help. Thanks

Getting an ID from a URL, why can WP do this itself, but none of of the functions provided get it right?

I have a set of absolute URLs that have been used to refer to my site (they come from redirects in an old .htaccess file in this case). All of these URLs do resolve to some page or post on the site. In other words, when I use them in my browser, they work. Many […]

Search by Attachment ID

I’m building a stock photo page for my company where we upload all photos our staff created so that it can be used later. It shows the ID of the image by post->ID so that users can see it, note it and be useful later – just like any other stock photo website. However, when […]