Posts are the core of WordPress. They store content, are categorized, and are expansible with meta. Posts are grouped by post type, and within their post type by taxonomy (though a taxonomy can span more than one post type).

learn more… | top users | synonyms (2)

28
votes
2answers
84k views

Get wordpress post content by post id

How can i get wordpress posts content by post id?
18
votes
9answers
12k views

Stop Wordpress Wrapping Images In A “P” Tag

I have searched high and low for a simple solution to this, but to no avail. Wordpress keeps on wrapping my images in p tags and because of the eccentric nature of the layout for a site I am working ...
14
votes
4answers
2k views

Show a different number of posts per page depending on context (e.g., homepage, search, archive)

In the Reading Settings, there is place to set the number of posts shown that affects the number of posts shown in all contexts. I'd like to show instead a certain number of posts on the homepage, and ...
12
votes
5answers
744 views

How to mark every 3rd post

I'm working on a WordPress site for my band and I'd like to mark every 3rd post on our blog page to have a special class applied to it, anybody have any pointers on how to achieve this? Any help is ...
12
votes
2answers
3k views

Turn a URL into an Attachment / Post ID

Is there any way I can take a URL of an image and find the attachment or post id of that image in the database? Here is the situation: I'm in a loop going over all the 'img' tags that are surrounded ...
11
votes
4answers
20k views

WP insert post PHP function and Custom Fields

The wordpress function is used for submitting data programatically. Standard fields to submit to incude the content, excerpt, title, date and many more. What there is no documentation for is how to ...
11
votes
4answers
151 views

How do I check if I linked to a post before I delete it?

If I want to "safely" delete a post. I want to make sure that no link exists (within my blog) to "to-be-deleted" post. How do I do that?
10
votes
7answers
30k views

GET the excerpt by ID

Why is it that one cannot get the excerpt by ID like with the title and most other elements. eg. get_the_excerpt(ID). I know how to use it with the $post->post_excerpt function but that does not ...
10
votes
2answers
1k views

ZIP up all images displayed in a [gallery] and offer as download link

I would like to offer my visitors the option to download the entire photo gallery (displayed on dedicated [gallery] pages) as a ZIP file displayed at the bottom of each gallery page. - The full-sized ...
10
votes
3answers
646 views

How to make comments work for a post loaded per Ajax?

I am currently loading a single post using ajax. While the post loading works ok, I cannot get the comments to load. Here is my code: My javascript to load the post: <script> ...
9
votes
1answer
2k views

How do you add Read more … link to posts?

How do you add Read more ...link to a particular post or to all posts in a blog ?
8
votes
3answers
1k views

How to change the case of all post titles to “Title Case”

I am helping my father with his WordPress website. It has over 1,700 posts with TITLES IN UPPERCASE. We'd like to change these to "Title Case" in the database (possibly using this PHP script). The ...
8
votes
2answers
1k views

How to end the excerpt with a sentence rather than a word?

Here is the excerpt of the post on my home page. I want to end the excerpt with a sentence. In this case it is ' opportunities. '. I know how to modify the length but it won't do what i want. Here ...
8
votes
2answers
13k views

Adding Page Attributes Metabox and Page Templates to the Posts Edit Page?

(Moderators note: Title was originally "How can I add the "Page Attributes" and/or "Page Attributes > Template" selector to POSTS editor") WP currently only allows the assignment of a "template" to ...
7
votes
3answers
175 views

Is there a way I can write a series in WordPress?

What I mean by series is like writing a book. A reader should be able to click on the book and then proceed to read the chapters. I can probably mimic it by creating a page and then linking it to a ...
7
votes
1answer
1k views

When is the 'post_content_filtered' column in database cleared by WordPress?

Some WordPress plugins (although very few) use the post_content_filtered column in database to save some data related to a post. For example, Markdown on Save stores the markdown version of a post ...
7
votes
1answer
592 views

How to use “Add link” pop up for a WordPress widget

In the WYSIWYG editor of WordPress you get pop up if you want to add a link for a text. Is there a possibility to access this functionality? Because I want to use this pop up for a WordPress widget ...
7
votes
2answers
187 views

How to prevent posts from being published too close to each other?

I manage a blog which consists of about 25 writers. Sometimes a few of them are in the process of writing a new post at once, and they end up publishing them too close to each other. Is there a way ...
7
votes
2answers
499 views

What's $object->filter for?

I keep seeing this pattern, and wonder what it's for, how WP uses it internally: if ( empty($post) ) { if ( isset($GLOBALS['post']) ) $_post = & $GLOBALS['post']; else ...
7
votes
1answer
375 views

Custom Post Types, slug, archive and SEO plugins

I made a custom post type called "friends". I am able to correctly list my friends using this urls: http://mysite/friends/friend1/ http://mysite/friends/friend2/ http://mysite/friends/friend3/ ...
6
votes
3answers
4k views

Add extra parameters after permalink?

How can I add extra parameters after a permalink, specifically if I'm using a custom post type? For example, let's say http://mysite/album/record-name was the permalink. How can I make ...
6
votes
3answers
2k views

How can I convert Posts into Custom type posts?

I have a Wordpress site that I just updated to 3.1. I want to make use of custom post types now, my question is how can I assign (transfer?) a post to a newly created custom post type ? For example, ...
6
votes
3answers
17k views

Submit post and upload image from front-end

I am trying to do something similar to the above question. I am trying to make users post and upload images from front-end. I have already done the post form and its working. I just followed and ...
6
votes
1answer
842 views

Stop WP from creating “Sample Page” and “Hello World!” post

Is it possible to stop WP from creating the "Sample Page" and "Hello World!" post when creating a new blog?
6
votes
3answers
1k views

Set Default Listing “View” in Admin

