-
▼
2011
(334)
-
▼
June
(28)
- How to Place JavaScript Into WordPress Pages
- How to Choose a WordPress Business Theme
- How to Use Google's AdSense With WordPress
- How to Change WordPress From Strict to Transitional
- How to Automatically Link WordPress Articles
- How to Find a WordPress Post ID
- How to Insert a Map Into WordPress
- How to Install FeedBurner for WordPress
- How to Add Clickable Logos in WordPress
- How to Add a Wordpress Blog to a Static Site
- How to Remove Phoenix Exploit From Your WordPress ...
- How to Access WordPress on HostGator
- How to Get Vietnamese in WordPress
- How to Add AdSense to a WordPress Theme
- How to Use PHP in WordPress Editor
- How to Do a Complete Uninstall of Wordpress From H...
- How to Use WordPress Mobile Edition
- How to Make a WordPress for Facebook
- How to Access Login to WordPress on your Web Server
- How to Embed Tweet Box With WordPress Plug
- How to Insert an Image Into a WordPress Blog Witho...
- How to Stop the Alphabetical Sorting of WordPress ...
- How to Upload Word Documents to Wordpress
- How to Center Headers in CSS on WordPress
- How to Use Images in a WordPress Template
- How to Create a Sitemap in WordPress
- How to Convert a WordPress Template to Fluid Width
- How to Make a WordPress Thumbnail Redirect to an E...
-
▼
June
(28)
adsense
How to Find a WordPress Post ID
Find the ID in the Dashboard
1. Log into the WordPress dashboard by visiting this page:http://yourdomain.com/wp-adminType in your user name and password, if prompted, and then press 'Enter' to log in. The dashboard is the control panel for your WordPress website.
2. Click 'Posts' in the left-hand menu and then click the post you want to check. Look at the address bar of your browser. The address contains a URL for 'post.php' plus a question mark and 'post=' with a number following that. The number is the ID for that post. While you can change the post title or the 'slug,' the ID always remains the same.
3. Click 'Pages' in the left-hand menu and then click the title of a page. Look at the address bar again. Like with posts, pages also get post ID numbers. In the case of IDs, WordPress treats pages and posts the same way.
Find the ID Programmatically
4. Navigate to the folder of your current WordPress theme and open any template files you wish to edit using a code editor like Notepad , jEdit or BBEdit. You can also edit from the dashboard by navigating to 'Appearance' and then 'Editor.' Files are listed on the far-right side.
5. Use the get_the_ID() function to find the ID of a post or page. This function returns the ID without displaying it on a Web page; use the_ID() to display the post ID as content on the post or page. Assign the ID to a variable so you can pass it to other functions. Here is an example:$post_id = get_the_ID();
6. Get the post ID by its title using a MySQL query. This is more complicated because WordPress does not offer a template tag function to do all the technical work for you. Here is some sample code:
get_var('SELECT ID FROM $wpdb->posts WHERE post_title = '' . $title . ''');?>The above code sets a variable to 'Sample Post' that is then passed into a MySQL query. The query itself is saved to the 'titleid' variable. You can then pass that variable somewhere else in the code or output it using '
'.
3:43 AM | Filed Under | 0 Comments
Comments
Popular Posts
-
1. Log in to your Weebly account. 2. Click 'Theme Editor.' 3. Click on the 'Design' tab. 4. Select 'Edit CSS/HTM...
-
1. Sign up for a publisher account at Bidvertiser. Submit basic contact information and confirm your email address to get started. 2. Lo...
-
1. Log in to your WordPress dashboard. 2. Open the 'Appearance' section on the left side of the WordPress dashboard and then cli...
-
1. Open your WordPress Dashboard in your preferred browser. It is accessed at the '/wp-admin' location of your site. For example, ...
-
Facebook Widget 1. Create a Facebook fan page for your blog, if you don't already have one. You will have to manually share content wi...
-
1. Download and install the WordPress for BlackBerry app via BlackBerry App World. Download the version that corresponds with your BlackBe...
-
1. Go to your WordPress blog's administrative control panel. 2. Click the 'Settings' button on the left-side navigation menu...
-
1. Click the 'Add Contact' button on the 'Add New Post' page. This opens the 'Add a Contact Form' page. 2. Click...
-
1. Register an account with Amazon Web Services Cloud. If you have an existing Amazon account, enter your email address in the appropriate...
-
1. Log into your WordPress.com account using your user name and password. 2. Hover your cursor over the 'My Blogs' tab at the to...
Post a Comment