All Questions
29
questions
1
vote
0
answers
26
views
Plugin with action 'save_post' needs to press publish twice on order to publish
I have an old plugin, which used to work fine (years ago). Now I have to press publish twice to publich the post.
The problem is in the blocks below. The used variables are declared above the code ...
3
votes
2
answers
2k
views
Get updated post meta on save_post action?
I'm trying to save post id and keyword (Yoast Focus Keyword) to a custom table when post is created or updated via save_post action. It saves everything fine on Publish (first-time) but when I update ...
-1
votes
1
answer
67
views
Remove action of an external plugin after checking if custom post meta is set
Edit:The problem were 2 folds - somehow the order list I found before indicated wp_head was before wp_enqueue_scripts but that is not the case. Found another more updated one and it is actually right ...
0
votes
0
answers
174
views
Custom filter from post meta
I am trying to create a dropdown filter on the custom post type record listing page.
I have it showing up using a dummy array but can't get it to work with actual data.
function ...
2
votes
1
answer
118
views
Explanation for remove_filter used in the below code [closed]
I am very confused about what the developer has done here. This is inside a class..a filter has been added and then removed, added again. This code results in many errors as well.
add_filter('...
1
vote
1
answer
81
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
0
answers
73
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
1
answer
59
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);
$...
1
vote
1
answer
5k
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
1
answer
2k
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
1
answer
304
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 ...
2
votes
2
answers
139
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
1
answer
192
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'))
...
4
votes
1
answer
7k
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 ...
1
vote
1
answer
4k
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
1
answer
263
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
2
answers
292
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
1
answer
2k
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
0
answers
92
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
1
answer
13k
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
3
answers
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 ...
4
votes
1
answer
2k
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
1
answer
428
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
0
answers
122
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
2
answers
1k
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
1
answer
7k
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
2
answers
277
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
1
answer
263
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
1
answer
220
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 ...