I'm looking for a way to set the default "View" options under post types in the admin area. For example, by default Posts will default to a "list" view instead of "excerpt" - I'd like to change this ...
6
votes
2answers
1k views

Confirmation box when submitting post for review

A very common issue that I experience with new authors is that they forget to complete a few essential tasks prior to submitting their post for review (even though I have a guide available for them). ...
6
votes
2answers
578 views

How to prevent a post from being deleted?

For auditing issue, I only want a post can be trashed, but not deleted - for all users. So I have a plugin like add_action('before_delete_post', function($id) { wp_die(0); }); But ...
6
votes
2answers
640 views

Do we still need to include a “if (have_posts())” in templates?

I include this logic in my template all the time if (have_posts()): //show content else: //show content not found endif; But recently i began to doubt its necessarity, wordpress will turn to ...
6
votes
1answer
534 views

Optimize post insert and delete for bulk operations?

Not much noticeable when working with individual posts, but when you create or delete multiple thousands in bulk and by code - process is quite slow. Are there any good tweaks to apply and corners to ...
6
votes
1answer
385 views

Display Random Author with Details in Sidebar

PHP newbie here, recently decided to have a stab at cobbling together a kooky little 'Random Author Spotlight' feature into my current WordPress theme. I'm almost done, but I've hit something of a ...
6
votes
1answer
1k views

Wordpress Queue like Tumblr?

Is there a way to give Wordpress the queue functionality that Tumblr has? Tumblr's queue, for those who don't know, is a way to space posts out without assigning specific post dates. For example, a ...
6
votes
1answer
6k views

How set featured posts using checkbox in post edit screen?

I want to make selecting a featured post is just by checking a checkbox in edit screen AND be able to retrieve these featured articles from only specific category ? in short what I'm looking for : ...
6
votes
1answer
132 views

How to protect pages with double authentication: password + email (in custom field)

I would like to extend the WordPress password protection of posts by adding extra input field for user email. So in order to see the content user will have to know the password and previously given ...
6
votes
2answers
148 views

Is it possible to Schedule Attachments in Wordpress?

As it's fairly well known, it is possible to schedule Posts in Wordpress for publishing. Also Attachments are actually Posts (in the more internal, technical meaning). So the question that bothers ...
6
votes
2answers
817 views

How to add a new tab to page editor

Anyone knows how to achieve this? It has something to do with meta boxes, but I just can't figure out the proper syntax.
6
votes
1answer
485 views

Search Custom Post Type Pages and Custom Fields in 2 Dropdowns?

On my custom post type pages I have custom fields that the user can edit. What I want is to have a search form with 2 select dropdowns: one dropdown that is populated with all the top-level custom ...
5
votes
4answers
650 views

How does one reduce the number of stored revisions?

How does one reduce the number of stored revision (e.g. 5 max) for post types that support revisions?
5
votes
2answers
3k views

How to add a “last” class to the last post in loop.php?

I need to add a "last" class to the last post that appears in loop.php. Can someone tell me how to accomplish this?
5
votes
4answers
2k views

How can you change the 'Insert into Post' title in the media button?

Actualy the question says it all. I integrated a media upload box to my admin page and a button with the text 'Insert into post' makes no sense. I rather like to change it to something like 'Use this ...
5
votes
2answers
505 views

Delete Associated Media Upon Page Deletion

Note Use at your own risk, it is buggy and I have run across a couple instances where it would delete ALL attachments. Unsure why. Is it possible to delete media associated with a page when that ...
5
votes
6answers
5k views

How to Create Editable Blocks of Text for the Homepage?

I'm making a site based on WordPress. It's not going to seem a blog or WP. Just a website. So WP acts like backend where the client can edit the text blocks. Question: How can I put block of text ...
5
votes
2answers
465 views

WP_Query Pagination on single-custom.php

What I am looking to do: Setup WP_Query pagination in a single-custom-post-type.php template file What I have done 1) Created a post type called "authors". Each post within that post type is an ...
5
votes
2answers
355 views

Can I force a metabox to be in one column?

Suppose I created a custom metabox for the add/edit post page that uses a wide width (not suitable for being in the sidebar), is there a way of keeping it in the middle column only and sortable while ...
5
votes
1answer
853 views

How to merge two or more WordPress posts?

I need to be able to merge two or more posts. What is the exact query (or queries) to make this happen? The scenario is multiple recommendations that need to be merged into one. I have already sorted ...
5
votes
1answer
2k views

using wp_update_post on save_post

im trying to update a posts date (-1 year), when you hit update. but it causes an infinite loop. any other ways of doing this? thanks. function change_year($post_id, $post){ if ( ...
5
votes
2answers
510 views

How to Display Network Post Count?

Is it possible to display the total post count for all blogs in a Network? get_blog_count and get_user_count do so for blogs and users, but I can't find any methods to do so for post count.
5
votes
1answer
104 views

Inject post (from specific category) between posts in Loop

I would like to add a post (from specific category) between posts in the WordPress Loop (such as 'Sponsors'). Example: P P P S P P S P P S P P How can I achieve this? I am a beginner with coding, so ...
5
votes
2answers
3k views

Function to execute when a post is moved to trash .

Hi is there an action which can be performed while a post is moved to trash .... I tried delete_post and deleted_post. It works but twice for each action ( before and after the action as written in ...
5
votes
1answer
132 views

Listen to Post action

I am writing a plugin that adds a custom metabox to the post page. I would like to trigger an event when the user navigates away from the edit post page or when a user stops editing a specific post. ...
5
votes
5answers
1k views

Different post sort order within different categories

I need to give each post a unique post order for multiple Categories (per post) it is in. I can imagine a solution using custom fields whereby for each Category there is a corresponding custom field ...