edit_form_after_editor only in post edit pages

Often with WP, it really helps to actually locate where and how a hook is called before using it. If you search the code base for edit_form_after_editor, you’ll locate: /** * Fires after the content editor. * * @since 3.5.0 * * @param WP_Post $post Post object. */ do_action( ‘edit_form_after_editor’, $post ); As you can … Read more

Get current category id from post page wordpress

WordPress has a function wp_get_referer, which gets the referring url from the http-header. So, if you go from a category archive to a single post, the name of the category will normally be included in that url. This means you can start your single.php like this: $refer = wp_get_referer(); if (strpos($refer, ‘category/cat1’) != false) {… … Read more

Display post X of Y in category

Okay, this should do, what you want: // Fetch all posts in the current post’s (main) category $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘cat’ => array_shift(get_the_category())->cat_ID, ); $query = new WP_Query($args); // The index of the current post in its (main) category $X = 1; $id = get_the_ID(); foreach ($query->posts as $cat_post) … Read more

Disable inline_edit() on edit.php

I was never able to find a filter either, but there is a check for whether the taxonomy is allowed to show it’s UI. So what I used to do in one of my plugins was to tweak the $wp_taxonomies global variable on the edit page. /** * Disable the UI for categories, but only … Read more

Set terms in a custom post

I know this is an old question, but the tax_input array should probably look like this since it appears to be hierarchical like a category: ‘tax_input’ => array(‘artist-category’ => array( 3 ) //use the ID of the category, not the name of the category From WordPress Codex on wp_set_post_terms If you want to enter terms … Read more

How do I restart my loop with get_next_post()?

get_next_post doesn’t really know what the “beginning” is. get_next_post uses get_adjacent_posts. If you look at the source, you can see that that function runs its own query to determine the next (or previous) post relative to the current post. It doesn’t loop through a list. To get the “first” post, you will need to run … Read more

Add custom Facebook share link with share count and variable text

I found a simple solution thanks to this answer: How do I change the singular/plural on “comment” to “comments” on Facebook’s number of comments? Here is how I solved without the tag, using the code I was already working for, this goes into function.php function get_likes($url) { $json_string = file_get_contents(‘http://graph.facebook.com/?ids=” . $url); $json = json_decode($json_string, … Read more