The Stack Overflow podcast is back! Listen to an interview with our new CEO.

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1
vote
1answer
30 views

How to generate numbers indistinguishable for the IDs of the posts

For a few days I've been after a filter or a function that creates more random ID's for posts like: 1920363522091 or Hpw_027991m-q Instead of the wordpress pattern that is: 1, 2, 3, 4 ... It can ...
0
votes
0answers
48 views

Grab meta data before post is saved

I'm trying to grab the metadata for a post before it is saved. I know that I could use the 'post_updated' hook (https://developer.wordpress.org/reference/hooks/post_updated/) to grab the before/after ...
0
votes
1answer
50 views

wordpress is_front_page() issue

I am updating the page title of all pages with a function i have created: function wpss_show_custom_description() { $wpss_disable = get_post_meta(get_the_id(), 'wpss_disable', true); $...
0
votes
1answer
2k views

Update post meta within save_post action

I'm currently trying to update a post's meta value within the save_post action. The problem with this is that it gets overwritten immediately. I've been banging my head on this problem for several ...
0
votes
1answer
296 views

Why does get_post() not return anything?

Inside my functions.php I use get_post() or similar (such as get_the_title()) inside some of my functions. It does not return anything. Why? And how to fix that? P.S: And I can not really add ...
0
votes
1answer
91 views

How to call get_post()?

I have a sidebar on my site and there I want to show the current post's meta information, such as the last modified date, the author and more. Thus I wrote the following function: function ...
1
vote
2answers
100 views

Where to hook my plugin's action

I'm writing a plugin that every time you: publish a post edit an already published one delete a published post it makes several queries to the database, gets certain post data (title, excerpt, ...
0
votes
1answer
103 views

Hide post title input for all roles except admin

How would this function need to be updated to exclude the admin? add_action('admin_init', 'wpse_110427_hide_title'); function wpse_110427_hide_title() { if (current_user_can('subscriber')) ...
1
vote
1answer
3k views

Change meta tags programatically

Is there a way to change the meta tags not in the head but in a template file through code? I would like to change the meta tags <meta property="og:title" content="title" /> <meta ...
0
votes
1answer
2k views

Set default Custom Post Meta Value

I've tried almost anything and just can't get this to work. I have a custom post type with a custom meta field and I want a default value to be added on when the Publish/Update/Save button is pressed....
0
votes
1answer
232 views

How can I get some of a posts meta data whilst it is still inserting?

I'm trying to make a function where a child post of a certain post type inherits the same title and slug as its parent. I'm using WP Types to define my post types and their relationships. But I'm ...
5
votes
2answers
278 views

Content hooks vs User hooks

This is more of a theory question than a question with a direct answer. I've been working with different actions for firing functions when a post is updated or deleted and when users are updated or ...
0
votes
1answer
1k views

WooCommerce wp_insert_post action firing on every save

function initial_product_data ( $post_id ) { // lets get out of here if this is not a new product if ( 'product' != $_POST['post_type'] ) return; // make sure the post isn't automagically ...
0
votes
0answers
85 views

Unsure how to add simple checkboxes that write to a small table to admin

I've been doing a lot of reading on the add_meta_boxes...but there's so much information that I'm confused about when to use them. I have a little plugin that writes out some checkboxes and then when ...
2
votes
1answer
11k views

update_post_meta() whenever custom post type is updated

I need the following functionality. Whenever my custom post type is updated or saved I need to overwrite certain custom post metas. I need to make sure this only affects posts of the post type '...
0
votes
3answers
1k views

Using preg_replace to filter custom textarea

I am developing a custom post type, which, among others includes the possibility of sending an email from within the post editor. The email body textarea is populated through a custom settings page ...
3
votes
1answer
960 views

Restrict post edit/delete based on user ID and custom field

I've been able to prevent deletion and editing of posts based on user ID and page ID however, I need to restrict access to editing and deleting based on a custom field. Not sure how to go about doing ...
2
votes
1answer
391 views

Filter list by a unique meta value dilemma

I'm been racking my head at this for a while now, and I can't figure out how to fix the code. Here's the issue; I found a snippet of code online to filter my post results in edit.php based on ...
1
vote
0answers
114 views

How to prevent further updates of custom meta when using actions to set one meta based on another

I'm using rilwis' Meta Box plugin (see https://github.com/rilwis/meta-box) to add custom meta boxes to a custom post type. I then want to populate one piece of meta data based on the value of another....
0
votes
1answer
972 views

Create action running on trashed_post hook to modify post_meta value

I have a custom post type that always do math operation to its post_meta and other custom post type post_meta. For example: post-type 1 = cpt_product_order post-type 1 post_meta = ...
0
votes
1answer
5k views

is there an update_post_meta action

Are there any actions I can hook into for update_post_meta()? I don't see anything obvious in the source. Woocommerce lets you change the featured status of items via ajax from the edit screen. I ...
0
votes
2answers
269 views

Custom Post type forgetting data

I just set up a custom post type, mostly following this tutorial. I'm setting up things on my site now, doing a lot of CSS modifications and such, and every few minutes the post just forgets ...
0
votes
1answer
256 views

Post via wp-admin and via iOS app, same hooks and triggers involved?

I've got an add_action in functions.php, the action is for save_post and the function I'm running I've named set_attachment_url. I'm simply getting the first attachment on a post and setting a custom ...
2
votes
1answer
197 views

Post IDs missing on delete_postmeta action hook

I'm using metadata in pages to store variables and do server side caching for dynamic generated PayPal buttons and other variables about the pages (page specific). I'm trying to hook the page meta ...