qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
47,206 | <p>I'm dealing with an SSL issue and I would like to strip the domain from all scripts and styles being output via wp_enqueue_scripts. This would result in all scripts and styles being displayed with a relative path from the domain root.</p>
<p>I imagine there is a hook that I can use to fileter this, however, I am no... | [
{
"answer_id": 47211,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, i think its possible. See on the filter hook <code>script_loader_src</code>; there get the string and you can... | 2012/03/29 | [
"https://wordpress.stackexchange.com/questions/47206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1777/"
] | I'm dealing with an SSL issue and I would like to strip the domain from all scripts and styles being output via wp\_enqueue\_scripts. This would result in all scripts and styles being displayed with a relative path from the domain root.
I imagine there is a hook that I can use to fileter this, however, I am not sure w... | Similar to Wyck's answer, but using str\_replace instead of regex.
`script_loader_src` and `style_loader_src` are the hooks you want.
```
<?php
add_filter( 'script_loader_src', 'wpse47206_src' );
add_filter( 'style_loader_src', 'wpse47206_src' );
function wpse47206_src( $url )
{
if( is_admin() ) return $url;
... |
47,209 | <p>I'm new to the forums and hoping to find an answer to the following question: </p>
<p>Go to this website: <a href="http://www.indochino.com/product/gray-glen-plaid-suit" rel="nofollow">http://www.indochino.com/product/gray-glen-plaid-suit</a>
Click on the thumbnails</p>
<p>Can anyone identify this lightbox?
Is it... | [
{
"answer_id": 47210,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 0,
"selected": false,
"text": "<p>You can use jQuery cycle, move the buttons apart, keep the adjacent divs visible. So you get the same e... | 2012/03/29 | [
"https://wordpress.stackexchange.com/questions/47209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14672/"
] | I'm new to the forums and hoping to find an answer to the following question:
Go to this website: <http://www.indochino.com/product/gray-glen-plaid-suit>
Click on the thumbnails
Can anyone identify this lightbox?
Is it a plugin or custom?
Any idea if it can be used with Wordpress?
Lastly, if nobody can identify thi... | Ist and custom gallery, i think. See in the source of `http://d3dgk6r8ca2pzn.cloudfront.net/js/gallery_1332969334.js`:
```
/**
* Image gallery used in product detail pages and customization pages
*
* @module Gallery
* @author Preet Jassi
* @file gallery.js
* @copyright (c) 2011 Indochino Ap... |
47,228 | <p>As an example, I'm looking at <code>class-wp-xmlrpc-server.php</code> and there's a line (~115) that says:</p>
<pre><code>$this->methods = apply_filters('xmlrpc_methods', $this->methods);
</code></pre>
<p>How can I actually find out what transformations are performed on the data by the filter? Obviously, I c... | [
{
"answer_id": 47229,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 0,
"selected": false,
"text": "<p>By interacting with the <code>$wp_filter</code> global, you can see all the filters that are setup at any giv... | 2012/03/29 | [
"https://wordpress.stackexchange.com/questions/47228",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14633/"
] | As an example, I'm looking at `class-wp-xmlrpc-server.php` and there's a line (~115) that says:
```
$this->methods = apply_filters('xmlrpc_methods', $this->methods);
```
How can I actually find out what transformations are performed on the data by the filter? Obviously, I can compare `$this->methods` before and afte... | Here is a snippet, similar to the above which prints out the hooked functions for all (or a specified) hook, every time it is called. The advantage is that this will capture (more, not all) 'dynamically' added hooks. In particular it will display only functions currently hooked onto that hook at the time of calling. (S... |
47,234 | <p>I’m trying to shorten the content of my RSS feed. Right now it displays way, way too much for each entry and I’ve tried to select the “Excerpt” in the Syndications setting in my option panel but it hasn’t done anything.</p>
<p>I’ve tried different approaches but little has it helped. </p>
<p>Is there a simple way ... | [
{
"answer_id": 47229,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 0,
"selected": false,
"text": "<p>By interacting with the <code>$wp_filter</code> global, you can see all the filters that are setup at any giv... | 2012/03/29 | [
"https://wordpress.stackexchange.com/questions/47234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6751/"
] | I’m trying to shorten the content of my RSS feed. Right now it displays way, way too much for each entry and I’ve tried to select the “Excerpt” in the Syndications setting in my option panel but it hasn’t done anything.
I’ve tried different approaches but little has it helped.
Is there a simple way (possible add\_fi... | Here is a snippet, similar to the above which prints out the hooked functions for all (or a specified) hook, every time it is called. The advantage is that this will capture (more, not all) 'dynamically' added hooks. In particular it will display only functions currently hooked onto that hook at the time of calling. (S... |
47,250 | <p>I am trying to understand what the following line from wp-signup.php does:</p>
<pre><code>$active_signup = get_site_option( 'registration' );
</code></pre>
<p>I can see from the following documentation:
<a href="http://codex.wordpress.org/WPMU_Functions/get_site_option" rel="nofollow">http://codex.wordpress.org/WP... | [
{
"answer_id": 47252,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 1,
"selected": false,
"text": "<p>You'll find every options in the table <code>wp_options</code></p>\n\n<p>Regarding the association between a key ... | 2012/03/29 | [
"https://wordpress.stackexchange.com/questions/47250",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1224/"
] | I am trying to understand what the following line from wp-signup.php does:
```
$active_signup = get_site_option( 'registration' );
```
I can see from the following documentation:
<http://codex.wordpress.org/WPMU_Functions/get_site_option>
that this will return the value of the site option '`registration`'.
But how ... | Note that the function `get_site_option()` works a bit differently from `get_option()` on its own. On WordPress Multisite (ie, with Network Mode enabled), there are two different kinds of options:
* site-specific options, which are stored in the individual options tables for each blog (`wp_options`, `wp_5_options`, e... |
47,280 | <p>After seeing some weird hits in my Relevanssi search results I found the following: </p>
<p><a href="http://wordpress.org/support/topic/searching-with-relevanssi-shows-all-revisions" rel="nofollow">http://wordpress.org/support/topic/searching-with-relevanssi-shows-all-revisions</a></p>
<p>I ran the following on my... | [
{
"answer_id": 47304,
"author": "robertwbradford",
"author_id": 7152,
"author_profile": "https://wordpress.stackexchange.com/users/7152",
"pm_score": 1,
"selected": false,
"text": "<p>As of now the Post Type Switcher plugin is causing this problem. (<a href=\"http://wordpress.org/support... | 2012/03/29 | [
"https://wordpress.stackexchange.com/questions/47280",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7152/"
] | After seeing some weird hits in my Relevanssi search results I found the following:
<http://wordpress.org/support/topic/searching-with-relevanssi-shows-all-revisions>
I ran the following on my WordPress database:
```
SELECT * FROM `wp_posts`
WHERE (`post_name` LIKE "%revision%" OR `post_name` LIKE "%autosave%")... | Have you tried adding an extra clause checking for the revision post type in `function pts_save_post( $post_id, $post ) {` of `post-type-switcher.php` ?
E.g. as taken from trunk and modified:
```
/**
* Set the post type on save_post but only when editing
*
* @since PostTypeSwitcher (0.3)
* @global string $pagenow... |
47,300 | <p>I do not know why this response me -1 always? I am using this code in my plugin file.
i want response on click p tag</p>
<pre><code><?php function myajax(){ ?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#testbutton").click(function(){
... | [
{
"answer_id": 47317,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 2,
"selected": true,
"text": "<p>according to wordPress jedi, scribu, you can now enqueue scripts from inside the plugin handler. </p>\n\n... | 2012/03/29 | [
"https://wordpress.stackexchange.com/questions/47300",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12261/"
] | I do not know why this response me -1 always? I am using this code in my plugin file.
i want response on click p tag
```
<?php function myajax(){ ?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#testbutton").click(function(){
jQuery.... | according to wordPress jedi, scribu, you can now enqueue scripts from inside the plugin handler.
<http://scribu.net/wordpress/conditional-script-loading-revisited.html>
you were echoing things and in shortcode handling you have to return. i ran into some issues getting the script to work by *returning* the script, s... |
47,303 | <p>I'm pulling in scripts.php through functions.php. this is in scripts.php but for some reason, wordpress isn't recognizing is_home(). i've tried resetting the query, but to no avail. Am I hooking into the right function? </p>
<pre><code>if(is_home()){
function my_scripts_method2() {
wp_register_script('cycle', ... | [
{
"answer_id": 47305,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 4,
"selected": true,
"text": "<p>At the time <em>functions.php</em> is included during bootup, WordPress has no idea on the contents of the que... | 2012/03/29 | [
"https://wordpress.stackexchange.com/questions/47303",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14700/"
] | I'm pulling in scripts.php through functions.php. this is in scripts.php but for some reason, wordpress isn't recognizing is\_home(). i've tried resetting the query, but to no avail. Am I hooking into the right function?
```
if(is_home()){
function my_scripts_method2() {
wp_register_script('cycle', get_template_... | At the time *functions.php* is included during bootup, WordPress has no idea on the contents of the query, and doesn't know the nature of the page. `is_home` will return false.
Wrap the code in a function and have it triggered by the `wp` hook, which comes after the global query object has been hydrated with data.
``... |
47,306 | <p>First off, I know it's better practice to use plugins separately than to integrate them in functions.php but this is for a theme framework that will be deployed to multiple sites and it will be easier to have it packaged as part of the theme.</p>
<p>I am having trouble using the following code from the plugin locat... | [
{
"answer_id": 47307,
"author": "xaedes",
"author_id": 9518,
"author_profile": "https://wordpress.stackexchange.com/users/9518",
"pm_score": 1,
"selected": false,
"text": "<p>That action will never be fired when it is no plugin :</p>\n\n<pre><code>add_action('plugins_loaded', 'initialize... | 2012/03/29 | [
"https://wordpress.stackexchange.com/questions/47306",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14702/"
] | First off, I know it's better practice to use plugins separately than to integrate them in functions.php but this is for a theme framework that will be deployed to multiple sites and it will be easier to have it packaged as part of the theme.
I am having trouble using the following code from the plugin located here. M... | ```
add_action('plugins_loaded', 'initialize_custom_image_sizes');
```
`plugins_loaded` is fired off way before *functions.php* is included. Change that hook to `init`.
<http://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request> |
47,310 | <p>I have a rotating images widget I want to display on my homepage. My selected homepage is a static front page I created with several other pages to make my blog look more like a website than a blog, and then I have a separate blog page. The widget does not come with shortcode. Rather it comes with something like cod... | [
{
"answer_id": 47312,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 0,
"selected": false,
"text": "<p>If the gallery widget is a standard widget that you can drag and drop into the sidebar, as opposed to needing... | 2012/03/29 | [
"https://wordpress.stackexchange.com/questions/47310",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14704/"
] | I have a rotating images widget I want to display on my homepage. My selected homepage is a static front page I created with several other pages to make my blog look more like a website than a blog, and then I have a separate blog page. The widget does not come with shortcode. Rather it comes with something like code t... | Try wrapping it with the [is\_front\_page()](http://codex.wordpress.org/Function_Reference/is_front_page) conditional like so:
```
<?php if ( is_front_page() ) { include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); } ?>
```
Hope this helps! |
47,354 | <p>I use this code to display Most popular posts based on view count, but I dont have images in post content I have all images attached to post via attachment (gallery)</p>
<p>How to replace this "thimthumb" thumbnail with first attachment of this listed posts?</p>
<pre><code><div id="popular" class="widgets">
... | [
{
"answer_id": 47358,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 0,
"selected": false,
"text": "<p>You must fetch <a href=\"http://codex.wordpress.org/Template_Tags/get_posts#Show_all_attachments\" rel=\"nofollow... | 2012/03/30 | [
"https://wordpress.stackexchange.com/questions/47354",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14716/"
] | I use this code to display Most popular posts based on view count, but I dont have images in post content I have all images attached to post via attachment (gallery)
How to replace this "thimthumb" thumbnail with first attachment of this listed posts?
```
<div id="popular" class="widgets">
<?php _e('<h2>P... | If I understand your question correctly, you want to retrieve the first attached image to each post & use the thumbnail size, rather than parsing the content for embedded images & using timthumb?
If so, set your thumbnail size to the required size (60x60) in the media options page, make sure you've drag n dropped the ... |
47,356 | <p>I was wondering does anyone know how I can modify the search so it searches a taxonomy?</p>
<p>at the moment it just looks for a product title, but not the taxonomy assigned to the post.</p>
<p>Please help</p>
| [
{
"answer_id": 47358,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 0,
"selected": false,
"text": "<p>You must fetch <a href=\"http://codex.wordpress.org/Template_Tags/get_posts#Show_all_attachments\" rel=\"nofollow... | 2012/03/30 | [
"https://wordpress.stackexchange.com/questions/47356",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12033/"
] | I was wondering does anyone know how I can modify the search so it searches a taxonomy?
at the moment it just looks for a product title, but not the taxonomy assigned to the post.
Please help | If I understand your question correctly, you want to retrieve the first attached image to each post & use the thumbnail size, rather than parsing the content for embedded images & using timthumb?
If so, set your thumbnail size to the required size (60x60) in the media options page, make sure you've drag n dropped the ... |
47,378 | <p>I am trying for hours and I managed to get full slug for parent of sub-page when I am on 3rd level sub-page I can not get slug of the top parent page. Example
domain.com/top_page/sub_page/sub_sub_page</p>
<p>I need to get full slug 'top_page/sub_page/sub_sub_page'</p>
<p>I am doing this for language sites that are... | [
{
"answer_id": 47396,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>This would replace domain.com/top_page/sub_page/sub_sub_page with /top_page/sub_page/sub_sub_page</p>\n\n<pre>... | 2012/03/30 | [
"https://wordpress.stackexchange.com/questions/47378",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14725/"
] | I am trying for hours and I managed to get full slug for parent of sub-page when I am on 3rd level sub-page I can not get slug of the top parent page. Example
domain.com/top\_page/sub\_page/sub\_sub\_page
I need to get full slug 'top\_page/sub\_page/sub\_sub\_page'
I am doing this for language sites that are on sub-d... | This would replace domain.com/top\_page/sub\_page/sub\_sub\_page with /top\_page/sub\_page/sub\_sub\_page
```
$path = str_replace(home_url(),'',get_permalink());
``` |
47,395 | <p>Been digging into WP files for a bit and think I just might be missing something. The end-goal is to remove the <code>Theme Locations</code> metabox from the Menus screen if someone doesn't have a certain capability <code>manage_options</code>. I know, a little odd for usability, but there's only one menu and we're ... | [
{
"answer_id": 47397,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>Instead of removing the metabox, you could hide it with CSS, e.g.:</p>\n\n<pre><code>#nav-menu-theme-location... | 2012/03/30 | [
"https://wordpress.stackexchange.com/questions/47395",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9605/"
] | Been digging into WP files for a bit and think I just might be missing something. The end-goal is to remove the `Theme Locations` metabox from the Menus screen if someone doesn't have a certain capability `manage_options`. I know, a little odd for usability, but there's only one menu and we're trying to make this harde... | The box gets added in wp\_nav\_menu\_setup(), so you'll have to remove it sometime after that and before it's being output later in nav-menus.php. There don't seem to be any action hooks you can use there, but admin-header.php has a few. You could try this:
```
add_action( 'admin_head-nav-menus.php', 'roots_remove_nav... |
47,405 | <p>If I have a user's ID, what's the best way for me to get the title of that user's most recent post?</p>
| [
{
"answer_id": 47408,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>The best way would be a custom SQL query, but you can simply use the native functions like <code>get_posts()<... | 2012/03/30 | [
"https://wordpress.stackexchange.com/questions/47405",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12476/"
] | If I have a user's ID, what's the best way for me to get the title of that user's most recent post? | You just set the 'author' parameter in a [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query) query or [`get_posts`](http://codex.wordpress.org/Template_Tags/get_posts) (which accepts the same parameters):
```
$recent = get_posts(array(
'author'=>1,
'orderby'=>'date',
'order'=>'desc',
'num... |
47,412 | <p>I've made a custom walker to use with wp_list_pages to modify the output to have thumbnails show. The goal is to have a list show up in a page template, which lists all children with their children.</p>
<p>The walker I have below seems to work for getting the thumbnail and page title but doesn't get the url of the ... | [
{
"answer_id": 47842,
"author": "javy",
"author_id": 12870,
"author_profile": "https://wordpress.stackexchange.com/users/12870",
"pm_score": 2,
"selected": true,
"text": "<p>figured it out - in case anyone else stumbles upon this with a similar question:</p>\n\n<p>The proper walker to ex... | 2012/03/30 | [
"https://wordpress.stackexchange.com/questions/47412",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12870/"
] | I've made a custom walker to use with wp\_list\_pages to modify the output to have thumbnails show. The goal is to have a list show up in a page template, which lists all children with their children.
The walker I have below seems to work for getting the thumbnail and page title but doesn't get the url of the page. Do... | figured it out - in case anyone else stumbles upon this with a similar question:
The proper walker to extend is Walker\_Page, not Walker\_Nav\_Menu.
Walker\_page is located in /wp-includes/post-template.php (line 978). |
47,415 | <p>I would like to change the upload directory for PDF files <strong>only</strong>, not for other files. For example, the PDF files would be uploaded to <code>wp-content/uploads/pdf</code> but other files would remain in <code>wp-content/uploads/yyyy/mm</code>.</p>
<p>I know it possible to filter <code>upload_dir</cod... | [
{
"answer_id": 50805,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 4,
"selected": false,
"text": "<p>Following <em>Justice Is Cheap</em> lead, I ended adapting the functions from this plugin: <a href=\"http://... | 2012/03/30 | [
"https://wordpress.stackexchange.com/questions/47415",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5834/"
] | I would like to change the upload directory for PDF files **only**, not for other files. For example, the PDF files would be uploaded to `wp-content/uploads/pdf` but other files would remain in `wp-content/uploads/yyyy/mm`.
I know it possible to filter `upload_dir` but I don't know how to do it with file types/mimes.
... | Following *Justice Is Cheap* lead, I ended adapting the functions from this plugin: <http://wordpress.org/extend/plugins/custom-upload-dir/>
```
<?php
/*
* Change upload directory for PDF files
* Only works in WordPress 3.3+
*/
add_filter('wp_handle_upload_prefilter', 'wpse47415_pre_upload');
add_filter('wp_hand... |
47,422 | <p>how to set category name for post:
this is my code ,this is not working ,why?</p>
<pre><code> $post_title = $vname;
$categ='category name';
$post_content = '[newpage link="'.$videos.'"]';
$new_post = array(
'ID' => '',
'post_author' => $user->ID,
'post_category' => $... | [
{
"answer_id": 47423,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 2,
"selected": true,
"text": "<p>The <code>post_category</code> parameter has to be an array of IDs (<em>int</em>).</p>\n\n<p><a href=\"http://... | 2012/03/30 | [
"https://wordpress.stackexchange.com/questions/47422",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14179/"
] | how to set category name for post:
this is my code ,this is not working ,why?
```
$post_title = $vname;
$categ='category name';
$post_content = '[newpage link="'.$videos.'"]';
$new_post = array(
'ID' => '',
'post_author' => $user->ID,
'post_category' => $categ,
'post_content' =... | The `post_category` parameter has to be an array of IDs (*int*).
<http://codex.wordpress.org/Function_Reference/wp_insert_post#Parameters>
Try [`get_category_by_slug`](http://codex.wordpress.org/Function_Reference/get_category_by_slug) to get the ID, then use it.
```
$category = get_category_by_slug( 'your-category'... |
47,427 | <p>We have IIS 7.5 and we've installed WordPress (v3.3.1) through the Microsoft Web Platform installer (http://www.microsoft.com/web/wordpress).</p>
<p>All works fine when we load WP locally (e.g. <a href="http://localhost/mywordpresssite" rel="nofollow">http://localhost/mywordpresssite</a>), the graphics load fine. B... | [
{
"answer_id": 47432,
"author": "k3davis",
"author_id": 14642,
"author_profile": "https://wordpress.stackexchange.com/users/14642",
"pm_score": 2,
"selected": true,
"text": "<p>Check that your WordPress Address and Site Address are correct under Settings > General. ie., if you want it to... | 2012/03/30 | [
"https://wordpress.stackexchange.com/questions/47427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14353/"
] | We have IIS 7.5 and we've installed WordPress (v3.3.1) through the Microsoft Web Platform installer (http://www.microsoft.com/web/wordpress).
All works fine when we load WP locally (e.g. <http://localhost/mywordpresssite>), the graphics load fine. But when I enter the IP address or hostname accessing the site from a m... | Check that your WordPress Address and Site Address are correct under Settings > General. ie., if you want it to be viewable on another computer, this shouldn't say "localhost" anywhere... |
47,431 | <p>Here's my issue. I have three tables I'd like to query - states, points, and state_points.</p>
<p>States contains stateid, and name. Points: pointid, pointlat, pointlng. State_points: Stateid, Pointid.</p>
<p>I need to build an array which displays the States, and then the corresponding points. To do this I fi... | [
{
"answer_id": 47434,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Class_Reference/wpdb\" rel=\"nofollow\">http://codex.wordpress.org/Class... | 2012/03/30 | [
"https://wordpress.stackexchange.com/questions/47431",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14745/"
] | Here's my issue. I have three tables I'd like to query - states, points, and state\_points.
States contains stateid, and name. Points: pointid, pointlat, pointlng. State\_points: Stateid, Pointid.
I need to build an array which displays the States, and then the corresponding points. To do this I figured the best way ... | <http://codex.wordpress.org/Class_Reference/wpdb>
`query` returns the number of affected rows. Instead use `get_results`, which returns all the rows specified by the query. You can use the second parameter to specify how these results will be returned, either as objects or as an array etc
When dealing with sql, you s... |
47,485 | <p>I have a wordpress site, which is running fine. Beside that site, I have a forum www.mywordpresssite.com/forum running.
Now I want to integrate this forum (phpbb) into my wordpress site. </p>
<p>What I would like to do is adding a menuitem called forum, and link this to a file called forum.php, with following con... | [
{
"answer_id": 47500,
"author": "xaedes",
"author_id": 9518,
"author_profile": "https://wordpress.stackexchange.com/users/9518",
"pm_score": 1,
"selected": false,
"text": "<p>You can use this file as custom template file.\n<a href=\"http://codex.wordpress.org/Pages#Page_Templates\" rel=\... | 2012/03/31 | [
"https://wordpress.stackexchange.com/questions/47485",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14770/"
] | I have a wordpress site, which is running fine. Beside that site, I have a forum www.mywordpresssite.com/forum running.
Now I want to integrate this forum (phpbb) into my wordpress site.
What I would like to do is adding a menuitem called forum, and link this to a file called forum.php, with following content:
```
<... | Use [bbPress](http://bbpress.org/). It has a fully-built backend, and allows you to assign specific users to moderate the forum, and not access the rest of the website. It's the quickest, easiest, and probably most secure solution. |
47,492 | <p>In my plugin in need to create two widget.
One is :social rank" another is "Profile Rank".</p>
<p>This is the code which i am using here.</p>
<pre><code> <?php
add_action( 'widgets_init', 'src_load_widgets' );
function src_load_widgets() {
register_widget( 'Widget_SRC' );
}
function src_load_widgets... | [
{
"answer_id": 47494,
"author": "Ajay Patel",
"author_id": 12261,
"author_profile": "https://wordpress.stackexchange.com/users/12261",
"pm_score": 0,
"selected": false,
"text": "<p>Ohh my mistake </p>\n\n<pre><code>function load_widgets() {\n register_widget( 'Widget_SRC' );\n regi... | 2012/03/31 | [
"https://wordpress.stackexchange.com/questions/47492",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12261/"
] | In my plugin in need to create two widget.
One is :social rank" another is "Profile Rank".
This is the code which i am using here.
```
<?php
add_action( 'widgets_init', 'src_load_widgets' );
function src_load_widgets() {
register_widget( 'Widget_SRC' );
}
function src_load_widgets() {
register_widget... | There is absolutely no problem with registering several widgets inside one file. Widgets are separate classes, and unlike other programming languages, PHP will have no problem with your declaring two classes inside one file.
```
add_action( 'widgets_init', 'src_load_widgets' );
function src_load_widgets() {
regis... |
47,498 | <p>I just recently moved to my new CentOS server and I did a fresh installed and before I use to be with my Mac OS [Xserver]</p>
<p>So what happen I was thinking about CDN and though that maybe this will somehow apply to some of the condition where it will make my site load faster because this is from another server.<... | [
{
"answer_id": 47494,
"author": "Ajay Patel",
"author_id": 12261,
"author_profile": "https://wordpress.stackexchange.com/users/12261",
"pm_score": 0,
"selected": false,
"text": "<p>Ohh my mistake </p>\n\n<pre><code>function load_widgets() {\n register_widget( 'Widget_SRC' );\n regi... | 2012/03/31 | [
"https://wordpress.stackexchange.com/questions/47498",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6390/"
] | I just recently moved to my new CentOS server and I did a fresh installed and before I use to be with my Mac OS [Xserver]
So what happen I was thinking about CDN and though that maybe this will somehow apply to some of the condition where it will make my site load faster because this is from another server.
How or is... | There is absolutely no problem with registering several widgets inside one file. Widgets are separate classes, and unlike other programming languages, PHP will have no problem with your declaring two classes inside one file.
```
add_action( 'widgets_init', 'src_load_widgets' );
function src_load_widgets() {
regis... |
47,501 | <p>Is there a WordPress plugin that can auto execute php script on a specific time? Or an other way to do this?</p>
<p>At this moment I execute every 30 minutes (from 00:00 to 08:00) a php script with cpanel (Cronjobs). Is there some way to handle this in WordPress itself?</p>
| [
{
"answer_id": 47494,
"author": "Ajay Patel",
"author_id": 12261,
"author_profile": "https://wordpress.stackexchange.com/users/12261",
"pm_score": 0,
"selected": false,
"text": "<p>Ohh my mistake </p>\n\n<pre><code>function load_widgets() {\n register_widget( 'Widget_SRC' );\n regi... | 2012/03/31 | [
"https://wordpress.stackexchange.com/questions/47501",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14383/"
] | Is there a WordPress plugin that can auto execute php script on a specific time? Or an other way to do this?
At this moment I execute every 30 minutes (from 00:00 to 08:00) a php script with cpanel (Cronjobs). Is there some way to handle this in WordPress itself? | There is absolutely no problem with registering several widgets inside one file. Widgets are separate classes, and unlike other programming languages, PHP will have no problem with your declaring two classes inside one file.
```
add_action( 'widgets_init', 'src_load_widgets' );
function src_load_widgets() {
regis... |
47,522 | <p>I'm using the following code with <code>query_posts</code> to put together a custom search:</p>
<pre><code>$args = array(
'post_type' => 'species',
'meta_query' => $meta_query,
'tax_query' => $tax_query
);
</code></pre>
<p><code>$meta_query</code> is put together with a few segments of code li... | [
{
"answer_id": 47527,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 1,
"selected": false,
"text": "<p><strong>Add this to your query:</strong></p>\n\n<pre><code>'paged' => get_query_var('paged')\n</code></pre>\n\... | 2012/03/31 | [
"https://wordpress.stackexchange.com/questions/47522",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6344/"
] | I'm using the following code with `query_posts` to put together a custom search:
```
$args = array(
'post_type' => 'species',
'meta_query' => $meta_query,
'tax_query' => $tax_query
);
```
`$meta_query` is put together with a few segments of code like this:
```
if (!empty($_POST["s_aquarium_H"])) {
$... | In the end, this was nothing to do with pagination - as such.
I needed to change my entire form to `GET` method and `$_REQUEST` variables rather than `POST` and `$_POST`. |
47,525 | <p>Im working on my first wordpress blog and trying to avoid plugins if at all possible for a lot of what doesn't really need to have a plugin. I am slightly familiar with php ( I don't understand it but I know where to put it and what file should go where). I understand the how to change the theme files around, CSS &a... | [
{
"answer_id": 47526,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>Inside your post loop:</p>\n\n<pre><code><div class=\"recent-post\">\n <div class=\"thumbnail\"&g... | 2012/03/31 | [
"https://wordpress.stackexchange.com/questions/47525",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25108/"
] | Im working on my first wordpress blog and trying to avoid plugins if at all possible for a lot of what doesn't really need to have a plugin. I am slightly familiar with php ( I don't understand it but I know where to put it and what file should go where). I understand the how to change the theme files around, CSS & HTM... | Inside your post loop:
```
<div class="recent-post">
<div class="thumbnail">
<?php
if(has_post_thumbnail()) {
the_post_thumbnail();
} else {
// show a default image if no featured image is specified
echo '<img src="'.get_bloginfo("template_url").'/images/... |
47,531 | <p>This is a really strange issue that I cannot seem to solve. I have several forms (login, registration, and other) outputted on a site via short codes. When the forms are submitted, their data is processed via an "init" hook that listens for the $_POST data.</p>
<p>When the forms are submitted in IE 9, all fields ar... | [
{
"answer_id": 47526,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>Inside your post loop:</p>\n\n<pre><code><div class=\"recent-post\">\n <div class=\"thumbnail\"&g... | 2012/03/31 | [
"https://wordpress.stackexchange.com/questions/47531",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2418/"
] | This is a really strange issue that I cannot seem to solve. I have several forms (login, registration, and other) outputted on a site via short codes. When the forms are submitted, their data is processed via an "init" hook that listens for the $\_POST data.
When the forms are submitted in IE 9, all fields are cleared... | Inside your post loop:
```
<div class="recent-post">
<div class="thumbnail">
<?php
if(has_post_thumbnail()) {
the_post_thumbnail();
} else {
// show a default image if no featured image is specified
echo '<img src="'.get_bloginfo("template_url").'/images/... |
47,548 | <p>I have created a page with the php comment at the start of the file:</p>
<pre><code><?php
/*
Template Name=> Team Detail
*/
?>
</code></pre>
<p>and saved it as team-detail.php in my theme's root directory. Now when I want to add a page with this as the template for that page, I cannot see this template in... | [
{
"answer_id": 47549,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>1) make sure you uploaded the file to your server.</p>\n\n<p>2) then try to change it to:</p>\n\n<pre><code><?p... | 2012/03/27 | [
"https://wordpress.stackexchange.com/questions/47548",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have created a page with the php comment at the start of the file:
```
<?php
/*
Template Name=> Team Detail
*/
?>
```
and saved it as team-detail.php in my theme's root directory. Now when I want to add a page with this as the template for that page, I cannot see this template in the admin area under ->add new pag... | First of all, change `Template Name=>` to `Template Name:`. Also, when you say the themes root do you mean `wp-content/themes`? If so, keep all your files in a folder specific to your theme i.e `wp-content/themes/myTheme`.
If you've done that, make sure you've got a stylesheet in your theme and that your [permissions]... |
47,565 | <p>I hope someone could realy help me...</p>
<p>I get this error message : </p>
<pre><code>"error Warning: preg_match_all() [function.preg-match-all]: Unknown modifier 'I' in /home/sulistyo/public_html/wp-content/plugins/wordpress-seo/admin/linkdex/linkdex.php on line 476"
</code></pre>
<p>when I enter/write a focu... | [
{
"answer_id": 47604,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 1,
"selected": false,
"text": "<p>I browsed through all the versions available here <a href=\"http://plugins.trac.wordpress.org/browser/wordpre... | 2012/04/01 | [
"https://wordpress.stackexchange.com/questions/47565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14786/"
] | I hope someone could realy help me...
I get this error message :
```
"error Warning: preg_match_all() [function.preg-match-all]: Unknown modifier 'I' in /home/sulistyo/public_html/wp-content/plugins/wordpress-seo/admin/linkdex/linkdex.php on line 476"
```
when I enter/write a focus keyword on wordpress seo meta b... | I browsed through all the versions available here <http://plugins.trac.wordpress.org/browser/wordpress-seo/tags/> and nowhere is there any "I" modifier. The "I" modifier is [obviously](http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php) invalid, thus the error. Updating the plugin will most certainly sol... |
47,578 | <p>Is there a way to get the widget title outside of the widget area like this:</p>
<pre><code><ul>
<li>
<h2 class="widgettitle">The title here</h2>
<div class=""widget>
<!-- any markup here -->
</div>
</li>
</ul>
</code></pre>
<p>... | [
{
"answer_id": 47584,
"author": "Jamie",
"author_id": 14761,
"author_profile": "https://wordpress.stackexchange.com/users/14761",
"pm_score": 0,
"selected": false,
"text": "<p>you should be able to use the code for widgets to get done what you want done. Read this page <a href=\"http://c... | 2012/04/01 | [
"https://wordpress.stackexchange.com/questions/47578",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14490/"
] | Is there a way to get the widget title outside of the widget area like this:
```
<ul>
<li>
<h2 class="widgettitle">The title here</h2>
<div class=""widget>
<!-- any markup here -->
</div>
</li>
</ul>
```
instead of this:
```
<ul>
<li>
<div class=""widget>
<h2 class="w... | this is the solution to wrap the content after the title like this
```
'before_widget' => '<li>',
'after_widget' => '</div></li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2><div class="widgetcontent">' ); ?>
```
the important markup is the `<div class="widgetcontent>"` in the after\_ti... |
47,579 | <p>Im using masonry with infinite scroll to display posts in a loop. I set the post per page which works great on the index page but when I place that same loop on a single page or a buddypress profile page then it only displays the first set of post per page and when I scroll down it returns no more posts to show. Her... | [
{
"answer_id": 47673,
"author": "Nick",
"author_id": 14061,
"author_profile": "https://wordpress.stackexchange.com/users/14061",
"pm_score": -1,
"selected": false,
"text": "<p>Add <code>posts_per_page=-1</code> to your <code>query_posts()</code>.</p>\n\n<p>This will query all posts and b... | 2012/04/01 | [
"https://wordpress.stackexchange.com/questions/47579",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12700/"
] | Im using masonry with infinite scroll to display posts in a loop. I set the post per page which works great on the index page but when I place that same loop on a single page or a buddypress profile page then it only displays the first set of post per page and when I scroll down it returns no more posts to show. Heres ... | Okay I've found the solution infinite scroll not working on certain pages. It seems that it is set by default to not load on any Page or Single. You can edit the plugin easily to remove the checks but be aware that upgrading the plugin in future will override the changes and you'll need to repeat them (unless they add ... |
47,580 | <p>I'm using the Media Library on the front end of my website and I'd like to stop users from being able to spam my server by uploading an unlimited number of files.</p>
<p>As such, I'd like to do one or maybe all of the below:</p>
<ol>
<li>Give users a maximum upload capacity; i.e. users can upload up to 10 megabyte... | [
{
"answer_id": 47605,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 5,
"selected": true,
"text": "<p>Assuming that you're providing upload functionality via WordPress' native functions, lik <a href=\"http://code... | 2012/04/01 | [
"https://wordpress.stackexchange.com/questions/47580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6344/"
] | I'm using the Media Library on the front end of my website and I'd like to stop users from being able to spam my server by uploading an unlimited number of files.
As such, I'd like to do one or maybe all of the below:
1. Give users a maximum upload capacity; i.e. users can upload up to 10 megabytes of files.
2. Limit... | Assuming that you're providing upload functionality via WordPress' native functions, lik [`wp_handle_upload`](http://codex.wordpress.org/Function_Reference/wp_handle_upload) or something more high-level, we come to the conclusion that several hooks are going to be pulled.
<http://core.trac.wordpress.org/browser/tags/3... |
47,582 | <p>I'm using the following code for upload in multiple mextaboxes in a post or page admin section. Works for metaboxes but breaks the TinyMCE insert image. I want to know please how I can achieve this without breaking the TinyMCE. Off course the issue comes when I overwrite the windows.send_to_editor function. </p>
<p... | [
{
"answer_id": 47605,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 5,
"selected": true,
"text": "<p>Assuming that you're providing upload functionality via WordPress' native functions, lik <a href=\"http://code... | 2012/04/01 | [
"https://wordpress.stackexchange.com/questions/47582",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13813/"
] | I'm using the following code for upload in multiple mextaboxes in a post or page admin section. Works for metaboxes but breaks the TinyMCE insert image. I want to know please how I can achieve this without breaking the TinyMCE. Off course the issue comes when I overwrite the windows.send\_to\_editor function.
```
jQu... | Assuming that you're providing upload functionality via WordPress' native functions, lik [`wp_handle_upload`](http://codex.wordpress.org/Function_Reference/wp_handle_upload) or something more high-level, we come to the conclusion that several hooks are going to be pulled.
<http://core.trac.wordpress.org/browser/tags/3... |
47,588 | <p>There is no option for switching html to visual mode in add new post page of my admin panel</p>
<p>there is no js error in console
reinstalled WP from WP updates admin panel too,
and there are no 404 on any js file either</p>
<p>home page url is <a href="http://bankpo.in" rel="nofollow">http://bankpo.in</a></p>
... | [
{
"answer_id": 47605,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 5,
"selected": true,
"text": "<p>Assuming that you're providing upload functionality via WordPress' native functions, lik <a href=\"http://code... | 2012/04/01 | [
"https://wordpress.stackexchange.com/questions/47588",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14792/"
] | There is no option for switching html to visual mode in add new post page of my admin panel
there is no js error in console
reinstalled WP from WP updates admin panel too,
and there are no 404 on any js file either
home page url is <http://bankpo.in>
couldnt upload image so giving a link for screenshot
<http://img... | Assuming that you're providing upload functionality via WordPress' native functions, lik [`wp_handle_upload`](http://codex.wordpress.org/Function_Reference/wp_handle_upload) or something more high-level, we come to the conclusion that several hooks are going to be pulled.
<http://core.trac.wordpress.org/browser/tags/3... |
47,592 | <p>I just read "How to create option page for wordpress theme" in <a href="http://wp.tutsplus.com/tutorials/using-the-settings-api-part-2-create-a-top-level-admin-menu/" rel="nofollow">wp.tutsplus.com</a> - I have a problem with getting categories . </p>
<p>there is two parts to my question</p>
<p><strong>- Part A - ... | [
{
"answer_id": 47605,
"author": "soulseekah",
"author_id": 9480,
"author_profile": "https://wordpress.stackexchange.com/users/9480",
"pm_score": 5,
"selected": true,
"text": "<p>Assuming that you're providing upload functionality via WordPress' native functions, lik <a href=\"http://code... | 2012/04/01 | [
"https://wordpress.stackexchange.com/questions/47592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14793/"
] | I just read "How to create option page for wordpress theme" in [wp.tutsplus.com](http://wp.tutsplus.com/tutorials/using-the-settings-api-part-2-create-a-top-level-admin-menu/) - I have a problem with getting categories .
there is two parts to my question
**- Part A - Get category slug and display it**
In this tuto... | Assuming that you're providing upload functionality via WordPress' native functions, lik [`wp_handle_upload`](http://codex.wordpress.org/Function_Reference/wp_handle_upload) or something more high-level, we come to the conclusion that several hooks are going to be pulled.
<http://core.trac.wordpress.org/browser/tags/3... |
47,597 | <p>I currently have a custom fields for enter State name. I want to use the autocomplete from jquery-ui in this fields. However, I failed.</p>
<p>This is the first time I using jquery-ui, and I am not so familiar with php and jquery. I hope that you guys can give me some advises. </p>
<p>This was the code that I use:... | [
{
"answer_id": 47602,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": false,
"text": "<p>Your first example works fine with some minor alteration ( I will add it below), as can be seen here, <a href=\"htt... | 2012/04/01 | [
"https://wordpress.stackexchange.com/questions/47597",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14728/"
] | I currently have a custom fields for enter State name. I want to use the autocomplete from jquery-ui in this fields. However, I failed.
This is the first time I using jquery-ui, and I am not so familiar with php and jquery. I hope that you guys can give me some advises.
This was the code that I use:
```
(function (... | Your first example works fine with some minor alteration ( I will add it below), as can be seen here, <http://jsfiddle.net/cDtv4/>.
What you need to do is make sure the actual jquery and jquery-ui (and possibly the jquery-ui.css) scripts are loading on the page you want this to work on.
You can do this by viewing you... |
47,606 | <p>I've been trying to load scripts and styles for a WordPress widget with the following conditions...</p>
<ol>
<li>The scripts MUST load in the HEAD (else they break).</li>
<li>The scripts must ONLY load when the widget actually displays (they're quite heavy).</li>
</ol>
<p>I've done a lot of searching, and this see... | [
{
"answer_id": 47610,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": false,
"text": "<p>Wordpress as a nice function <code>is_active_widget</code> that you can use in your __construct and test if t... | 2012/04/01 | [
"https://wordpress.stackexchange.com/questions/47606",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14340/"
] | I've been trying to load scripts and styles for a WordPress widget with the following conditions...
1. The scripts MUST load in the HEAD (else they break).
2. The scripts must ONLY load when the widget actually displays (they're quite heavy).
I've done a lot of searching, and this seems to be a common (unsolved) prob... | Wordpress as a nice function `is_active_widget` that you can use in your \_\_construct and test if the widget is present in the current page and add your scripts/styles based on that ex:
```
function __construct() {
parent::__construct(__CLASS__, 'BasicWidget', array(
'classname' => __CLASS__,
'des... |
47,616 | <p>I was wondering if it was possible to get the first two paragraphs and the feature image in the excerpt.</p>
<p>I currently have the first 100 words, but would like the the first two paragraphs.</p>
<p>What I want to achieve is something like Smashing Magazine, where the first paragraph is one font, and the second... | [
{
"answer_id": 47619,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 0,
"selected": false,
"text": "<p>AFAIK, you can only set the number of words that come in the excerpt using the <code>excerpt_length</co... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47616",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14801/"
] | I was wondering if it was possible to get the first two paragraphs and the feature image in the excerpt.
I currently have the first 100 words, but would like the the first two paragraphs.
What I want to achieve is something like Smashing Magazine, where the first paragraph is one font, and the second is the base, whi... | Check out this tutorial: <http://jshamsul.com/2012/02/08/wordpress-get-first-paragraph-from-post/>
There the author puts all the paragraphs into array. So you could possibly pull out the first, second, thrid... paragraphs from that array.
As for smashingmagazine.com styling the first paragraph. They do it with CSS :f... |
47,618 | <p>How to get this to load last?</p>
<pre><code> <script type="text/javascript">
jQuery(document).ready(function(){
jQuery("div.domTip_tipBody").mouseover(function(){
jQuery("#yyy a.tippy_link").css("background-color","yellow");});
jQuery("div.domTip_tipBody").mouseout(function(){
jQuery("#yyy a... | [
{
"answer_id": 47620,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 0,
"selected": false,
"text": "<p>You can simply add the script to footer.php and it will probably work, but it's not the best way to avoid jQu... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13698/"
] | How to get this to load last?
```
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("div.domTip_tipBody").mouseover(function(){
jQuery("#yyy a.tippy_link").css("background-color","yellow");});
jQuery("div.domTip_tipBody").mouseout(function(){
jQuery("#yyy a.tippy_link").css("b... | ```
add_action('wp_footer','myscript_in_footer');
function myscript_in_footer(){
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("div.domTip_tipBody").mouseover(function(){
jQuery("#yyy a.tippy_link").css("background-color","yellow");});
jQuery("div.domTip_tipBody").mouseout(f... |
47,628 | <p>I've been googleing around but failed to find a solution for my need.
I'm using wordpress 3.0 and TwentyEleven theme as default pack.
In the Dashboard -> appearance->menus that allow user can create menu items from Pages,Categories,and custom link.
Now I want to add a box like those boxes above but it would list... | [
{
"answer_id": 47629,
"author": "Matthew Darnell",
"author_id": 14112,
"author_profile": "https://wordpress.stackexchange.com/users/14112",
"pm_score": 1,
"selected": false,
"text": "<p>From the WordPress Codex Site:</p>\n<blockquote>\n<p>Custom Post Types and Taxonomies</p>\n<p>If you h... | 2012/02/24 | [
"https://wordpress.stackexchange.com/questions/47628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I've been googleing around but failed to find a solution for my need.
I'm using wordpress 3.0 and TwentyEleven theme as default pack.
In the Dashboard -> appearance->menus that allow user can create menu items from Pages,Categories,and custom link.
Now I want to add a box like those boxes above but it would list my ... | Just as a follow up for anybody looking to add their own meta boxes to the menu screen, you can do it by using 'nav-menus' for the post type:
```
add_action( 'admin_init', 'my_add_meta_box' );
function my_add_meta_box() {
add_meta_box( 'custom-meta-box', __('My meta box'), 'my_nav_menu_item_link_meta_box', 'nav-m... |
47,638 | <p>I was trying to remove the <strong>rel=prev</strong> and <strong>rel=next</strong> tags from my website as my SEO gut suggested. I found those functions which perfectly do the magic:</p>
<pre><code>remove_action('wp_head', 'start_post_rel_link', 10, 0 );
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 1... | [
{
"answer_id": 47646,
"author": "SplinterReality",
"author_id": 14810,
"author_profile": "https://wordpress.stackexchange.com/users/14810",
"pm_score": 0,
"selected": false,
"text": "<p>Try the <a href=\"http://codex.wordpress.org/Function_Reference/is_category\" rel=\"nofollow\">is_cate... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47638",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7730/"
] | I was trying to remove the **rel=prev** and **rel=next** tags from my website as my SEO gut suggested. I found those functions which perfectly do the magic:
```
remove_action('wp_head', 'start_post_rel_link', 10, 0 );
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
```
however, after a while my S... | Not entirely sure if I agree with the explanation of your SEO guy as rel=prev and rel=next are used for **paginated** archives.
Of course categories can be one, but also your blog if it'd contain multiple pages.
Anyways, here's what I'm currently using:
```
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head'... |
47,641 | <p>I want to add widgets to my wordpress site programmatically. I tried the following code from the <a href="http://codex.wordpress.org/Function_Reference/register_widget" rel="nofollow noreferrer">codex docs</a>:</p>
<pre><code>class MyNewWidget extends WP_Widget {
function MyNewWidget() {
// Instantiate... | [
{
"answer_id": 49233,
"author": "Adam Seabridge",
"author_id": 13381,
"author_profile": "https://wordpress.stackexchange.com/users/13381",
"pm_score": 0,
"selected": false,
"text": "<p>here is an example that should work with the latest version of wordpress:</p>\n\n<pre><code> class MyNe... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47641",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14518/"
] | I want to add widgets to my wordpress site programmatically. I tried the following code from the [codex docs](http://codex.wordpress.org/Function_Reference/register_widget):
```
class MyNewWidget extends WP_Widget {
function MyNewWidget() {
// Instantiate the parent object
parent::__construct( fal... | Because your code is just like prototype, it doesn't display anything.
That's why your are not seeing anything in dashboard.
```
/**
* Adds Foo_Widget widget.
*/
class Foo_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*/
function __construct() {
parent::__construct(
... |
47,647 | <p>I have over 200 customposts and each has customfields (add_city, add_state, add_location) in each custompost is googlmap with customfield (geo_longitude geo_latitude) Help please, display in googlmap multiple markers, depending on more meta_key meta_value.
To sort kustomposts I use this beautiful code :</p>
<pre><... | [
{
"answer_id": 47678,
"author": "Nick",
"author_id": 14061,
"author_profile": "https://wordpress.stackexchange.com/users/14061",
"pm_score": 1,
"selected": false,
"text": "<p>The only way to get multiple markers on a map is to use the Google Maps API.\n<a href=\"https://developers.google... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10797/"
] | I have over 200 customposts and each has customfields (add\_city, add\_state, add\_location) in each custompost is googlmap with customfield (geo\_longitude geo\_latitude) Help please, display in googlmap multiple markers, depending on more meta\_key meta\_value.
To sort kustomposts I use this beautiful code :
```
<?p... | The only way to get multiple markers on a map is to use the Google Maps API.
<https://developers.google.com/maps/documentation/javascript/tutorial>.
The way you are referencing through an iframe only allows one marker(one location). |
47,657 | <p>I created some custom login/registration template pages and now I want that every request to wp-login.php to be redirected to a custom url. Now I have something like this:</p>
<pre><code>add_action('init','possibly_redirect');
function possibly_redirect(){
global $pagenow;
if( '/wp-login.php' == $pagenow ) {
wp_re... | [
{
"answer_id": 47933,
"author": "John Smith",
"author_id": 14811,
"author_profile": "https://wordpress.stackexchange.com/users/14811",
"pm_score": 2,
"selected": false,
"text": "<p>Actually I found the right way to do this.</p>\n\n<p>For redirect wordpress login to a custom url:</p>\n\n<... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47657",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14811/"
] | I created some custom login/registration template pages and now I want that every request to wp-login.php to be redirected to a custom url. Now I have something like this:
```
add_action('init','possibly_redirect');
function possibly_redirect(){
global $pagenow;
if( '/wp-login.php' == $pagenow ) {
wp_redirect('/login... | To restrict direct access only for 'wp-login.php', without POST or GET request (useful for custom ajax login forms), I use the advanced function:
```
function possibly_redirect(){
global $pagenow;
if( 'wp-login.php' == $pagenow ) {
if ( isset( $_POST['wp-submit'] ) || // in case of LOGIN
( isset($_GET[... |
47,669 | <p>I'm writing some code that makes extensive use of custom post types- and I'm looking for a means of programatically adding a category to a defined custom post type, and then accessing its category ID. </p>
<p>I had a poke around but I can't seem to find a robust means of achieving this - wp_create_category would be... | [
{
"answer_id": 47672,
"author": "Arvind Pal",
"author_id": 12858,
"author_profile": "https://wordpress.stackexchange.com/users/12858",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Please put this code in theme functions.php</strong></p>\n\n<pre><code>function post_type_discog() ... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47669",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7434/"
] | I'm writing some code that makes extensive use of custom post types- and I'm looking for a means of programatically adding a category to a defined custom post type, and then accessing its category ID.
I had a poke around but I can't seem to find a robust means of achieving this - wp\_create\_category would be the obv... | if you need to pre-create some terms you can add the following into the init function that registers the taxonomy. it will create the term foo in the recordings taxonomy
```
if (!term_exists( 'foo', 'recordings') ){
wp_insert_term( 'foo', 'recordings' );
})
``` |
47,691 | <p>Is there a plugin that would restrict non-admin users to only existing tags? I could have used categories for this, but it will be difficult to display with a large population (~1000) of tags. </p>
| [
{
"answer_id": 48598,
"author": "Travis Pflanz",
"author_id": 14558,
"author_profile": "https://wordpress.stackexchange.com/users/14558",
"pm_score": 3,
"selected": true,
"text": "<p>If you do not already have your tags created, you can use the \"Bulk Add Tags\" plugin - <a href=\"http:/... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47691",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12388/"
] | Is there a plugin that would restrict non-admin users to only existing tags? I could have used categories for this, but it will be difficult to display with a large population (~1000) of tags. | If you do not already have your tags created, you can use the "Bulk Add Tags" plugin - <http://wordpress.org/extend/plugins/bulk-add-tags/>
Then to restrict all users except admins from adding new tags via the "New Post" screen, add this code to your theme's functions.php file:
```
//Hide Post Page Options from all e... |
47,697 | <p>Is there anyway to remove the 'W' icon from the WordPress toolbar located at the top, when Authors login?</p>
<p>I know that an author can uncheck an option for an individual user, but we need to do this for all users?</p>
| [
{
"answer_id": 47699,
"author": "Dave Hunt",
"author_id": 1769,
"author_profile": "https://wordpress.stackexchange.com/users/1769",
"pm_score": 0,
"selected": false,
"text": "<p>To just remove the logo from the toolbar, add this to your stylesheet:</p>\n\n<pre><code>#wp-admin-bar-wp-logo... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47697",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14353/"
] | Is there anyway to remove the 'W' icon from the WordPress toolbar located at the top, when Authors login?
I know that an author can uncheck an option for an individual user, but we need to do this for all users? | ```
function mytheme_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
}
add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
```
For specific user roles you can wrap the `add_action` in a conditional, something like
```
if(current_user_can('editor')){
add_acti... |
47,708 | <p>Is there anyway to remove the 'Press This' tool from WordPress for all users?</p>
<p>Thanks!</p>
| [
{
"answer_id": 47725,
"author": "William",
"author_id": 9942,
"author_profile": "https://wordpress.stackexchange.com/users/9942",
"pm_score": 2,
"selected": false,
"text": "<p>Adding the following action essentially disables the press-this functionality, at least best I can tell:</p>\n\n... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14353/"
] | Is there anyway to remove the 'Press This' tool from WordPress for all users?
Thanks! | Adding the following action essentially disables the press-this functionality, at least best I can tell:
```
add_action('load-press-this.php', function(){ wp_die('"Press This" functionality has been disabled.'); });
```
The option will still be there on the admin dashboard page, but attempting to use it will fail. |
47,726 | <p>Would like to remove <code><dc:creator></code> or edit it to be a static value without editing core Wordpress files. Preferably as a function. </p>
| [
{
"answer_id": 47728,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 0,
"selected": false,
"text": "<p>Unfortunately, that element is hard-coded into WordPress core. Take a look at <code>/wp-includes/feed-rss2.php</code... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47726",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5302/"
] | Would like to remove `<dc:creator>` or edit it to be a static value without editing core Wordpress files. Preferably as a function. | 1. Copy `/wp-includes/feed-rss2.php` to your theme folder
2. Edit it and make whatever changes you desire (e.g. removing the line for `dc:creator`)
3. in your theme's `functions.php` file, add the following function:
```php
remove_all_actions( 'do_feed_rss2' );
function create_my_custom_feed() {
load_template(... |
47,731 | <p>I used the following to remove certain menus for the "editor"</p>
<pre><code>function remove_menus () {
global $menu;
if( (current_user_can('install_themes')) ) {
$restricted = array(); } // check if admin and hide nothing
else { // for all other users
// R... | [
{
"answer_id": 47759,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 1,
"selected": false,
"text": "<p>I agree with m0r7if3r you'll want to use a role editing plugin to make it so the user can't add/edit pages. Once... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47731",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2417/"
] | I used the following to remove certain menus for the "editor"
```
function remove_menus () {
global $menu;
if( (current_user_can('install_themes')) ) {
$restricted = array(); } // check if admin and hide nothing
else { // for all other users
// Remove Tools, A... | A much simpler solution is to use `remove_menu_page` , `remove_submenu_page` and `remove_menu` (admin bar).
Your example of removing the sub-menu item for "add new" would be
```
remove_submenu_page( 'edit.php?post_type=page', 'post-new.php?post_type=page' );
```
To remove it from the admin menu bar you can use the ... |
47,743 | <p>How can I hide one admin from another in the users list?
I want to give admin permission to another person without giving him the ability to see/edit my details.</p>
| [
{
"answer_id": 48601,
"author": "Travis Pflanz",
"author_id": 14558,
"author_profile": "https://wordpress.stackexchange.com/users/14558",
"pm_score": 0,
"selected": false,
"text": "<p>My favorite method for this is to use the \"User Role Editor\" plugin - <a href=\"http://wordpress.org/e... | 2012/04/02 | [
"https://wordpress.stackexchange.com/questions/47743",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14823/"
] | How can I hide one admin from another in the users list?
I want to give admin permission to another person without giving him the ability to see/edit my details. | ```
add_action('pre_user_query','yoursite_pre_user_query');
function yoursite_pre_user_query($user_search) {
global $current_user;
$username = $current_user->user_login;
if ($username == '<USERNAME OF OTHER ADMIN>') {
global $wpdb;
$user_search->query_where = str_replace('WHERE 1=1',
"WHERE 1=1 AN... |
47,769 | <p>when creating pages, the title normally show as a link and as a title on the page it displayed when click on. My question is how do i remove the title from displaying on my page. for example when a page like "contact us" is created, the page itself will have "contact us" display in either h1 or h2 tag. how do i make... | [
{
"answer_id": 47776,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 1,
"selected": false,
"text": "<p>Set the title as 'Contact'. Then use the following code:</p>\n\n<pre><code>add_filter('the_title','remo... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47769",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14829/"
] | when creating pages, the title normally show as a link and as a title on the page it displayed when click on. My question is how do i remove the title from displaying on my page. for example when a page like "contact us" is created, the page itself will have "contact us" display in either h1 or h2 tag. how do i make th... | Set the title as 'Contact'. Then use the following code:
```
add_filter('the_title','remove_title');
function remove_title($title) {
if( !is_page('Contact') ) {
return $title;
}
}
```
Put this code in your `functions.php` file. |
47,775 | <p>I'm am displaying the last 5 posts of a custom post type 'show'.</p>
<p>This gives me the latest post first.</p>
<pre><code><?php
$args = array(
'post_type' => 'show',
'posts_per_page' => 5,
'order' => 'DESC'
);
$home_shows = new WP_Query($args);
var_dump($home_shows);
?>
</code></pr... | [
{
"answer_id": 47778,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 1,
"selected": false,
"text": "<p>Remove all the custom field mess and add an <code>'order' => 'ASC'</code> to the args array! And you... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47775",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11167/"
] | I'm am displaying the last 5 posts of a custom post type 'show'.
This gives me the latest post first.
```
<?php
$args = array(
'post_type' => 'show',
'posts_per_page' => 5,
'order' => 'DESC'
);
$home_shows = new WP_Query($args);
var_dump($home_shows);
?>
```
What I need is to actually have the earli... | I figured out what I was doing wrong. A simple beginners mistake.
Array\_reverse was working properly, but I wasn't then reassigning the reversed array back to the $home\_shows WP\_Query, hence not seeing any change.
Here is the answer, and my revised code.
```
<?php
$args = array(
... |
47,791 | <p>I've been getting a notice when I try to add a new post in two different taxonomies, in one i use a custom meta box and in the other not, however the notice appears for both when trying to add a new item, i see this: Notice: Undefined index: product_noncename in /Applications/MAMP/htdocs/site/wordpress/wp-content/th... | [
{
"answer_id": 47793,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 3,
"selected": true,
"text": "<pre><code>// Save the Metabox Data\nfunction wpt_save_product_meta($post_id, $post) {\n\n if($post->post_... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47791",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4304/"
] | I've been getting a notice when I try to add a new post in two different taxonomies, in one i use a custom meta box and in the other not, however the notice appears for both when trying to add a new item, i see this: Notice: Undefined index: product\_noncename in /Applications/MAMP/htdocs/site/wordpress/wp-content/them... | ```
// Save the Metabox Data
function wpt_save_product_meta($post_id, $post) {
if($post->post_type!='post type with metabox') {
return $post->ID;
}
// verify this came from the our screen and with proper authorization,
// because save_post can be triggered at other times
if ( !wp_verify_non... |
47,805 | <p>There is add_action() function inside function which is callback for add_shortcode(). Any idea how to remove this action with the help of custom plugin? Should I hook to any action which is called later then add_shortcode() function? I do not want to removing and re-adding shortcode, because there is huge function b... | [
{
"answer_id": 47817,
"author": "hakre",
"author_id": 178,
"author_profile": "https://wordpress.stackexchange.com/users/178",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>I do not want to removing and re-adding shortcode, because there is huge function beyond it.</p>\n</... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47805",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3316/"
] | There is add\_action() function inside function which is callback for add\_shortcode(). Any idea how to remove this action with the help of custom plugin? Should I hook to any action which is called later then add\_shortcode() function? I do not want to removing and re-adding shortcode, because there is huge function b... | OK, I found a way. Function add\_shortcode is called for the\_content filter with priority 11 (after wpautop). So, to remove custom\_function() has to be done with the help of this filter (also with priority 11). Solution?
```
add_filter( 'the_content', 'unhook_custom_function', 11 );
function unhook_custom_function( ... |
47,808 | <p>I have the following snippet of code:</p>
<pre><code><?php>$more = '.....';?>
<p class="extra"><?php the_excerpt(); ?></p>
</code></pre>
<p>What I am trying to do is append the value of $more to the_excerpt() function but unsure how to do.</p>
<p>I have tried: </p>
<pre><code><p cl... | [
{
"answer_id": 47817,
"author": "hakre",
"author_id": 178,
"author_profile": "https://wordpress.stackexchange.com/users/178",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>I do not want to removing and re-adding shortcode, because there is huge function beyond it.</p>\n</... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47808",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14248/"
] | I have the following snippet of code:
```
<?php>$more = '.....';?>
<p class="extra"><?php the_excerpt(); ?></p>
```
What I am trying to do is append the value of $more to the\_excerpt() function but unsure how to do.
I have tried:
```
<p class="extra"><?php the_excerpt() . $more; ?></p>
```
but no go.
Any hel... | OK, I found a way. Function add\_shortcode is called for the\_content filter with priority 11 (after wpautop). So, to remove custom\_function() has to be done with the help of this filter (also with priority 11). Solution?
```
add_filter( 'the_content', 'unhook_custom_function', 11 );
function unhook_custom_function( ... |
47,810 | <p>Is there a plugin available that will automatically post an excerpt of a blog post (perhaps up to the more tag) to specified social media groups/pages. So, for example, on posting an excerpt would be posted with a 'Read more' link to a user-defined Facebook group, G+ page and, possibly, twitter feed?</p>
<p>If not... | [
{
"answer_id": 47817,
"author": "hakre",
"author_id": 178,
"author_profile": "https://wordpress.stackexchange.com/users/178",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>I do not want to removing and re-adding shortcode, because there is huge function beyond it.</p>\n</... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47810",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13240/"
] | Is there a plugin available that will automatically post an excerpt of a blog post (perhaps up to the more tag) to specified social media groups/pages. So, for example, on posting an excerpt would be posted with a 'Read more' link to a user-defined Facebook group, G+ page and, possibly, twitter feed?
If not, is there ... | OK, I found a way. Function add\_shortcode is called for the\_content filter with priority 11 (after wpautop). So, to remove custom\_function() has to be done with the help of this filter (also with priority 11). Solution?
```
add_filter( 'the_content', 'unhook_custom_function', 11 );
function unhook_custom_function( ... |
47,812 | <p>As my question suggests I'm having difficulty creating a variable in the header, via functions.php and wp_head, and then calling that variable further down the page.</p>
<p>For example, in functions.php</p>
<pre><code>add_action( 'wp_footer', 'add_ran_var' );
function add_ran_var () {
$random_variable = "1... | [
{
"answer_id": 47814,
"author": "Geert",
"author_id": 4936,
"author_profile": "https://wordpress.stackexchange.com/users/4936",
"pm_score": 0,
"selected": false,
"text": "<p>A variable defined in a function is only accessible within that function. This is the case for your <code>$random_... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47812",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12027/"
] | As my question suggests I'm having difficulty creating a variable in the header, via functions.php and wp\_head, and then calling that variable further down the page.
For example, in functions.php
```
add_action( 'wp_footer', 'add_ran_var' );
function add_ran_var () {
$random_variable = "1";
}
```
And... | Before you use your `$random_variable` for the first time you need to globalize it , something like:
```
global $random_variable;
```
then next time or any time you want to access it just call globalize it again and it will be available like this:
```
global $random_variable;
//do stuff with it
``` |
47,824 | <p>Starting on <code>line 474</code> of <code>/wp-includes/admin-bar.php</code> there is a function that is declared as the following:</p>
<p><code>function wp_admin_bar_new_content_menu( $wp_admin_bar )</code></p>
<p>What it does it generates the <code>+ New</code> menu item along with any custom post types that a u... | [
{
"answer_id": 47927,
"author": "David Carroll",
"author_id": 14861,
"author_profile": "https://wordpress.stackexchange.com/users/14861",
"pm_score": 4,
"selected": true,
"text": "<p>I've not worked with the admin-bar before. However, I found your question interesting and decided to take... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47824",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9605/"
] | Starting on `line 474` of `/wp-includes/admin-bar.php` there is a function that is declared as the following:
`function wp_admin_bar_new_content_menu( $wp_admin_bar )`
What it does it generates the `+ New` menu item along with any custom post types that a user has `edit_posts` capability for. The actual top-menu item... | I've not worked with the admin-bar before. However, I found your question interesting and decided to take a look. If you add a function to handle the action hook 'admin\_bar\_menu' and set the priority to be higher than 70, you will have access to the raw admin\_bar\_menu nodes where you can modify the properties you a... |
47,828 | <p>I'm trying to add some meta fields to a <a href="http://getshopped.org/" rel="nofollow" title="WordPress Shopping Cart">WPSC</a> product using the following code:</p>
<pre><code>/**
* data callback
*/
function abc_callback($object, $box)
{
echo 'callback executed!';
}
/**
* add custom fields
*/
function ab... | [
{
"answer_id": 47830,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Use the action <code>'add_meta_boxes'</code> to add a meta box. See my <a href=\"https://gist.github.com/1748108\" rel... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47828",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14633/"
] | I'm trying to add some meta fields to a [WPSC](http://getshopped.org/ "WordPress Shopping Cart") product using the following code:
```
/**
* data callback
*/
function abc_callback($object, $box)
{
echo 'callback executed!';
}
/**
* add custom fields
*/
function abc_load_post($post_id)
{
add_meta_box('abc_... | I can see 2 problems with your code. You seem to want that meta box to appear on product pages, but you actually add it to the post type and not the product post type. The other problem is the hook you attach your function to. Try this:
```
add_action( 'add_meta_boxes_{post_type}', 'abc_load_post' );
```
Substitute ... |
47,833 | <p>I am using nextgen gallery plugin with this code:</p>
<pre><code>$galleries = $wpdb->get_results(
"SELECT t.*, tt.*
FROM $wpdb->nggallery AS t
INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid
WHERE tt.exclude != 1
GROUP BY tt.galleryid ORDER by tt.galleryid");
echo do_shortcode('[nggallery ... | [
{
"answer_id": 47837,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<h2>DataBase handling</h2>\n\n<blockquote>\n <p><strong>ALWAYS</strong> do a proper <code>prepare()</code> when recei... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14844/"
] | I am using nextgen gallery plugin with this code:
```
$galleries = $wpdb->get_results(
"SELECT t.*, tt.*
FROM $wpdb->nggallery AS t
INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid
WHERE tt.exclude != 1
GROUP BY tt.galleryid ORDER by tt.galleryid");
echo do_shortcode('[nggallery id='.$galleries[0]->gid... | After some pain, I found this at the [plugin documentation](http://wordpress.org/extend/plugins/nextgen-gallery/faq/)
>
> For a single picture : [singlepic id=x w=width h=height
> mode=web20|watermark float=left|right]
>
>
>
So my echo became this:
```
echo
'<li>
'.do_shortcode('[singlepic id='.$gallery->p... |
47,853 | <p>I've read the entry <strong><em>Best Collection of Code for your functions.php file</em></strong>, it really help me a lot. </p>
<p>I only got a question, <strong>is there a way to hide some plugins options (in their respective administrations), just like the way you hide the widgets at the dashboard?</strong>. Thi... | [
{
"answer_id": 49630,
"author": "Eric Allen",
"author_id": 5831,
"author_profile": "https://wordpress.stackexchange.com/users/5831",
"pm_score": 0,
"selected": false,
"text": "<p>Well, there are a few options, but, depending on the situation, code isn't the easiest way that I know to dea... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14847/"
] | I've read the entry ***Best Collection of Code for your functions.php file***, it really help me a lot.
I only got a question, **is there a way to hide some plugins options (in their respective administrations), just like the way you hide the widgets at the dashboard?**. This because I have to let the editor manage s... | This should be easiest way, just add the line to wp-config.php, this will disable plugin and theme editor, both.
`define('DISALLOW_FILE_EDIT',true);`
If you want to add codes into theme's function, the code should work for you.
```
function ra_block_tp_edit( $caps, $cap ) {
if($cap == 'edit_plugins' )
$... |
47,861 | <p>I have categories driven site. I have different template for each category. I would like to set different number of posts – <strong>different for each category</strong>. Plus I would like to add proper previous and next links in each category.</p>
<p>for example in this <code>category-1.php</code> I want 4 posts pe... | [
{
"answer_id": 47865,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 0,
"selected": false,
"text": "<p>With query_posts, pagination won't work correctly, unless you use query_posts() in a page template and you se... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14850/"
] | I have categories driven site. I have different template for each category. I would like to set different number of posts – **different for each category**. Plus I would like to add proper previous and next links in each category.
for example in this `category-1.php` I want 4 posts per page:
```
<?php query_posts('sh... | As [@StephenHarris pointed out](http://chat.stackexchange.com/transcript/message/4093036#4093036) there's also the [`pre_get_posts` filter](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts).
```
function hwl_home_pagesize( $query )
{
if ( is_category( 9 ) )
{
// If you want "posts... |
47,863 | <p>I made my own upload service for my website that is separate from WP, but uses WP to provide low level db functions and user verification. To do that, I include wp-load.php in my main script (Uploadify) but doing that seems to fill the server's memory with unnecessary components. Thanks to that, I'm seeing an error ... | [
{
"answer_id": 47864,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": false,
"text": "<p>Disabling plugins entirely means you loose many advantages.</p>\n\n<p>There are distributions of wordpress th... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5648/"
] | I made my own upload service for my website that is separate from WP, but uses WP to provide low level db functions and user verification. To do that, I include wp-load.php in my main script (Uploadify) but doing that seems to fill the server's memory with unnecessary components. Thanks to that, I'm seeing an error in ... | Disabling plugins entirely means you loose many advantages.
There are distributions of wordpress that go further and rip out posts and links etc, but they'll always lag behind WordPress core and tend not to survive as long.
Here are some things that could be done
**Short Init**
Putting this in your wp-config.php:
... |
47,867 | <p>I've read the documentation <a href="http://cart66.com/cart66lite-documentation.pdf" rel="nofollow">http://cart66.com/cart66lite-documentation.pdf</a> and searched on google but i can't seem to find a location(s) to localize strings (hardcode) for Cart66.</p>
<p>If someone can point me to the right direction.</p>
... | [
{
"answer_id": 47864,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": false,
"text": "<p>Disabling plugins entirely means you loose many advantages.</p>\n\n<p>There are distributions of wordpress th... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47867",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14852/"
] | I've read the documentation <http://cart66.com/cart66lite-documentation.pdf> and searched on google but i can't seem to find a location(s) to localize strings (hardcode) for Cart66.
If someone can point me to the right direction.
EDIT1:
I've changed CART66\_CURRENCY\_SYMBOL field in the wp\_cart66\_cart\_settings ta... | Disabling plugins entirely means you loose many advantages.
There are distributions of wordpress that go further and rip out posts and links etc, but they'll always lag behind WordPress core and tend not to survive as long.
Here are some things that could be done
**Short Init**
Putting this in your wp-config.php:
... |
47,870 | <p>As of now i'm using this code to echo user's profile url.</p>
<pre><code><?php echo esc_url( home_url( '/' ) ); ?>user/<?php echo $current_user->user_login ?>"><?php echo $current_user->user_login ?></a>
</code></pre>
<p>This link uses author base as "user". So when i change author... | [
{
"answer_id": 47872,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": true,
"text": "<h2>Choosing the right template</h2>\n\n<p>As your \"User Profile\"-Page is something completely custom and <strong>not... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | As of now i'm using this code to echo user's profile url.
```
<?php echo esc_url( home_url( '/' ) ); ?>user/<?php echo $current_user->user_login ?>"><?php echo $current_user->user_login ?></a>
```
This link uses author base as "user". So when i change author base this link will be broken.
IS there any function ava... | Choosing the right template
---------------------------
As your "User Profile"-Page is something completely custom and **not** the admin UI user profile page, I'd suggest to take the uthor posts page instead:
```
get_author_link( true, get_current_user_id() );
```
Then modify this template.
Pretty URls
----------... |
47,890 | <p>I have a custom content type of <code>photo_group</code> which is a collection of photos.</p>
<p>I want to be able to go to <code>mysite.com/photos</code> and have that page dump out all of my photo groups.</p>
<p>How can I do this without making a "page" and setting the template? Or is that the approach I'll have... | [
{
"answer_id": 47926,
"author": "tollmanz",
"author_id": 4850,
"author_profile": "https://wordpress.stackexchange.com/users/4850",
"pm_score": 3,
"selected": true,
"text": "<p>Romes,</p>\n\n<p>The method you suggested will definitely work and is likely the easiest; however, I can definit... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13169/"
] | I have a custom content type of `photo_group` which is a collection of photos.
I want to be able to go to `mysite.com/photos` and have that page dump out all of my photo groups.
How can I do this without making a "page" and setting the template? Or is that the approach I'll have to take?
Thanks | Romes,
The method you suggested will definitely work and is likely the easiest; however, I can definitely see cases in which this is not ideal. To accomplish this more "programmatically", you would need to do the following:
1) Set a new query var
2) Generate a new rewrite rule to make sense of that query var
3) Red... |
47,897 | <p>I have created several custom content types.</p>
<p>My question: What about showing things of different content types in search.php? Are different post types shown in search.php? if not how to make them shown? How should I configure the search code in order to show these content types which I want to show?</p>
| [
{
"answer_id": 47900,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>By default it is usually <code>post</code>s and <code>page</code>s, but, you can modify this several ways</p>\... | 2012/04/03 | [
"https://wordpress.stackexchange.com/questions/47897",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13880/"
] | I have created several custom content types.
My question: What about showing things of different content types in search.php? Are different post types shown in search.php? if not how to make them shown? How should I configure the search code in order to show these content types which I want to show? | By default it is usually `post`s and `page`s, but, you can modify this several ways
**URLs**
`example.com/?s=test` will search for the term test in posts and pages, but, `example.com/?s=test&post_type=product` will search posts of the type `product` for the term test.
In the same way appending ?s=term to your post t... |
47,922 | <p>I am trying out the <a href="http://premium.wpmudev.org/project/qa-wordpress-questions-and-answers-plugin-lite" rel="nofollow">Q&A lite plugin from WPMU</a>. It looks great except for one thing. It looks like users can only ask and answer question, not make comments on them. This effectively makes a conversation... | [
{
"answer_id": 47900,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>By default it is usually <code>post</code>s and <code>page</code>s, but, you can modify this several ways</p>\... | 2012/04/04 | [
"https://wordpress.stackexchange.com/questions/47922",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6169/"
] | I am trying out the [Q&A lite plugin from WPMU](http://premium.wpmudev.org/project/qa-wordpress-questions-and-answers-plugin-lite). It looks great except for one thing. It looks like users can only ask and answer question, not make comments on them. This effectively makes a conversation between two users very short. On... | By default it is usually `post`s and `page`s, but, you can modify this several ways
**URLs**
`example.com/?s=test` will search for the term test in posts and pages, but, `example.com/?s=test&post_type=product` will search posts of the type `product` for the term test.
In the same way appending ?s=term to your post t... |
47,924 | <p>Hi guys I'm working on this public theme where the previous developer had created a post type called "blog" the problem is that when you create a page with the same slug it creates a conflict.</p>
<p>The theme is being used by several clients and I'm trying to avoid this issue by renaming the post type without hav... | [
{
"answer_id": 51186,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 0,
"selected": false,
"text": "<p>Admittedly, I've never tried this, but the Codex description of <code>register_post_type()</code> is:</p>\n\n<blo... | 2012/04/04 | [
"https://wordpress.stackexchange.com/questions/47924",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14859/"
] | Hi guys I'm working on this public theme where the previous developer had created a post type called "blog" the problem is that when you create a page with the same slug it creates a conflict.
The theme is being used by several clients and I'm trying to avoid this issue by renaming the post type without having the use... | You are in the right direction. When doing something like this, make sure you look at every possible place where this needs to be changed as you don't want data inconsistency. Some suggestions to make this process better:
Don't hardcode WordPress table name (`$wpdb->posts`) in the query. This won't work if the install... |
47,928 | <p>I am setting up a few sections of a website external to the core wordpress installation, but I still want to use the built in wpdb functions, and/or header files from wordpress.</p>
<p>I follow the instructions outlined in wordpress, setting up my headers:</p>
<pre><code> <?
require('../cms/wp-blog-header.php'... | [
{
"answer_id": 47932,
"author": "aaronwaggs",
"author_id": 5376,
"author_profile": "https://wordpress.stackexchange.com/users/5376",
"pm_score": 2,
"selected": false,
"text": "<p>consider including <code>wp-load.php</code> instead of <code>wp-blog-header.php</code></p>\n\n<p>You can also... | 2012/04/04 | [
"https://wordpress.stackexchange.com/questions/47928",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14862/"
] | I am setting up a few sections of a website external to the core wordpress installation, but I still want to use the built in wpdb functions, and/or header files from wordpress.
I follow the instructions outlined in wordpress, setting up my headers:
```
<?
require('../cms/wp-blog-header.php');
define('WP_USE_THEME... | Solution Found! Thanks to [these guys](http://www.adrogen.com/blog/wordpress-wp-blog-headerphp-causes-404-in-ie/)
```
require('../cms/wp-config.php');
$wp->init();
$wp->parse_request();
$wp->query_posts();
$wp->register_globals();
```
The key is, don't use wp-blog-header, but this code instead. |
47,940 | <p>I'm working on my first wordpress blog site and I think I'm doing pretty good. <a href="http://ambergoodwin.com/averylawoffice/averytest/" rel="nofollow">This is my site so far</a> but I need some help with a couple things as I'm not sure why this is happening. I've styled my blog the way I want to (with the clickab... | [
{
"answer_id": 47945,
"author": "Brad Farleigh",
"author_id": 13184,
"author_profile": "https://wordpress.stackexchange.com/users/13184",
"pm_score": 0,
"selected": false,
"text": "<p>By default wordpress will display posts and pages based on the layout defined in index.php but you can o... | 2012/04/04 | [
"https://wordpress.stackexchange.com/questions/47940",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25108/"
] | I'm working on my first wordpress blog site and I think I'm doing pretty good. [This is my site so far](http://ambergoodwin.com/averylawoffice/averytest/) but I need some help with a couple things as I'm not sure why this is happening. I've styled my blog the way I want to (with the clickable title and the dark red bac... | I think you just need to add your body "blog" class before your own css style like below:
```
.blog .entry-subtitle {
width: 100%;
height: 36px;
line-height: 36px;
letter-spacing: 1px;
color: white;
font-weight: normal;
font-size: 1em;
text-indent: 15px;
margin-top: -10px;
background-color: #761616;
text-transform: up... |
47,957 | <p>I think the way wordpress display previous and next posts is basically non sense, with next posts on the left side, and older posts on the right side.</p>
<p>I am using the code </p>
<pre><code><?php posts_nav_link() ?>
</code></pre>
<p>is there a way to reverse such order?</p>
| [
{
"answer_id": 47958,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 3,
"selected": true,
"text": "<p>This is because it is, by default, done as 'previous page' on the left, and 'next page' on the right. Post... | 2012/04/04 | [
"https://wordpress.stackexchange.com/questions/47957",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14378/"
] | I think the way wordpress display previous and next posts is basically non sense, with next posts on the left side, and older posts on the right side.
I am using the code
```
<?php posts_nav_link() ?>
```
is there a way to reverse such order? | This is because it is, by default, done as 'previous page' on the left, and 'next page' on the right. Posts appear in reverse chronological order, with the latest post first, so 'next page' means going back in time. So in terms of pages it makes sense, in terms of chronology it doesn't.
Anyway... this should work:
``... |
47,960 | <p>I need to list post_title's in this specific format (note the last title in the list <strong>must not</strong> have a comma)</p>
<pre><code> "post_title","post_title","post_title"
</code></pre>
<p>I thought a mini-loop might work. Here's what I'm using</p>
<pre><code> <?php query_posts('cat=0$pos... | [
{
"answer_id": 47962,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 0,
"selected": false,
"text": "<p>change that line:</p>\n\n<pre><code>'<?php the_title(); ?>',\n</code></pre>\n\n<p>to:</p>\n\n<pre><code>&l... | 2012/04/04 | [
"https://wordpress.stackexchange.com/questions/47960",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3842/"
] | I need to list post\_title's in this specific format (note the last title in the list **must not** have a comma)
```
"post_title","post_title","post_title"
```
I thought a mini-loop might work. Here's what I'm using
```
<?php query_posts('cat=0$posts_per_page=-1'); // query to show all posts indepen... | I'm not sure of the context for this, but `query_posts` probably isn't what you want to use. (See [this answer](https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts)).
(*Untested*). I would use get\_posts:
```
$posts = get_posts(array(
'numberposts'=>-1,
'cat... |
47,972 | <p>I want to show something in the sidebar of a post only if the author of the post equals a specific author or username. I was looking at <code>is_author()</code> but that doesn't seem to do the trick.</p>
| [
{
"answer_id": 47976,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>You can access the posts author (inside the loop) with the <code>global $post;</code></p>\n\n<pre><code>echo $post-... | 2012/04/04 | [
"https://wordpress.stackexchange.com/questions/47972",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12700/"
] | I want to show something in the sidebar of a post only if the author of the post equals a specific author or username. I was looking at `is_author()` but that doesn't seem to do the trick. | You can access the posts author (inside the loop) with the `global $post;`
```
echo $post->post_author
```
If your sidebar comes after your main content (in code), then you could populate a global array (not the best solution, but ok).
```
// in the loop: Add each author to the global $post_authors array
$post_auth... |
47,993 | <p>I have some html:</p>
<pre><code><div class="container">
<p class="accent">The first paragraph...</p>
<p>The rest of the article...</p>
</div>
</code></pre>
<p>I'd like to put "the_excerpt" in the first paragraph (with a special colour / font size) but then have the following te... | [
{
"answer_id": 47999,
"author": "Eduardo Reveles",
"author_id": 7459,
"author_profile": "https://wordpress.stackexchange.com/users/7459",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe doing it with css?</p>\n\n<pre><code>.container p:first {\n font-weight: bold;\n}\n</code></pre... | 2012/04/04 | [
"https://wordpress.stackexchange.com/questions/47993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2417/"
] | I have some html:
```
<div class="container">
<p class="accent">The first paragraph...</p>
<p>The rest of the article...</p>
</div>
```
I'd like to put "the\_excerpt" in the first paragraph (with a special colour / font size) but then have the following text be "normal".
Is there a way to **subtract** the\_excerpt ... | The key is to use **user-defined excerpts**, rather than auto-generated excerpts. For example:
```
<div <?php post_class(); ?>>
<?php
// If post has defined excerpt, output it here
if ( has_excerpt() ) {
?>
<div class="first-paragraph-excerpt">
<?php the_excerpt(); ?>
</div>
<?php
}
// Now output t... |
48,012 | <p>how to insert content into my taxonomy
this code is correct or not?</p>
<pre><code> // Create post object
$my_post = array(
'post_title' => 'My post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
'tax_input' => array( 'taxonomy_nam... | [
{
"answer_id": 48030,
"author": "Sam Margulies",
"author_id": 8043,
"author_profile": "https://wordpress.stackexchange.com/users/8043",
"pm_score": 0,
"selected": false,
"text": "<p>This code appears to be correct, but the only way to find out is to try it. You can find more information ... | 2012/04/04 | [
"https://wordpress.stackexchange.com/questions/48012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14179/"
] | how to insert content into my taxonomy
this code is correct or not?
```
// Create post object
$my_post = array(
'post_title' => 'My post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
'tax_input' => array( 'taxonomy_name' => array( 'Newpostlist' ) ) ,
'post_catego... | You're using `tax_input` incorrectly. You're not literally supposed to say `taxonomy_name`, you're supposed to enter the name of your custom taxonomy. See <https://codex.wordpress.org/Function_Reference/wp_insert_post>. So, assuming your taxonomy is called 'ninja\_turtles' and you are tagging your post with 'donatello'... |
48,017 | <p>I would remove Tag capability from classic Post type,
can I use <code>remove_theme_support( $feature );</code> and how to do this ?</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 48018,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 3,
"selected": true,
"text": "<p>You can do it with something like this:</p>\n\n<pre><code>add_action( 'init', 'wpse48017_remove_tags' );\nfunc... | 2012/04/04 | [
"https://wordpress.stackexchange.com/questions/48017",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/492/"
] | I would remove Tag capability from classic Post type,
can I use `remove_theme_support( $feature );` and how to do this ?
Thanks in advance | You can do it with something like this:
```
add_action( 'init', 'wpse48017_remove_tags' );
function wpse48017_remove_tags() {
global $wp_taxonomies;
$tax = 'post_tag'; // this may be wrong, I never remember the names on the defaults
if( taxonomy_exists( $tax ) )
unset( $wp_taxonomies[$tax] );
}
``... |
48,032 | <p>I use the following code to get the Administrator role</p>
<pre><code>$admin = get_role('administrator');
</code></pre>
<p>This works fine, but on a different WordPress language setup, this code breaks. For example, in French it should be</p>
<pre><code>$admin = get_role('adminstrateur');
</code></pre>
<p>Any cr... | [
{
"answer_id": 48033,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 2,
"selected": true,
"text": "<p>Just guessing, but maybe:</p>\n\n<pre><code>$admin = get_role( __( 'administrator' ) );\n</code></pre>\n\n<p>If you're... | 2012/04/04 | [
"https://wordpress.stackexchange.com/questions/48032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2167/"
] | I use the following code to get the Administrator role
```
$admin = get_role('administrator');
```
This works fine, but on a different WordPress language setup, this code breaks. For example, in French it should be
```
$admin = get_role('adminstrateur');
```
Any cross-language solution? | Just guessing, but maybe:
```
$admin = get_role( __( 'administrator' ) );
```
If you're trying to make sure that WP translates the string for a specific locale, `__()` will return the translated string. So if `get_role('administrator')` works and on a French setup `get_role('administrateur')` would work, then the ab... |
48,046 | <p>I'm working on my first wordpresss website and I've really never worked with RSS feeds. However my friend that I'm doing a website for wants it in there. so I guess I'm in a crash course learning session with google to learn all I can about RSS feeds. </p>
<p>I was hoping to find a plugin that just allowed the visi... | [
{
"answer_id": 48033,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 2,
"selected": true,
"text": "<p>Just guessing, but maybe:</p>\n\n<pre><code>$admin = get_role( __( 'administrator' ) );\n</code></pre>\n\n<p>If you're... | 2012/04/05 | [
"https://wordpress.stackexchange.com/questions/48046",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25108/"
] | I'm working on my first wordpresss website and I've really never worked with RSS feeds. However my friend that I'm doing a website for wants it in there. so I guess I'm in a crash course learning session with google to learn all I can about RSS feeds.
I was hoping to find a plugin that just allowed the visitor to sub... | Just guessing, but maybe:
```
$admin = get_role( __( 'administrator' ) );
```
If you're trying to make sure that WP translates the string for a specific locale, `__()` will return the translated string. So if `get_role('administrator')` works and on a French setup `get_role('administrateur')` would work, then the ab... |
48,056 | <p>Is there a way to query posts from multiple post_type's and filter the normal blog posts by a category?</p>
<p>I am trying to display the 10 latest custom_post_type posts and blog posts on my homepage in a single query - so that I have 10 posts in total, sorted by post_date in DESC order, containing all posts from ... | [
{
"answer_id": 48053,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 3,
"selected": true,
"text": "<p>Go to \"Settings\" -> \"Permalink\" page and set custom structure for permalinks equals to <code>/news/%p... | 2012/04/05 | [
"https://wordpress.stackexchange.com/questions/48056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12495/"
] | Is there a way to query posts from multiple post\_type's and filter the normal blog posts by a category?
I am trying to display the 10 latest custom\_post\_type posts and blog posts on my homepage in a single query - so that I have 10 posts in total, sorted by post\_date in DESC order, containing all posts from my cus... | Go to "Settings" -> "Permalink" page and set custom structure for permalinks equals to `/news/%postname%`. |
48,075 | <p>When I upload an image, it is automatically resized as I would expect, however the sizes for inserting the image seem to ignore the settings I've placed in Settings/Media.</p>
<p>In my media settings I have:</p>
<ul>
<li>Thumbnail: 150 x 150 </li>
<li>Medium: 300 x 300 </li>
<li>Large: 690 x 9999 </li>
</ul>
<p... | [
{
"answer_id": 48086,
"author": "Scriptamateur",
"author_id": 13191,
"author_profile": "https://wordpress.stackexchange.com/users/13191",
"pm_score": 0,
"selected": false,
"text": "<p>If you want more control on what image sizes are generated when you upload images, have a look at the <a... | 2012/04/05 | [
"https://wordpress.stackexchange.com/questions/48075",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14903/"
] | When I upload an image, it is automatically resized as I would expect, however the sizes for inserting the image seem to ignore the settings I've placed in Settings/Media.
In my media settings I have:
* Thumbnail: 150 x 150
* Medium: 300 x 300
* Large: 690 x 9999
I upload an image of: *2226 x 1663*.
Wordpress gen... | I believe your issue is that the value set for the global **`$content_width`** variable (which is **640px** in Boilerplate and **584px** in Twenty Eleven) is less than the width you're specifying via `Settings -> Media`.
WordPress is overriding your user setting with the Theme-specific value. This actually makes sense... |
48,085 | <p>Is it possible to reference a class instead of a function in 'add_action'? Can't seem to figure it out. Here is just a basic example of the function in question.</p>
<pre><code>add_action( 'admin_init', 'MyClass' );
class MyClass {
function __construct() {
.. This is where stuff gets done ..
}
}... | [
{
"answer_id": 48089,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Generally speaking, you wouldn't add an entire <em>class</em> to a hook. The <code>add_action()</code>/<cod... | 2012/04/05 | [
"https://wordpress.stackexchange.com/questions/48085",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13081/"
] | Is it possible to reference a class instead of a function in 'add\_action'? Can't seem to figure it out. Here is just a basic example of the function in question.
```
add_action( 'admin_init', 'MyClass' );
class MyClass {
function __construct() {
.. This is where stuff gets done ..
}
}
```
So yea... | No, you cannot 'initialise' or instantiate the class through a hook, not directly. Some additional code is always required ( and it is not a desirable thing to be able to do that, as you're opening a can of worms for yourself.
Here is a better way of doing it:
```php
class MyClass {
function __construct() {
... |
48,091 | <p>I am importing a large DB from an Excel spreadsheet into a wordpress DB. I was going to do it manually by creating a new table but decided to import it into the existing wordpress framework as it will allow me to change information manually in the wordpress back end.</p>
<p>I was importing all 2000 rows into the wp... | [
{
"answer_id": 48097,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": true,
"text": "<p>I don't think you should create a new column in wp_posts...</p>\n\n<p>This kind of info is stored in wp_postm... | 2012/04/05 | [
"https://wordpress.stackexchange.com/questions/48091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10645/"
] | I am importing a large DB from an Excel spreadsheet into a wordpress DB. I was going to do it manually by creating a new table but decided to import it into the existing wordpress framework as it will allow me to change information manually in the wordpress back end.
I was importing all 2000 rows into the wp\_posts ta... | I don't think you should create a new column in wp\_posts...
This kind of info is stored in wp\_postmeta.
When I need this kind of importing (Excel->WP), I use [CSV Importer](http://wordpress.org/extend/plugins/csv-importer/other_notes/), as you can assign categories, tags and custom field to the imported data.
You'l... |
48,107 | <p>I have a <code>mymail.php</code> script which sends a email (I managed to do it using <code>require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-includes/class-phpmailer.php' );</code>.) and outputs a plain text string (Such as "Email is sent successfully.")</p>
<p>I want to use the functions defined in WP in this my scr... | [
{
"answer_id": 48111,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p><code>mymail.php</code> is located in the same dir where <code>style.css</code> and <code>f... | 2012/04/05 | [
"https://wordpress.stackexchange.com/questions/48107",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13880/"
] | I have a `mymail.php` script which sends a email (I managed to do it using `require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-includes/class-phpmailer.php' );`.) and outputs a plain text string (Such as "Email is sent successfully.")
I want to use the functions defined in WP in this my script. The particular function I w... | The root problem here is that you should never make direct requests to PHP files in a theme or plugins from the browser. It is extreme bad practice, fragile, and open to lots of security issues.
To get this working as is you would need to bootstrap WordPress by putting something similar this near the top of your PHP f... |
48,117 | <p>I'm using wordpress' native media manager. I have a problem. I can show the title under the image. But I want also to show the description. Is it possible to do? </p>
| [
{
"answer_id": 48168,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>This is actually quite easy: You just hijack the short code handler for image captions, grab the <code>post_content</co... | 2012/04/05 | [
"https://wordpress.stackexchange.com/questions/48117",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14915/"
] | I'm using wordpress' native media manager. I have a problem. I can show the title under the image. But I want also to show the description. Is it possible to do? | This is actually quite easy: You just hijack the short code handler for image captions, grab the `post_content` (the image description) and set its content as a value for the attribute `caption`. Then you call the original shortcode handler.
The following example requires the shortcode attribute `desc` set to `1` to m... |
48,123 | <p>I'm trying to find away to retrive a dynamic sidebar from one blog and print it on another blog in the same install of Wordpress Multisite. I have tried</p>
<pre><code>switch_to_blog($blog_id);
dynamic_sidebar($sidebar_name);
restore_current_blog();
</code></pre>
<p>But nothing is returned.</p>
<p>I also tired to... | [
{
"answer_id": 48222,
"author": "developdaly",
"author_id": 3293,
"author_profile": "https://wordpress.stackexchange.com/users/3293",
"pm_score": -1,
"selected": false,
"text": "<p>Are you using <code>global $switched;</code>?</p>\n\n<pre><code>global $switched;\nswitch_to_blog($blog_id)... | 2012/04/05 | [
"https://wordpress.stackexchange.com/questions/48123",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14916/"
] | I'm trying to find away to retrive a dynamic sidebar from one blog and print it on another blog in the same install of Wordpress Multisite. I have tried
```
switch_to_blog($blog_id);
dynamic_sidebar($sidebar_name);
restore_current_blog();
```
But nothing is returned.
I also tired to retrive the sidebar through `get... | Unfortunately, the `switch_to_blog()` method isn't going to work for this purpose. `switch_to_blog()` is really only a partial switch - it makes some modifications to `$wpdb` that help with database queries. But it's not a complete switch in the way you might imagine.
In particular, `dynamic_sidebar()` depends on glob... |
48,138 | <p>I've looked everywhere for a solution, but have yet to find one. Here is the situation. I've created a custom content type using the plugin <code>Custom Content Type Manager</code> and now have need to use these custom post types within pages that I've created in WP.</p>
<p>So I created a page called "Photos" and... | [
{
"answer_id": 48141,
"author": "Adam Rice",
"author_id": 13603,
"author_profile": "https://wordpress.stackexchange.com/users/13603",
"pm_score": 2,
"selected": false,
"text": "<p>I think what is happening here is that WP is noticing that your URL ends with \"photos\" and so it is struct... | 2012/04/05 | [
"https://wordpress.stackexchange.com/questions/48138",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13169/"
] | I've looked everywhere for a solution, but have yet to find one. Here is the situation. I've created a custom content type using the plugin `Custom Content Type Manager` and now have need to use these custom post types within pages that I've created in WP.
So I created a page called "Photos" and use a template php fil... | The loop in your code is automatically going to pull data from the current page ID (i.e. Photos). You have to define the query for which data you're looking for. Be sure to replace `photo` with whatever the slug is for your post type.
See <http://codex.wordpress.org/Class_Reference/WP_Query> for other arguments you ca... |
48,145 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://wordpress.stackexchange.com/questions/2040/setting-comments-off-as-default-for-pages-and-custom-post-types">setting comments off as default for pages and custom post types?</a> </p>
</blockquote>
<p>When I create a new page, I want these ... | [
{
"answer_id": 48147,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li>Go to <strong><code>Dashboard -> Settings -> Discussion</code></strong></li>\n<li>Find <strong... | 2012/04/05 | [
"https://wordpress.stackexchange.com/questions/48145",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1986/"
] | >
> **Possible Duplicate:**
>
> [setting comments off as default for pages and custom post types?](https://wordpress.stackexchange.com/questions/2040/setting-comments-off-as-default-for-pages-and-custom-post-types)
>
>
>
When I create a new page, I want these two checkboxes (from the "Discussion" meta box) to ... | You can re-register the "page" post type and leave out the comments capability.
```
add_action( 'init', 'my_new_page_type' );
function my_new_page_type() {
register_post_type( 'page', array(
'labels' => array(
'name_admin_bar' => _x( 'Page', 'add new on admin bar' ),
),
'public... |
48,171 | <p>I made a little plugin that enqueues 1 .js file and 1 .css file into a theme's front-end. All it does it load a grid on top of the theme so I can visualise the design. </p>
<p>If this plugin was activated on a live site, is it possible that only I (the super admin) can see the JS and CSS files included onto the fro... | [
{
"answer_id": 48172,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": true,
"text": "<pre><code>function load_grid() {\n if ( current_user_can( 'level_10' ) ) {\n wp_enqueue_style('gr... | 2012/04/06 | [
"https://wordpress.stackexchange.com/questions/48171",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I made a little plugin that enqueues 1 .js file and 1 .css file into a theme's front-end. All it does it load a grid on top of the theme so I can visualise the design.
If this plugin was activated on a live site, is it possible that only I (the super admin) can see the JS and CSS files included onto the front-end?
A... | ```
function load_grid() {
if ( current_user_can( 'level_10' ) ) {
wp_enqueue_style('grid_css', plugins_url('/lib/css/grid.css', __FILE__) );
wp_enqueue_script('grid_js', plugins_url('/lib/js/grid.js', __FILE__), array('jquery') );
}
}
add_action('wp_enqueue_scripts', 'load_grid');
``` |
48,183 | <p><strong>Precondition:</strong> coming from a Custom PHP applications(using symfony, zend and so on) world, for me it feels unnatural to have template separated in a way that is done in original wordpress theme. e.g top part of a page is in header, center in a "index, page..." and bottom part in a footer. </p>
<p>ex... | [
{
"answer_id": 48172,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": true,
"text": "<pre><code>function load_grid() {\n if ( current_user_can( 'level_10' ) ) {\n wp_enqueue_style('gr... | 2012/04/06 | [
"https://wordpress.stackexchange.com/questions/48183",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4089/"
] | **Precondition:** coming from a Custom PHP applications(using symfony, zend and so on) world, for me it feels unnatural to have template separated in a way that is done in original wordpress theme. e.g top part of a page is in header, center in a "index, page..." and bottom part in a footer.
example of current struct... | ```
function load_grid() {
if ( current_user_can( 'level_10' ) ) {
wp_enqueue_style('grid_css', plugins_url('/lib/css/grid.css', __FILE__) );
wp_enqueue_script('grid_js', plugins_url('/lib/js/grid.js', __FILE__), array('jquery') );
}
}
add_action('wp_enqueue_scripts', 'load_grid');
``` |
48,214 | <p>For whatever reason, I have a post and a page with the same slug name and it causes the db to hang. I can't alter the slug on either so I need to go manually delete the posts from the database and start over.</p>
<p>Now, I am willing to go pull up the post ID from wp_posts and wp_postmeta and manually delete each e... | [
{
"answer_id": 48217,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": -1,
"selected": false,
"text": "<p>Ok, if you want to delete it completely, you have to delete post/page from <code>wp_term_relationships<... | 2012/04/06 | [
"https://wordpress.stackexchange.com/questions/48214",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10099/"
] | For whatever reason, I have a post and a page with the same slug name and it causes the db to hang. I can't alter the slug on either so I need to go manually delete the posts from the database and start over.
Now, I am willing to go pull up the post ID from wp\_posts and wp\_postmeta and manually delete each entry. Wi... | Drop this into a file in your plugin directory and you should be able to do this from your WP installation using a query string.
```
/*
Plugin Name: Delete Specific Post
Description: Rid the post forever!
Version: 0.1
Author: WPSE
License: GPL2
*/
add_filter('query_vars', 'delete_post_query_var');
function delete_pos... |
48,224 | <p>Person X has default SITE with an integral blog. Person X also has SITE 2 with Blog 2 and also SITE 3 with Blog 3.</p>
<p>Is it possible to have on the DEFAULT SITE HEADER MENU something like this:</p>
<pre><code>HOME BLOG1 BLOG2 BLOG3 CONTACTUS
</code></pre>
<p>BLOG1 is a integral blog of that DEFAULT SITE. Blog... | [
{
"answer_id": 48226,
"author": "developdaly",
"author_id": 3293,
"author_profile": "https://wordpress.stackexchange.com/users/3293",
"pm_score": 1,
"selected": false,
"text": "<p>The first, and likely best, solution is to use a WordPress network where BLOG 1 resides at <code>example.com... | 2012/04/06 | [
"https://wordpress.stackexchange.com/questions/48224",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14941/"
] | Person X has default SITE with an integral blog. Person X also has SITE 2 with Blog 2 and also SITE 3 with Blog 3.
Is it possible to have on the DEFAULT SITE HEADER MENU something like this:
```
HOME BLOG1 BLOG2 BLOG3 CONTACTUS
```
BLOG1 is a integral blog of that DEFAULT SITE. Blog 2 tab would link to the blog 2 o... | The first, and likely best, solution is to use a WordPress network where BLOG 1 resides at `example.com`.
BLOG 2 is a totally separate blog, but within the context of the network and lives at a subdirectory like `example.com/blog2`. And so on...
The second solution is to use a plugin that pulls in feeds from external... |
48,238 | <p>Thanks to Wordpress calling their content 'posts', it makes it hard to find information on dealing with forms submitted with the POST protocol. My question is simple, the answer should be simple to a seasoned Wordpress developer.</p>
<p>Using a Wordpress plugin which has a form in the widget method of the class, I ... | [
{
"answer_id": 48226,
"author": "developdaly",
"author_id": 3293,
"author_profile": "https://wordpress.stackexchange.com/users/3293",
"pm_score": 1,
"selected": false,
"text": "<p>The first, and likely best, solution is to use a WordPress network where BLOG 1 resides at <code>example.com... | 2012/04/06 | [
"https://wordpress.stackexchange.com/questions/48238",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6348/"
] | Thanks to Wordpress calling their content 'posts', it makes it hard to find information on dealing with forms submitted with the POST protocol. My question is simple, the answer should be simple to a seasoned Wordpress developer.
Using a Wordpress plugin which has a form in the widget method of the class, I named the ... | The first, and likely best, solution is to use a WordPress network where BLOG 1 resides at `example.com`.
BLOG 2 is a totally separate blog, but within the context of the network and lives at a subdirectory like `example.com/blog2`. And so on...
The second solution is to use a plugin that pulls in feeds from external... |
48,258 | <p>I'm sending the content of a custom post type in a plain text email (it's to send competition entries to a panel of judges), so I need to make sure that <code>$post->post_content</code> is correctly sanitized first.</p>
<p>Is there a filter I can use for this, or if not, what sanitization do I need to do?</p>
<... | [
{
"answer_id": 48260,
"author": "David",
"author_id": 11218,
"author_profile": "https://wordpress.stackexchange.com/users/11218",
"pm_score": 1,
"selected": true,
"text": "<p>You will want to use <code>sanitize_email();</code> as follows:</p>\n\n<pre><code>return( sanitize_email( $email ... | 2012/04/07 | [
"https://wordpress.stackexchange.com/questions/48258",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2877/"
] | I'm sending the content of a custom post type in a plain text email (it's to send competition entries to a panel of judges), so I need to make sure that `$post->post_content` is correctly sanitized first.
Is there a filter I can use for this, or if not, what sanitization do I need to do?
Update: I've just found `wp_s... | You will want to use `sanitize_email();` as follows:
```
return( sanitize_email( $email ) );
```
Here is the Codex link so you have it: <http://codex.wordpress.org/Function_Reference/sanitize_email>
Cheers! |
48,262 | <p>I need to get any post category id from the post id(Not for current) Post.
How can i ?</p>
<p>Thanks</p>
| [
{
"answer_id": 48263,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 3,
"selected": false,
"text": "<p>Take a look at <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_post_categories\">wp_get_p... | 2012/04/07 | [
"https://wordpress.stackexchange.com/questions/48262",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12261/"
] | I need to get any post category id from the post id(Not for current) Post.
How can i ?
Thanks | You can try this code for getting category id from post id:
```
global $post;
$category_detail=get_the_category( $post->ID );
``` |
48,269 | <p>I'm trying to hide a help page from editors, added by the <a href="http://www.gravityforms.com/" rel="nofollow">gravity forms</a> plugin. I believe I've run into the same issue before with other plugins, so I'd like to know the correct way to do it for 3rd party plugins. This is what I have so far which does not wor... | [
{
"answer_id": 48270,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 3,
"selected": false,
"text": "<p>You need to add your hook at the end of the queue and then remove menu by slug:</p>\n\n<pre><code>functi... | 2012/04/07 | [
"https://wordpress.stackexchange.com/questions/48269",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I'm trying to hide a help page from editors, added by the [gravity forms](http://www.gravityforms.com/) plugin. I believe I've run into the same issue before with other plugins, so I'd like to know the correct way to do it for 3rd party plugins. This is what I have so far which does not work. It does of course work for... | Ok, Eugene's Answer works in the case of a plugin that doesn't deals with custom capabilities.
>
> <http://codex.wordpress.org/Roles_and_Capabilities>
>
> The [WordPress Plugin API](http://codex.wordpress.org/Plugin_API) allows Roles and Capabilities to be added, removed and changed. Since Plugins might change Rol... |
48,275 | <p>I was wondering if we can set the order of a function hooked to wp_footer(), I created a function that echos:</p>
<pre><code><script> ajsfunction(); </script>
</code></pre>
<p>and I also enqueued the js file of this function and printed it in the footer but the above is being printed before linking to... | [
{
"answer_id": 48276,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 4,
"selected": true,
"text": "<p>The recommended way is to call your function inside the .js file you are enqueuing. Is there any reason you ... | 2012/04/07 | [
"https://wordpress.stackexchange.com/questions/48275",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14490/"
] | I was wondering if we can set the order of a function hooked to wp\_footer(), I created a function that echos:
```
<script> ajsfunction(); </script>
```
and I also enqueued the js file of this function and printed it in the footer but the above is being printed before linking to the js file so it's not working, I'm ... | The recommended way is to call your function inside the .js file you are enqueuing. Is there any reason you can't do that?
If you need access to dynamic data like WP options from within your script, use [`wp_localize_script`](http://codex.wordpress.org/Function_Reference/wp_localize_script) to initialize a javascript ... |
48,281 | <p>This is what I added in my theme's functions.php file to enable formatting for excerpts in Wordpress (<a href="http://betterwp.net/wordpress-tips/fancy-wordpress-excerpt/" rel="nofollow noreferrer">source of the tip</a>):</p>
<pre><code>remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerp... | [
{
"answer_id": 48289,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 4,
"selected": true,
"text": "<p>This is one of the reasons why HTML markup is removed from excerpts in the first place, to prevent such issues lik... | 2012/04/07 | [
"https://wordpress.stackexchange.com/questions/48281",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | This is what I added in my theme's functions.php file to enable formatting for excerpts in Wordpress ([source of the tip](http://betterwp.net/wordpress-tips/fancy-wordpress-excerpt/)):
```
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'bwp_trim_excerpt');
function bwp_trim_excerpt... | This is one of the reasons why HTML markup is removed from excerpts in the first place, to prevent such issues like this from occurring however, where there's a will, there's a way...
You can, through using regular expression, close the open tags applicable to the excerpt only and you might want to take a look at the ... |
48,292 | <p>This is from the codex. </p>
<pre><code><?php get_term_by( $field, $value, $taxonomy, $output, $filter ) ?>
</code></pre>
<p>Suppose I have a taxonomy system as follows;</p>
<p>taxonomy: "healthy foods"
and it's a hierarchical taxonomy and your hierarchy goes exactly like this;</p>
<pre><code>healthy foods... | [
{
"answer_id": 48293,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 3,
"selected": true,
"text": "<p><code>get_term_by()</code> just returns the first matching term, 'first' meaning some internal order in MySQL.</p>\n... | 2012/04/07 | [
"https://wordpress.stackexchange.com/questions/48292",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14967/"
] | This is from the codex.
```
<?php get_term_by( $field, $value, $taxonomy, $output, $filter ) ?>
```
Suppose I have a taxonomy system as follows;
taxonomy: "healthy foods"
and it's a hierarchical taxonomy and your hierarchy goes exactly like this;
```
healthy foods
fruits
red ones
green ones
... | `get_term_by()` just returns the first matching term, 'first' meaning some internal order in MySQL.
If having multiple terms with the same name matters in your case, don't rely on `get_term_by()` alone. |