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 |
|---|---|---|---|---|---|---|
87,850 | <p>My company had a website developed that is entirely driven by custom fields. We're now discovering that we didn't anticipate the need for pages with custom layouts, the kinds that can be made on case by case basis in the visual editor. I have access to the site's page templates, but they all reference the custom fie... | [
{
"answer_id": 87847,
"author": "chifliiiii",
"author_id": 4130,
"author_profile": "https://wordpress.stackexchange.com/users/4130",
"pm_score": 0,
"selected": false,
"text": "<p>Try changing </p>\n\n<pre><code><?php wp_reset_query(); ?>\n</code></pre>\n\n<p>to</p>\n\n<pre><code>&l... | 2013/02/21 | [
"https://wordpress.stackexchange.com/questions/87850",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25758/"
] | My company had a website developed that is entirely driven by custom fields. We're now discovering that we didn't anticipate the need for pages with custom layouts, the kinds that can be made on case by case basis in the visual editor. I have access to the site's page templates, but they all reference the custom fields... | You don't need to call [`wp_reset_query()`](http://codex.wordpress.org/Function_Reference/wp_reset_query) here, because you're not modifying the *main* query. Instead, call [`wp_reset_postdata()`](http://codex.wordpress.org/Function_Reference/wp_reset_postdata).
You only need to call `wp_reset_query()` when modifying ... |
87,870 | <p>With some Java generic code in a code block, ie:</p>
<pre><code>List<Integer> l = new ArrayList<Integer>();
</code></pre>
<p>WP-Markdown was treating as HTML, and no matter what I did, the code above got turned into something like</p>
<pre><code>List<Integer> l = new ArrayList</Integer>&l... | [
{
"answer_id": 87905,
"author": "Nick Pickering",
"author_id": 21097,
"author_profile": "https://wordpress.stackexchange.com/users/21097",
"pm_score": 1,
"selected": false,
"text": "<p>You could write a shortcode to pass your Java code into that runs <code>htmlentities</code> on it. That... | 2013/02/21 | [
"https://wordpress.stackexchange.com/questions/87870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26832/"
] | With some Java generic code in a code block, ie:
```
List<Integer> l = new ArrayList<Integer>();
```
WP-Markdown was treating as HTML, and no matter what I did, the code above got turned into something like
```
List<Integer> l = new ArrayList</Integer><Integer>();</Integer>
```
Is there any way to get WP Markdown... | I was trying to fix this for the longest time as well. It seems that the problem is not the rendering, but the editor - when you save, it updates your post.
I found a checkbox under Settings -> Writing called "WordPress should correct invalidly nested XHTML automatically". Unchecking this checkbox fixed the problem. |
87,885 | <p>Is there any reason that my custom post type archive title is all lower-case even though 'name' is defined as sentence-case?</p>
<p>Here is the post type function I'm using:</p>
<pre><code>function resources_post_type() {
$labels = array(
'name' => _x( 'Resources, Help & Support', 'post ty... | [
{
"answer_id": 87905,
"author": "Nick Pickering",
"author_id": 21097,
"author_profile": "https://wordpress.stackexchange.com/users/21097",
"pm_score": 1,
"selected": false,
"text": "<p>You could write a shortcode to pass your Java code into that runs <code>htmlentities</code> on it. That... | 2013/02/22 | [
"https://wordpress.stackexchange.com/questions/87885",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27727/"
] | Is there any reason that my custom post type archive title is all lower-case even though 'name' is defined as sentence-case?
Here is the post type function I'm using:
```
function resources_post_type() {
$labels = array(
'name' => _x( 'Resources, Help & Support', 'post type general name' ),
'sin... | I was trying to fix this for the longest time as well. It seems that the problem is not the rendering, but the editor - when you save, it updates your post.
I found a checkbox under Settings -> Writing called "WordPress should correct invalidly nested XHTML automatically". Unchecking this checkbox fixed the problem. |
87,886 | <p>I'm using Disqus WordPress plugin. When the page is not fully loaded yet, there's only comment count but after that Disqus auto appends the string Comments to that which looks really ugly.</p>
<p><img src="https://i.stack.imgur.com/d4sqC.png" alt="snapshot"></p>
<p>From the theme:</p>
<pre><code> <div class... | [
{
"answer_id": 87905,
"author": "Nick Pickering",
"author_id": 21097,
"author_profile": "https://wordpress.stackexchange.com/users/21097",
"pm_score": 1,
"selected": false,
"text": "<p>You could write a shortcode to pass your Java code into that runs <code>htmlentities</code> on it. That... | 2013/02/22 | [
"https://wordpress.stackexchange.com/questions/87886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27848/"
] | I'm using Disqus WordPress plugin. When the page is not fully loaded yet, there's only comment count but after that Disqus auto appends the string Comments to that which looks really ugly.

From the theme:
```
<div class="comment-bubble">
<a href="<?php the_p... | I was trying to fix this for the longest time as well. It seems that the problem is not the rendering, but the editor - when you save, it updates your post.
I found a checkbox under Settings -> Writing called "WordPress should correct invalidly nested XHTML automatically". Unchecking this checkbox fixed the problem. |
87,909 | <p>I'm currently developing a website with WordPress 3.5 and I need to retrieve <strong>Post Text (Only text, not include images)</strong> at <strong>Archive Page</strong>. I can retrieve it with <code>wp_excerpt()</code> method without any problems. But the main problem for me is that I can't get the exact text layout... | [
{
"answer_id": 87920,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 2,
"selected": false,
"text": "<p>There's not a native WordPress function to retrieve text only, but you can use WordPress filters and regex... | 2013/02/22 | [
"https://wordpress.stackexchange.com/questions/87909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26576/"
] | I'm currently developing a website with WordPress 3.5 and I need to retrieve **Post Text (Only text, not include images)** at **Archive Page**. I can retrieve it with `wp_excerpt()` method without any problems. But the main problem for me is that I can't get the exact text layout. `wp_excerpt()` method returns text whi... | Or even simpler:
```
echo wp_strip_all_tags( get_the_content() );
```
By using:
* [`get_the_content()`](https://developer.wordpress.org/reference/functions/get_the_content/)
>
> Retrieve the post content. (Must be used in a Loop)
>
>
> An important difference from `the_content()` is that `get_the_content()` doe... |
87,933 | <p>I have a <code>register_nav_menus</code> call in my theme's functions.php:</p>
<pre><code>//register nav menu and footer nav.
register_nav_menus(
array(
'main-nav' => 'Main Navigation',
'footer-nav' => 'Footer Navigation'
)
);
</code></pre>
<p>This works fine, but I'd like to take t... | [
{
"answer_id": 87934,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>There is no need to create/update custom menus programmatically, just to do what you're trying to do.</p>\n... | 2013/02/22 | [
"https://wordpress.stackexchange.com/questions/87933",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11332/"
] | I have a `register_nav_menus` call in my theme's functions.php:
```
//register nav menu and footer nav.
register_nav_menus(
array(
'main-nav' => 'Main Navigation',
'footer-nav' => 'Footer Navigation'
)
);
```
This works fine, but I'd like to take the extra step of programatically creating a... | Figured out how to do this based on an answer to this question :
[Programmatically add a Navigation menu and menu items](https://wordpress.stackexchange.com/questions/44736/programmatically-add-a-navigation-menu-and-menu-items)
I adapted my answer to suit my own needs, i.e just to create the nav menu and assign it to ... |
87,948 | <p>I have a function on my site that it supposed to run when a new post is published (email push notification), with the exception of the same article updated (i.e <code>publish_to_publish</code> transition, I don't want to send unnecessary push notifications)</p>
<p>I know that I can use the {old_status} to {new_st... | [
{
"answer_id": 87955,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>If not, how do I tie multiple hooks to the same action? Do I just list\n them like so:</p>\... | 2013/02/22 | [
"https://wordpress.stackexchange.com/questions/87948",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11793/"
] | I have a function on my site that it supposed to run when a new post is published (email push notification), with the exception of the same article updated (i.e `publish_to_publish` transition, I don't want to send unnecessary push notifications)
I know that I can use the {old\_status} to {new\_status} action hooks, b... | >
> If not, how do I tie multiple hooks to the same action? Do I just list
> them like so:
>
>
>
> ```
> add_action('new_to_publish', 'save_new_post', 10, 1);
> add_action('future_to_publish', 'save_new_post', 10, 1);
> add_action('draft_to_publish', 'save_new_post', 10, 1);
>
> ```
>
>
This is exactly the way... |
87,950 | <p>I am running a woocommerce shop and I have products which are in multiple categories. I would like to show the category images on the single product pages. And also on the product overview page.</p>
<p>I only found how I can show the category image on the product category page:</p>
<pre><code><?php
if (is_prod... | [
{
"answer_id": 115593,
"author": "Filespit",
"author_id": 38588,
"author_profile": "https://wordpress.stackexchange.com/users/38588",
"pm_score": 1,
"selected": false,
"text": "<p>I had the same problem and I came up with this solution, hope it helps.</p>\n\n<pre><code><?php\n $ter... | 2013/02/22 | [
"https://wordpress.stackexchange.com/questions/87950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27869/"
] | I am running a woocommerce shop and I have products which are in multiple categories. I would like to show the category images on the single product pages. And also on the product overview page.
I only found how I can show the category image on the product category page:
```
<?php
if (is_product_category()){
global ... | I had the same problem and I came up with this solution, hope it helps.
```
<?php
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ){
$category_name = $term->name;
$category_thumbnail = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true);
$image ... |
87,951 | <p>I am trying to access the bookmarks created by a single user. The key is stored in the links table, attribute link_owner.</p>
<p>However, get_bookmarks() seems to load the entire table and all I am left with is to parse the table and filter the rows with a matching userid.</p>
<p>For my application I expect the nu... | [
{
"answer_id": 87962,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>Bookmarks were softly deprecated in 3.5 therefor it might not be very smart to use them any longer. The of... | 2013/02/22 | [
"https://wordpress.stackexchange.com/questions/87951",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27873/"
] | I am trying to access the bookmarks created by a single user. The key is stored in the links table, attribute link\_owner.
However, get\_bookmarks() seems to load the entire table and all I am left with is to parse the table and filter the rows with a matching userid.
For my application I expect the number of links t... | It looks like the default `get_bookmarks()`
<http://codex.wordpress.org/Function_Reference/get_bookmarks>
is using this query:
```
SELECT * FROM wp_links WHERE 1=1 AND link_visible = 'Y' ORDER BY link_name ASC;
```
You can check the function in `/wp-includes/bookmark.php`.
The `get_bookmarks()` function has `li... |
87,968 | <p>Since a week or two I keep receiving the following automatic email message sent from my WordPress website, and I'd like to know if it indicates any security hole and if there's anything I can do to stop it :</p>
<p>"A host, 79.148.238.85(you can check the host at <a href="http://ip-adress.com/ip_tracer/79.148.238.8... | [
{
"answer_id": 87962,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>Bookmarks were softly deprecated in 3.5 therefor it might not be very smart to use them any longer. The of... | 2013/02/22 | [
"https://wordpress.stackexchange.com/questions/87968",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | Since a week or two I keep receiving the following automatic email message sent from my WordPress website, and I'd like to know if it indicates any security hole and if there's anything I can do to stop it :
"A host, 79.148.238.85(you can check the host at <http://ip-adress.com/ip_tracer/79.148.238.85>) has been locke... | It looks like the default `get_bookmarks()`
<http://codex.wordpress.org/Function_Reference/get_bookmarks>
is using this query:
```
SELECT * FROM wp_links WHERE 1=1 AND link_visible = 'Y' ORDER BY link_name ASC;
```
You can check the function in `/wp-includes/bookmark.php`.
The `get_bookmarks()` function has `li... |
88,033 | <p>Before asking the question I want to tell you that I have already asked the question in <a href="https://stackoverflow.com/questions/15025213/wordpress-woocommerce-template-file-overiding">https://stackoverflow.com/questions/15025213/wordpress-woocommerce-template-file-overiding</a></p>
<p>I am using the <a href="h... | [
{
"answer_id": 88607,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 4,
"selected": false,
"text": "<p>I'm not quite sure if I understand your problem correctly, but here's my attempt to replicate it.</p>\n\n<p>... | 2013/02/23 | [
"https://wordpress.stackexchange.com/questions/88033",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27905/"
] | Before asking the question I want to tell you that I have already asked the question in <https://stackoverflow.com/questions/15025213/wordpress-woocommerce-template-file-overiding>
I am using the [WooCommerce](http://wordpress.org/extend/plugins/woocommerce/) plugin to develop a website. Everything is fine with WooCom... | By going through your question I want to tell you that [woocommerce](http://wordpress.org/extend/plugins/woocommerce/) will not use your custom template. It will use its own template.
As you want to use [wordpress advanced custom fields plugin](http://www.advancedcustomfields.com/) I want to tell you is that feature on... |
88,036 | <p>I have a textarea for small css enhancements on the plugins page i output them directly to the head. My Question is how to sanitize the CSS</p>
<p>i have validation function registered for the options with <code>register_setting</code>. On the setting page right now <code>$output['css'] = (string) $input['css'];</c... | [
{
"answer_id": 88042,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 0,
"selected": false,
"text": "<p>Most plugins I have seen actually don't care about this. They simply trust that someone who is going to be able... | 2013/02/23 | [
"https://wordpress.stackexchange.com/questions/88036",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25537/"
] | I have a textarea for small css enhancements on the plugins page i output them directly to the head. My Question is how to sanitize the CSS
i have validation function registered for the options with `register_setting`. On the setting page right now `$output['css'] = (string) $input['css'];` is all what i am doing. Sho... | You should not use esc\_attr in this way. It should be used only for escaping attributes in HTML tags.
As for the CSS it depends on who is the intended user. If you are doing it for a standalone site in which only the admin can edit the CSS, than you don't need to sanitize. But if it is intended for use in a network t... |
88,041 | <p>I've spent hours trying to figure this out and its driving me mad. I'm not great with php code so I'm not sure if I'm doing this the best way anyway...</p>
<p>It should be simple - I have built a custom theme, and all I want to do is display a thumbnail that links to a lightbox effect once clicked.</p>
<p>I want m... | [
{
"answer_id": 88051,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 1,
"selected": false,
"text": "<pre><code>add_action( 'wp_enqueue_scripts', 'brian_scripts' );\nif ( function_exists( 'add_theme_support' ) ) {\n... | 2013/02/23 | [
"https://wordpress.stackexchange.com/questions/88041",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27907/"
] | I've spent hours trying to figure this out and its driving me mad. I'm not great with php code so I'm not sure if I'm doing this the best way anyway...
It should be simple - I have built a custom theme, and all I want to do is display a thumbnail that links to a lightbox effect once clicked.
I want my dimensions to b... | ```
add_action( 'wp_enqueue_scripts', 'brian_scripts' );
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 214, 9999, false );
add_image_size('large', 500, 9999, true); //custom size
}
```
This code is in your functions.php?
The docs for [add\_theme\_sup... |
88,043 | <p>I have a plugin that inserts some rewrite rule in the .htaccess file. However, upon deactivating it, doesn't remove said rule. The rule is nested in <code># BEGIN My plugin</code> and <code># END My plugin</code>.</p>
<p>I want to create an uninstall.php file for this plugin to remove the rule created on acrivation... | [
{
"answer_id": 88045,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 3,
"selected": true,
"text": "<p>How do you add your rewrite rule?</p>\n\n<p>If you are adding it manually (opening the .htaccess and adding the ... | 2013/02/23 | [
"https://wordpress.stackexchange.com/questions/88043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8421/"
] | I have a plugin that inserts some rewrite rule in the .htaccess file. However, upon deactivating it, doesn't remove said rule. The rule is nested in `# BEGIN My plugin` and `# END My plugin`.
I want to create an uninstall.php file for this plugin to remove the rule created on acrivation.
I've never done this before. ... | How do you add your rewrite rule?
If you are adding it manually (opening the .htaccess and adding the lines by yourself in php) then you are also supposed to remove it manually. As you suggested the best way would then be to use regex.
If the rewrite rule was added through the Wordpress API using [add\_rewrite\_rule(... |
88,063 | <p>Good Day. I am using a Gallery shortcode in my wordpress site to display images.
Problem is that I wasnt the gallery to show only images from a certain category, for example category id 35. How do I specify it in the shortcode?</p>
<p>Shortcode: </p>
<pre><code> [custom_gallery style="1" source="**cat=%cat_id%*... | [
{
"answer_id": 88065,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": -1,
"selected": true,
"text": "<p>Rename the directory in which the plugin resides to disable it</p>\n"
},
{
"answer_id": 88077,
... | 2013/02/23 | [
"https://wordpress.stackexchange.com/questions/88063",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27604/"
] | Good Day. I am using a Gallery shortcode in my wordpress site to display images.
Problem is that I wasnt the gallery to show only images from a certain category, for example category id 35. How do I specify it in the shortcode?
Shortcode:
```
[custom_gallery style="1" source="**cat=%cat_id%**" link="image" descrip... | Rename the directory in which the plugin resides to disable it |
88,067 | <p>The Jetpack image widget does not offer a target option for links. Is there a way to open all Jetpack image widget links in a new window without hacking the plugin? Like through a hook or function?</p>
| [
{
"answer_id": 88092,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": true,
"text": "<p>There is <a href=\"http://plugins.svn.wordpress.org/jetpack/tags/2.1.2/modules/widgets/image-widget.php\" rel... | 2013/02/23 | [
"https://wordpress.stackexchange.com/questions/88067",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7318/"
] | The Jetpack image widget does not offer a target option for links. Is there a way to open all Jetpack image widget links in a new window without hacking the plugin? Like through a hook or function? | There is [no hook available](http://plugins.svn.wordpress.org/jetpack/tags/2.1.2/modules/widgets/image-widget.php) in the plugin.
One solution is to simply copy this Jetpack Widget and add the target option.
Another is through jQuery, in the file `/theme/functions.php`:
```
add_action( 'wp_enqueue_scripts', 'jetpack... |
88,081 | <p>I know it should work with custom table and I think it worked in previous development I believe. But this time I don't know whey it is not getting custom table with <code>$wpdb->tablename</code></p>
<p>Code:</p>
<pre><code>global $wpdb;
$items = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpd... | [
{
"answer_id": 88089,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 3,
"selected": false,
"text": "<p>You are supposed to store the table name in $wpdb before you can use it the way you did.</p>\n\n<pre><code>$wpd... | 2013/02/23 | [
"https://wordpress.stackexchange.com/questions/88081",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9821/"
] | I know it should work with custom table and I think it worked in previous development I believe. But this time I don't know whey it is not getting custom table with `$wpdb->tablename`
Code:
```
global $wpdb;
$items = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->review_media"));
```
This is not giv... | `$wpdb->tablename` works only with the tables initially present in a WordPress installation. These tables are defined in `wp-includes/wp-db.php`.
The second method you used is perfectly acceptable. |
88,116 | <p>Good Day</p>
<p>I am using excerpts in my wordpress theme. Now in wordpress's documentation, they say wordpress does not automatically add links for the excerpts, you have to manually add them like this:</p>
<p>Original excerpts file</p>
<pre><code> <div class="content">
<?php the_excerpt(); ?>
<... | [
{
"answer_id": 88141,
"author": "Matt van Andel",
"author_id": 15324,
"author_profile": "https://wordpress.stackexchange.com/users/15324",
"pm_score": 1,
"selected": false,
"text": "<p>For something like that, you need to use custom post metadata (aka \"Custom Fields\").</p>\n\n<p>There ... | 2013/02/23 | [
"https://wordpress.stackexchange.com/questions/88116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27604/"
] | Good Day
I am using excerpts in my wordpress theme. Now in wordpress's documentation, they say wordpress does not automatically add links for the excerpts, you have to manually add them like this:
Original excerpts file
```
<div class="content">
<?php the_excerpt(); ?>
</div>
```
Adding links
```
<div class="c... | For something like that, you need to use custom post metadata (aka "Custom Fields").
There are two steps:
1. Define a new custom field for the post (this will be where you enter your URL)
2. Output that custom field in your template.
**STEP 1**
First, you will need to define a new custom field to store your links. S... |
88,151 | <p>Im using Artiss Currency Converter to convert some numbers on my website. Im trying to out put <code>do_shortcode('[convert number=1 from="aud" to="jpy"]')</code> in 2 pages. One is a template page in <code>mythemefolder/newtemplate.php</code> and the other is in <code>mythemefolder/functions/single_product.php</cod... | [
{
"answer_id": 88155,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<pre><code>global $options;$fields;$options2;$options3;$symbols;\n</code></pre>\n\n<p>That is the same as:</p>\n... | 2013/02/24 | [
"https://wordpress.stackexchange.com/questions/88151",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27930/"
] | Im using Artiss Currency Converter to convert some numbers on my website. Im trying to out put `do_shortcode('[convert number=1 from="aud" to="jpy"]')` in 2 pages. One is a template page in `mythemefolder/newtemplate.php` and the other is in `mythemefolder/functions/single_product.php`
`do_shortcode('[convert number=1... | ```
global $options;$fields;$options2;$options3;$symbols;
```
That is the same as:
```
global $options;
$fields;
$options2;
$options3;
$symbols;
```
You've declared options as a global, but the other variables are just stated, they're doing nothing, those lines might as well not be there.
Next we have:
```
$fiel... |
88,182 | <p>I am using the following to display google maps using hotel_address custom field.</p>
<pre><code><iframe width="440" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?q=<?php the_field('hotel_address'); ?>&amp;iwloc=&amp;output=embed">... | [
{
"answer_id": 88183,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 0,
"selected": false,
"text": "<p>I would try</p>\n\n<pre><code>if ( $map && $map != \"\" )\n</code></pre>\n\n<p>as you set the variable,... | 2013/02/24 | [
"https://wordpress.stackexchange.com/questions/88182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27593/"
] | I am using the following to display google maps using hotel\_address custom field.
```
<iframe width="440" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?q=<?php the_field('hotel_address'); ?>&iwloc=&output=embed"></iframe><br /><small>
```
And ... | I would try
```
if ( $map && $map != "" )
```
as you set the variable, but it can also contain an empty string. |
88,225 | <p>I've written a shortcode plugin.
Basically the plugin has the following structure:</p>
<pre><code>PL::setup();
class PL {
public static function setup() {
add_shortcode("myshortcode", array ( __CLASS__,"myshortcode_handler"));
}
public static function myshortcode_handler(
... some variable assignment?
if (tim... | [
{
"answer_id": 88228,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>There are a number of ways to do this. One of those ways is to define a constant the first time your callback... | 2013/02/24 | [
"https://wordpress.stackexchange.com/questions/88225",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20109/"
] | I've written a shortcode plugin.
Basically the plugin has the following structure:
```
PL::setup();
class PL {
public static function setup() {
add_shortcode("myshortcode", array ( __CLASS__,"myshortcode_handler"));
}
public static function myshortcode_handler(
... some variable assignment?
if (time the shortcod... | In your shortcode callback `myshortcode_handler()`, use a static variable:
```
function myshortcode_handler()
{
static $first_call = TRUE;
if ( ! $first_call )
{
# callback was called earlier …
}
# set it to FALSE after you have handled the condition.
$first_call = FALSE;
return;... |
88,241 | <p>I'm trying to hide the featured image caption from showing. Currently, it'll show build the div (but not populate it because it's empty). What I'd like to do, ideally, is only show the div if someone has entered text in the Caption (<code>post_excerpt</code>) box in the Media Panel.</p>
<p>This is the code I'm work... | [
{
"answer_id": 88228,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>There are a number of ways to do this. One of those ways is to define a constant the first time your callback... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27555/"
] | I'm trying to hide the featured image caption from showing. Currently, it'll show build the div (but not populate it because it's empty). What I'd like to do, ideally, is only show the div if someone has entered text in the Caption (`post_excerpt`) box in the Media Panel.
This is the code I'm working off of:
```
... | In your shortcode callback `myshortcode_handler()`, use a static variable:
```
function myshortcode_handler()
{
static $first_call = TRUE;
if ( ! $first_call )
{
# callback was called earlier …
}
# set it to FALSE after you have handled the condition.
$first_call = FALSE;
return;... |
88,258 | <p>I am currently developing a multi-site plug-in for WordPress. I need to run a function when a new site is created.</p>
| [
{
"answer_id": 88260,
"author": "Jesse",
"author_id": 9145,
"author_profile": "https://wordpress.stackexchange.com/users/9145",
"pm_score": 3,
"selected": false,
"text": "<p>I guess you are looking for an action/filter.</p>\n\n<p><code>wpmu_new_blog</code> this action is fired in <code>w... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88258",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18746/"
] | I am currently developing a multi-site plug-in for WordPress. I need to run a function when a new site is created. | I guess you are looking for an action/filter.
`wpmu_new_blog` this action is fired in `wpmu_create_blog` function (wp-includes/ms-functions.php)
```
do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta );
``` |
88,276 | <p><strong>I use _x() now! I accepted the answer just because he understood right and was first. So don't get confused!</strong></p>
<pre><code>$like_me_on = __('Like me on %s', 'my-plugin');
$like_us_on = __('Like us on %s', 'my-plugin');
$follow_me_on = __('Follow me on %s', 'my-plugin');
$follow_us_on = __('Follow... | [
{
"answer_id": 88281,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 3,
"selected": true,
"text": "<p>It's interesting idea and I think that such approach will work for you. What I would recommend you is tha... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25537/"
] | **I use \_x() now! I accepted the answer just because he understood right and was first. So don't get confused!**
```
$like_me_on = __('Like me on %s', 'my-plugin');
$like_us_on = __('Like us on %s', 'my-plugin');
$follow_me_on = __('Follow me on %s', 'my-plugin');
$follow_us_on = __('Follow us on %s', 'my-plugin');
... | It's interesting idea and I think that such approach will work for you. What I would recommend you is that it will be better to use constructions like this:
```
// $singular = 1 - for 'me', 2 - for 'us'
$like_on = _n('Like me on %s', 'Like us on %s', $singular, 'my-plugin');
```
In this case it will be easier to und... |
88,292 | <p>I want to list x number of categories. I'm using <code>wp_list_categories</code> function, it generates the following markup</p>
<pre><code><li class="cat-item cat-item-1"><a href="#">Uncategorized</a></li>
<li class="cat-item cat-item-2"><a href="#">Category 2</a></li&g... | [
{
"answer_id": 88294,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": true,
"text": "<h2>List of possibilities</h2>\n\n<p>You got exactly two options to alter the output of <a href=\"http://queryposts.com... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88292",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24715/"
] | I want to list x number of categories. I'm using `wp_list_categories` function, it generates the following markup
```
<li class="cat-item cat-item-1"><a href="#">Uncategorized</a></li>
<li class="cat-item cat-item-2"><a href="#">Category 2</a></li>
<li class="cat-item cat-item-3"><a href="#">Category 3</a></li>
<li cl... | List of possibilities
---------------------
You got exactly two options to alter the output of [`wp_list_categories()`](http://queryposts.com/function/wp_list_categories/)
1. Use a filter after the MarkUp was generated and re-format it:
```
add_filter( 'wp_list_categories', 'wpse88292_reformat_list_cats', 10, 2 );
f... |
88,307 | <p>I've created a CPT, added capabilities to it and them to the Subscriber role successfully.</p>
<p>However the mapping is clearly not working because I get errors on publish and a Subscriber cannot edit their own posts (which the function below allows if they are the author). Why won't my map_meta_cap function work?... | [
{
"answer_id": 88397,
"author": "Ben Racicot",
"author_id": 18726,
"author_profile": "https://wordpress.stackexchange.com/users/18726",
"pm_score": 2,
"selected": true,
"text": "<p>Turns out it's a real bad idea to map your own meta capabilities. To solve this problem I ended up going th... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88307",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18726/"
] | I've created a CPT, added capabilities to it and them to the Subscriber role successfully.
However the mapping is clearly not working because I get errors on publish and a Subscriber cannot edit their own posts (which the function below allows if they are the author). Why won't my map\_meta\_cap function work?
I've ... | Turns out it's a real bad idea to map your own meta capabilities. To solve this problem I ended up going through the steps you would with a map\_meta\_cap function with TWO plugins.
Use [[Map Cap]](http://wordpress.org/extend/plugins/map-cap/) to automatically map the meta capabilities of my new custom post type to my... |
88,321 | <p>I'd like to hide the sidebar on a specific post (not page). How can I do this?</p>
<p>For background, I've searched quite a bit both on Google and here. I'm finding lots of solutions for showing different sidebars on posts vs. pages, or for showing (or hiding) a specific sidebar on a specific <em>page</em>, but n... | [
{
"answer_id": 88332,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 1,
"selected": false,
"text": "<p>One potential approach isn't so much "hiding" a sidebar as it is not including it.</p>\n<h1>Pages</h1>\n<p>... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88321",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/507/"
] | I'd like to hide the sidebar on a specific post (not page). How can I do this?
For background, I've searched quite a bit both on Google and here. I'm finding lots of solutions for showing different sidebars on posts vs. pages, or for showing (or hiding) a specific sidebar on a specific *page*, but nothing that's about... | Here's an idea I mentioned on Twitter.
```
function special_post_template( $template ) {
// Identify a single query for the special post
if ( is_single() && 10 == get_the_ID() )
$template = get_template_directory() . '/special-single.php';
return $template;
}
add_filter( 'template_include', 'special_post_t... |
88,337 | <p>There are over 200 posts tagged with the keyword "Apple."</p>
<p>Each tag page -- example.com/tag/apple/page/2/ -- shows 10 posts.</p>
<p>So there are 20 tag pages.</p>
<p>Is it possible to show all these 200 post (links) in one page? I don't want to show any of the excerpt -- just consolidate all those 200 links... | [
{
"answer_id": 88341,
"author": "Nilambar Sharma",
"author_id": 27998,
"author_profile": "https://wordpress.stackexchange.com/users/27998",
"pm_score": -1,
"selected": false,
"text": "<p>Its possible. You need to modify parameters in <code>query_posts()</code>. Use:</p>\n\n<pre><code>que... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7371/"
] | There are over 200 posts tagged with the keyword "Apple."
Each tag page -- example.com/tag/apple/page/2/ -- shows 10 posts.
So there are 20 tag pages.
Is it possible to show all these 200 post (links) in one page? I don't want to show any of the excerpt -- just consolidate all those 200 links in one page.
Appreciat... | This is what I would consider the correct solution, and is the solution alluded to by Milo's comment (if I am not mistaken).
```
function alter_ppp_for_tags_wpse_88337($qry) {
if ( is_tag() && $qry->is_main_query() ) {
$qry->set('posts_per_page','-1');
}
}
add_action('pre_get_posts','alter_ppp_for_tags_wpse_88... |
88,339 | <p>In my <code>functions.php</code> I have defined the following:</p>
<pre><code>add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 475, 475, true );
</code></pre>
<p>I have used the <strong>Regenerate Thumbnails</strong> plugin to regenerate the thumbnails. </p>
<p>When calling <code><?php the_post... | [
{
"answer_id": 88340,
"author": "user1576978",
"author_id": 23576,
"author_profile": "https://wordpress.stackexchange.com/users/23576",
"pm_score": 0,
"selected": false,
"text": "<p>I understand that you'd like to use <code><?php the_post_thumbnail(); ?></code>, but i'd use timthum... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88339",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12920/"
] | In my `functions.php` I have defined the following:
```
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 475, 475, true );
```
I have used the **Regenerate Thumbnails** plugin to regenerate the thumbnails.
When calling `<?php the_post_thumbnail(); ?>`, the images do not look cropped. When checking ... | I've figured this out. Appears as though I really wanted `add_image_size('post', 475, 475, true);` and then reran the **Regenerate Thumbnails** plugin. After sorting out a permissions error on `/wp-content/uploads`, this worked great.
Then in my theme, I just displayed this image size for the post thumbnail. `the_pos... |
88,368 | <p>I have following code</p>
<pre><code> <?php
$args = array(
'post_type' => 'attachment',
'numberposts' => 12,
'post_status' => null
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo '<li><a h... | [
{
"answer_id": 88340,
"author": "user1576978",
"author_id": 23576,
"author_profile": "https://wordpress.stackexchange.com/users/23576",
"pm_score": 0,
"selected": false,
"text": "<p>I understand that you'd like to use <code><?php the_post_thumbnail(); ?></code>, but i'd use timthum... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25217/"
] | I have following code
```
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => 12,
'post_status' => null
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo '<li><a href="'.get_permalink( $attachment->... | I've figured this out. Appears as though I really wanted `add_image_size('post', 475, 475, true);` and then reran the **Regenerate Thumbnails** plugin. After sorting out a permissions error on `/wp-content/uploads`, this worked great.
Then in my theme, I just displayed this image size for the post thumbnail. `the_pos... |
88,370 | <p>I have WooCommerce running on <a href="http://sergedenimes.com/shop/" rel="nofollow">this store</a>.</p>
<p>Although the default is to show 12 products on a page the client has asked for a "show all" button that will prevent the user having to use pagination to get to the other products.</p>
<p>Is there a function... | [
{
"answer_id": 88393,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>Just add the conditional check to your <code>functions.php</code> file:</p>\n\n<pre><code>if( isset( $_GET['showall'... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88370",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23620/"
] | I have WooCommerce running on [this store](http://sergedenimes.com/shop/).
Although the default is to show 12 products on a page the client has asked for a "show all" button that will prevent the user having to use pagination to get to the other products.
Is there a function I can run on the current page that will re... | Just add the conditional check to your `functions.php` file:
```
if( isset( $_GET['showall'] ) ){
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return -1;' ) );
} else {
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 12;' ) );
}
``` |
88,378 | <p>I'm using: get_theme_mod to show various pieces of info from the theme customizer, in the following format:</p>
<pre><code><a href=" <?php get_theme_mod( $name, $default ) ?> ">This is the link</a>
</code></pre>
<p>I would like to hide the whole line if that particular customizer field is empty.<... | [
{
"answer_id": 88380,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 3,
"selected": false,
"text": "<pre><code>$value = get_theme_mod( $name, $default );\nif ($value !== $default) { \n?>\n <a href=\" <?php e... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88378",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27788/"
] | I'm using: get\_theme\_mod to show various pieces of info from the theme customizer, in the following format:
```
<a href=" <?php get_theme_mod( $name, $default ) ?> ">This is the link</a>
```
I would like to hide the whole line if that particular customizer field is empty.
What could I wrap around the anchor to ac... | ```
$value = get_theme_mod( $name, $default );
if ($value !== $default) {
?>
<a href=" <?php echo $value; ?> ">This is the link</a>
<?php
}
``` |
88,383 | <p>For a Wordpress Theme I know javascript files (ending in .js) must be included using <code>wp_enqueue_script</code> in <code>functions.php</code> but how do I include additional javascript code? For example, say I need to add this:</p>
<pre><code>jQuery(function($){
jQuery.supersized({
slides:
[... | [
{
"answer_id": 88380,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 3,
"selected": false,
"text": "<pre><code>$value = get_theme_mod( $name, $default );\nif ($value !== $default) { \n?>\n <a href=\" <?php e... | 2013/02/25 | [
"https://wordpress.stackexchange.com/questions/88383",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17746/"
] | For a Wordpress Theme I know javascript files (ending in .js) must be included using `wp_enqueue_script` in `functions.php` but how do I include additional javascript code? For example, say I need to add this:
```
jQuery(function($){
jQuery.supersized({
slides:
[
'http://google.com',
... | ```
$value = get_theme_mod( $name, $default );
if ($value !== $default) {
?>
<a href=" <?php echo $value; ?> ">This is the link</a>
<?php
}
``` |
88,384 | <pre><code>foreach((get_the_category()) as $category) {
echo $category->cat_name . ', ';
}
</code></pre>
<p>So I'm echoing it like this because I don't want the categories to appear as hyperlinks, I just want the cat names.</p>
<p>The problem is I can't get rid of the last separator so it ends up like : categ... | [
{
"answer_id": 88380,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 3,
"selected": false,
"text": "<pre><code>$value = get_theme_mod( $name, $default );\nif ($value !== $default) { \n?>\n <a href=\" <?php e... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88384",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22450/"
] | ```
foreach((get_the_category()) as $category) {
echo $category->cat_name . ', ';
}
```
So I'm echoing it like this because I don't want the categories to appear as hyperlinks, I just want the cat names.
The problem is I can't get rid of the last separator so it ends up like : category, category, category,
I t... | ```
$value = get_theme_mod( $name, $default );
if ($value !== $default) {
?>
<a href=" <?php echo $value; ?> ">This is the link</a>
<?php
}
``` |
88,426 | <p>I have a custom walker menu.( See the code below)</p>
<p>I would like to have my nav menu like this</p>
<pre><code>----------------------------------
Home | link1 | link2 | link3 (5)
----------------------------------
</code></pre>
<p>Where <code>5</code> is the children count of link3.</p>
<p>Can someone help m... | [
{
"answer_id": 88433,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 2,
"selected": true,
"text": "<pre><code>function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {\n $item_html = '';\... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88426",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I have a custom walker menu.( See the code below)
I would like to have my nav menu like this
```
----------------------------------
Home | link1 | link2 | link3 (5)
----------------------------------
```
Where `5` is the children count of link3.
Can someone help me to implement this?
Here is my current custom nav... | ```
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
$item_html = '';
parent::start_el($item_html, $item, $depth, $args);
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( $locations['primary_navigation'] );
$menu_items = wp_get_nav_menu_items($menu->te... |
88,431 | <p>I am developing a theme which uses different image sizes. So I will be adding 7 image sizes, are they too many? Could that break anything like the image size selector, other parts of the interface or upload performance?</p>
<p>Also, is it a bad practice to remove the default image sizes from the theme for example a... | [
{
"answer_id": 88432,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 2,
"selected": false,
"text": "<p>For each image size, WordPress creates unique image on image upload. Than, when you register 7 image sizes... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88431",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24715/"
] | I am developing a theme which uses different image sizes. So I will be adding 7 image sizes, are they too many? Could that break anything like the image size selector, other parts of the interface or upload performance?
Also, is it a bad practice to remove the default image sizes from the theme for example adding foll... | For each image size, WordPress creates unique image on image upload. Than, when you register 7 image sizes, and upload single image, 8 unique images will appear in your wp-content/uploads directory. Is this too much for small blog with 100 posts to have 800 images on the server? But having 1000 posts? It depends.
Anot... |
88,447 | <p>Supposing I have this function which I hooked into my_get_users function:</p>
<pre><code>function define_users($group) {
//Query database for users belonging to a group
global $wpdb;
$users= $wpdb->get_results("SELECT user_id from $wpdb->usermeta WHERE meta_key='groupname' AND meta_value=$group",ARRAY_N);
... | [
{
"answer_id": 88452,
"author": "Jesse",
"author_id": 9145,
"author_profile": "https://wordpress.stackexchange.com/users/9145",
"pm_score": 1,
"selected": true,
"text": "<p>try this</p>\n\n<p><strong>$users = apply_filters('my_get_users',$group);</strong></p>\n"
},
{
"answer_id":... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88447",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20972/"
] | Supposing I have this function which I hooked into my\_get\_users function:
```
function define_users($group) {
//Query database for users belonging to a group
global $wpdb;
$users= $wpdb->get_results("SELECT user_id from $wpdb->usermeta WHERE meta_key='groupname' AND meta_value=$group",ARRAY_N);
return $users;
}
... | try this
**$users = apply\_filters('my\_get\_users',$group);** |
88,461 | <p>I want to customise the output of Yoast SEO breadcrumbs, I have this so far which works great:</p>
<pre><code>add_filter( 'wpseo_breadcrumb_single_link', 'ss_breadcrumb_single_link', 10, 2 );
function ss_breadcrumb_single_link( $link_output, $link ) {
$element = 'li';
$element = esc_attr( apply_filters( 'wp... | [
{
"answer_id": 88488,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": true,
"text": "<p>They are all null. You haven't set any of those variables. Here is your function.</p>\n\n<pre><code>function s... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88461",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27973/"
] | I want to customise the output of Yoast SEO breadcrumbs, I have this so far which works great:
```
add_filter( 'wpseo_breadcrumb_single_link', 'ss_breadcrumb_single_link', 10, 2 );
function ss_breadcrumb_single_link( $link_output, $link ) {
$element = 'li';
$element = esc_attr( apply_filters( 'wpseo_breadcrumb... | They are all null. You haven't set any of those variables. Here is your function.
```
function ss_breadcrumb_output() {
return apply_filters( 'ss_breadcrumb_output', '<' . $wrapper . $id . $class . ' xmlns:v="http://rdf.data-vocabulary.org/#">' . $output . '</' . $wrapper . '>' );
}
```
All of the variables in t... |
88,467 | <p>I have made a custom template to show the posts in "Products" category in a single page.I have some custom fields.I need to show the values of the custom fields in the page. I have used the get_post_custom_values as the following but i get an error as </p>
<pre><code>Warning: Invalid argument supplied for foreach()... | [
{
"answer_id": 88488,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": true,
"text": "<p>They are all null. You haven't set any of those variables. Here is your function.</p>\n\n<pre><code>function s... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88467",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28044/"
] | I have made a custom template to show the posts in "Products" category in a single page.I have some custom fields.I need to show the values of the custom fields in the page. I have used the get\_post\_custom\_values as the following but i get an error as
```
Warning: Invalid argument supplied for foreach() in C:\wamp... | They are all null. You haven't set any of those variables. Here is your function.
```
function ss_breadcrumb_output() {
return apply_filters( 'ss_breadcrumb_output', '<' . $wrapper . $id . $class . ' xmlns:v="http://rdf.data-vocabulary.org/#">' . $output . '</' . $wrapper . '>' );
}
```
All of the variables in t... |
88,496 | <p>I saw this post and the function helped to fix my pagination problem for the archives pages for my custom post type: <a href="https://wordpress.stackexchange.com/questions/81480/pagination-doesnt-show-up-for-custom-post-type">pagination doesn't show up for custom post type</a></p>
<p>The challenge I have is I n... | [
{
"answer_id": 88497,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>Have you consulted <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow\">the Cod... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88496",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28050/"
] | I saw this post and the function helped to fix my pagination problem for the archives pages for my custom post type: [pagination doesn't show up for custom post type](https://wordpress.stackexchange.com/questions/81480/pagination-doesnt-show-up-for-custom-post-type)
The challenge I have is I need this same type of fun... | Have you consulted [the Codex `WP_Query()` entry](http://codex.wordpress.org/Class_Reference/WP_Query)?
To query by custom field, you'll need to add [tax query parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) to your query args.
e.g.
```
'meta_key' => 'foobar'
```
To sort, y... |
88,499 | <p>I have 15 different wordpress sites installed on my server. They are independent installations , not multisite. I have developed a parent theme and copied it in all sites. Now whenever I have to make a change in parent theme, I have to access parent theme of all sites and make changes in each theme. Is it possible ... | [
{
"answer_id": 88522,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Create a separate directory and a (sub) domain for your themes.<br>\nLets say the domain is <code>themes.example.com</... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88499",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6028/"
] | I have 15 different wordpress sites installed on my server. They are independent installations , not multisite. I have developed a parent theme and copied it in all sites. Now whenever I have to make a change in parent theme, I have to access parent theme of all sites and make changes in each theme. Is it possible that... | Create a separate directory and a (sub) domain for your themes.
Lets say the domain is `themes.example.com`, and the directory is `/extra/wp-themes/`.
Now let all your installations use the new theme root. Or just do [the same for plugins](https://wordpress.stackexchange.com/a/15484/73) to manage all plugins from o... |
88,542 | <p>I'm trying to figure out if it's possible to get an excerpt from each post, grabbing the first paragraph from each one. I'm currently using the ACF plugin and have custom post types and custom fields.<br>
Here's my code:</p>
<pre><code>function custom_field_excerpt() {
global $post;
$text = get_field('news'... | [
{
"answer_id": 88565,
"author": "bcorkins",
"author_id": 6678,
"author_profile": "https://wordpress.stackexchange.com/users/6678",
"pm_score": 2,
"selected": true,
"text": "<p>Assuming your paragraphs are marked with <code><p></code> tags, which can be set in the ACF field options,... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88542",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28065/"
] | I'm trying to figure out if it's possible to get an excerpt from each post, grabbing the first paragraph from each one. I'm currently using the ACF plugin and have custom post types and custom fields.
Here's my code:
```
function custom_field_excerpt() {
global $post;
$text = get_field('news');
if ( '' ... | Assuming your paragraphs are marked with `<p>` tags, which can be set in the ACF field options, the following should work:
```
function custom_field_excerpt() {
global $post;
$text = get_field('news');
if ( '' != $text ) {
$start = strpos($text, '<p>'); // Locate the first paragraph tag
$en... |
88,548 | <p>I'm trying to implement the <a href="http://wordpress.org/extend/plugins/co-authors-plus/" rel="nofollow noreferrer">Co-Authors Plus</a> Plugin. It says that you will need to change some PHP in the theme. The documentation <a href="http://vip.wordpress.com/documentation/incorporate-co-authors-plus-template-tags-into... | [
{
"answer_id": 88565,
"author": "bcorkins",
"author_id": 6678,
"author_profile": "https://wordpress.stackexchange.com/users/6678",
"pm_score": 2,
"selected": true,
"text": "<p>Assuming your paragraphs are marked with <code><p></code> tags, which can be set in the ACF field options,... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88548",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28070/"
] | I'm trying to implement the [Co-Authors Plus](http://wordpress.org/extend/plugins/co-authors-plus/) Plugin. It says that you will need to change some PHP in the theme. The documentation [outlines the changes](http://vip.wordpress.com/documentation/incorporate-co-authors-plus-template-tags-into-your-theme/).
I believe... | Assuming your paragraphs are marked with `<p>` tags, which can be set in the ACF field options, the following should work:
```
function custom_field_excerpt() {
global $post;
$text = get_field('news');
if ( '' != $text ) {
$start = strpos($text, '<p>'); // Locate the first paragraph tag
$en... |
88,549 | <p>Hy, i make a slide for news, the question is how can i reduce the dathabase queries...ore how can i compress this code...</p>
<p><a href="http://s16.postimage.org/bswe0vrph/queries.jpg" rel="nofollow">http://s16.postimage.org/bswe0vrph/queries.jpg</a></p>
<pre><code><div id="featured" >
<ul class="ui-tabs... | [
{
"answer_id": 88570,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>You can try this version with <code>WP_Query()</code> called only once:</p>\n\n<pre><code><?php\n$args=array... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88549",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17885/"
] | Hy, i make a slide for news, the question is how can i reduce the dathabase queries...ore how can i compress this code...
<http://s16.postimage.org/bswe0vrph/queries.jpg>
```
<div id="featured" >
<ul class="ui-tabs-nav">
<li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1">
<?php
$recentPosts = new WP_Q... | You can try this version with `WP_Query()` called only once:
```
<?php
$args=array(
'post_type' => 'stiri',
'posts_per_page' => 5,
'taxonomy' => 'stire',
'stire' => 'articole-speciale'
);
$recentPosts = new WP_Query($args);
?>
<div id="featured" >
<ul class="ui-tabs-nav">
<?php $i=0; w... |
88,551 | <p>Is there any solution for using jQuery tabs within the native WordPress scripts? If you know of a way to get any method of jQuery tabs working on the frontend and the backend please share your solution.</p>
<p>I have tried implementing <a href="http://jqueryui.com/tabs/" rel="nofollow noreferrer">jQuery Tabs</a> (e... | [
{
"answer_id": 88562,
"author": "bcorkins",
"author_id": 6678,
"author_profile": "https://wordpress.stackexchange.com/users/6678",
"pm_score": 3,
"selected": true,
"text": "<p>jQuery UI Tabs are actually shipped with WordPress core, so implementing them is quite easy. It sounds like you'... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88551",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9579/"
] | Is there any solution for using jQuery tabs within the native WordPress scripts? If you know of a way to get any method of jQuery tabs working on the frontend and the backend please share your solution.
I have tried implementing [jQuery Tabs](http://jqueryui.com/tabs/) (example source available at link)
**Dependencie... | jQuery UI Tabs are actually shipped with WordPress core, so implementing them is quite easy. It sounds like you're only trying to utilize the tabs on the admin side, so a very basic setup would look something like:
**In functions.php:**
```
function my_enqueue_scripts($hook) {
// Only load the scripts on the pag... |
88,556 | <p>How can someone restrict the images which appear in the v3.5 Media Library modal to only show those that are attached to a specific post id?</p>
<p>I'm creating a front-end management template that allows multiple authors to edit any particular post, hence the need to restrict what is shown on a post-by-post basis ... | [
{
"answer_id": 89040,
"author": "Ünsal Korkmaz",
"author_id": 1372,
"author_profile": "https://wordpress.stackexchange.com/users/1372",
"pm_score": 3,
"selected": false,
"text": "<p>I am not sure is this what you are looking for. This code will "lock" uploads to show only “Uplo... | 2013/02/26 | [
"https://wordpress.stackexchange.com/questions/88556",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1057/"
] | How can someone restrict the images which appear in the v3.5 Media Library modal to only show those that are attached to a specific post id?
I'm creating a front-end management template that allows multiple authors to edit any particular post, hence the need to restrict what is shown on a post-by-post basis rather tha... | I am not sure is this what you are looking for. This code will "lock" uploads to show only “Uploaded to this post” in media panel
```
add_action( 'admin_footer-post-new.php', 'firmasite_mediapanel_lock_uploaded' );
add_action( 'admin_footer-post.php', 'firmasite_mediapanel_lock_uploaded' );
function firmasite_mediapan... |
88,574 | <p>If I wanted to get the category ID for the current post, I would use something like this:</p>
<pre><code><?php foreach((get_the_category()) as $category) { echo $category->cat_ID . ' '; } ?>
</code></pre>
<p>How can I do the same for a a term ID from a specific Taxonomy?</p>
| [
{
"answer_id": 88575,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 1,
"selected": false,
"text": "<p>See <a href=\"http://codex.wordpress.org/Function_Reference/get_the_terms\" rel=\"nofollow\"><code>get_th... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88574",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35798/"
] | If I wanted to get the category ID for the current post, I would use something like this:
```
<?php foreach((get_the_category()) as $category) { echo $category->cat_ID . ' '; } ?>
```
How can I do the same for a a term ID from a specific Taxonomy? | Thanks helgatheviking, it didn't work as is but you definitely set me on the right path. I got it working by doing the following:
```
<?php foreach((get_the_terms($post->ID, 'your-taxonomy-here')) as $term) { echo $term->term_id. ''; } ?>
```
Replace "your-taxonomy-here" with your own and your ready to go. |
88,593 | <p>i made a website by wordpress and i uploaded it to ftp file </p>
<blockquote>
<p>public html</p>
</blockquote>
<p>my problem is that i made a css file that include all the other css files but when i tested the website i found that the wordpress didnt see the it saw only the first one what should i do to make the... | [
{
"answer_id": 88603,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": false,
"text": "<p>Try to use relative URLs to your imported css files. So try to remove first <code>/</code> from each imp... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88593",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27084/"
] | i made a website by wordpress and i uploaded it to ftp file
>
> public html
>
>
>
my problem is that i made a css file that include all the other css files but when i tested the website i found that the wordpress didnt see the it saw only the first one what should i do to make the website see my files this is wh... | Try to use relative URLs to your imported css files. So try to remove first `/` from each import URL:
```
@import url('styles/forms.css');
@import url('styles/tables.css');
@import url('styles/homepage.css');
@import url('styles/reset.css');
@import url('styles/stimenu.css');
@import url('styles/layout.css');
@import ... |
88,599 | <p>I have a form on my site, created using Contact Form 7 with Captcha. Contents of the form when POSTed are being sent to a PHP script, the "action" attribute of the form is set to <code>themes/<themename>/<filename>.php</code> </p>
<p>We have been receiving a lot of spam, it seems that someone can handc... | [
{
"answer_id": 88605,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>If you are looking for a solution that will detect spam without blocking legitimate users then Use akismet... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28090/"
] | I have a form on my site, created using Contact Form 7 with Captcha. Contents of the form when POSTed are being sent to a PHP script, the "action" attribute of the form is set to `themes/<themename>/<filename>.php`
We have been receiving a lot of spam, it seems that someone can handcraft the form and use it to send s... | You must hook the form using `wpcf7_before_send_mail` and add your PHP code to functions.php (since the script is already in your theme folder)? You won't lose any of CF7's abilities.
```
function wpse_process_form( &WPCF7Object ){
#process your form here
}
add_action('wpcf7_before_send_mail', 'wpse_process_form' )... |
88,604 | <p>I am trying to build a Wordpress theme with boostrap, but the nav menu is giving me some trouble. I would like the dropdown to work like boostraps dropdown, but I do not know how to do this.</p>
<p>This is my menu:</p>
<pre><code><ul class="nav">
<?php wp_nav_menu( array( 'items_wrap' => '%3$s' ) );... | [
{
"answer_id": 88612,
"author": "Sunyatasattva",
"author_id": 24240,
"author_profile": "https://wordpress.stackexchange.com/users/24240",
"pm_score": 4,
"selected": true,
"text": "<p>You will need to write a custom walker extending <code>Walker_Nav_Menu</code>, more or less like so:</p>\... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88604",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17400/"
] | I am trying to build a Wordpress theme with boostrap, but the nav menu is giving me some trouble. I would like the dropdown to work like boostraps dropdown, but I do not know how to do this.
This is my menu:
```
<ul class="nav">
<?php wp_nav_menu( array( 'items_wrap' => '%3$s' ) ); ?>
</ul>
```
This is what I ha... | You will need to write a custom walker extending `Walker_Nav_Menu`, more or less like so:
```
class My_Custom_Nav_Walker extends Walker_Nav_Menu {
function start_lvl(&$output, $depth = 0, $args = array()) {
$output .= "\n<ul class=\"dropdown-menu\">\n";
}
function start_el(&$output, $item, $depth = 0,... |
88,609 | <pre><code> <ul>
<li class="selected">Link 1<img src="images/slash.png" /></li>
<li>Link 2<img src="images/slash.png" /></li>
<li>Link 3<img src="images/slash.png" /></li>
<li>Link 4<img src="images/slash.png" />&... | [
{
"answer_id": 88615,
"author": "Amit Sharma",
"author_id": 28093,
"author_profile": "https://wordpress.stackexchange.com/users/28093",
"pm_score": 0,
"selected": false,
"text": "<p>If this is the wp_nav_menu you're talking about, then you should be looking at the link_after property of ... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88609",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27125/"
] | ```
<ul>
<li class="selected">Link 1<img src="images/slash.png" /></li>
<li>Link 2<img src="images/slash.png" /></li>
<li>Link 3<img src="images/slash.png" /></li>
<li>Link 4<img src="images/slash.png" /></li>
<li>Link 5<img src="images/slash.png" /></li>
<li>Link 6<i... | If your `slash.png` is merely *cosmetic*, I would advise you use the CSS `::after` pseudo-element, which matches a virtual last-child of the element in question. Then use the `:last-child` selector to avoid it displaying in the last item. It should be something like so:
```
ul.nav li::after {
background: url('imag... |
88,613 | <p>I am generating the following notice in my options.php when testing my theme in wp_debug mode.</p>
<p>I can see where the problem is but do not know how to fix this issue? </p>
<p>It seems the non object is being called from the taxonomy array in options.php as the array cannot find the term_id because a post and ... | [
{
"answer_id": 88615,
"author": "Amit Sharma",
"author_id": 28093,
"author_profile": "https://wordpress.stackexchange.com/users/28093",
"pm_score": 0,
"selected": false,
"text": "<p>If this is the wp_nav_menu you're talking about, then you should be looking at the link_after property of ... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27358/"
] | I am generating the following notice in my options.php when testing my theme in wp\_debug mode.
I can see where the problem is but do not know how to fix this issue?
It seems the non object is being called from the taxonomy array in options.php as the array cannot find the term\_id because a post and or category has... | If your `slash.png` is merely *cosmetic*, I would advise you use the CSS `::after` pseudo-element, which matches a virtual last-child of the element in question. Then use the `:last-child` selector to avoid it displaying in the last item. It should be something like so:
```
ul.nav li::after {
background: url('imag... |
88,620 | <p>When I try to upload a <code>*.prc</code> file type, I get this error: </p>
<blockquote>
<p>Sorry, this file type is not permitted for security reasons. </p>
</blockquote>
<p>How can I fix this?</p>
| [
{
"answer_id": 88638,
"author": "Mike Madern",
"author_id": 24806,
"author_profile": "https://wordpress.stackexchange.com/users/24806",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://howto.blbosti.com/2010/03/wordpress-modify-the-upload-list-of-allowed-file-types/\" rel=\... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28101/"
] | When I try to upload a `*.prc` file type, I get this error:
>
> Sorry, this file type is not permitted for security reasons.
>
>
>
How can I fix this? | [This article](http://howto.blbosti.com/2010/03/wordpress-modify-the-upload-list-of-allowed-file-types/) explains a method in which you can add a file type to the list of allowed file types.
Copy and paste the following code into your `functions.php`:
```
add_filter('upload_mimes', 'custom_upload_mimes');
function c... |
88,623 | <p>Short version:</p>
<ul>
<li>Step 1/ i am using contact form 7 to collect some user data and i
insert the data into a custom database table.</li>
<li>Step 2/ only the
custom table needs to be altered/updated. In fact at the moment only
one column needs to be updated by hand</li>
</ul>
<p>The client wants a very sim... | [
{
"answer_id": 88631,
"author": "Simon",
"author_id": 10889,
"author_profile": "https://wordpress.stackexchange.com/users/10889",
"pm_score": 2,
"selected": false,
"text": "<p>I'll answer this from a security perspective, please add additional detail to the question if you are more inter... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88623",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9936/"
] | Short version:
* Step 1/ i am using contact form 7 to collect some user data and i
insert the data into a custom database table.
* Step 2/ only the
custom table needs to be altered/updated. In fact at the moment only
one column needs to be updated by hand
The client wants a very simple UI to update the data. The clie... | I'll answer this from a security perspective, please add additional detail to the question if you are more interested in the user interaction/UI/etc. side of things.
You could argue that a password protected page offers far less security when compared to a default WordPress user, therefore you might want to setup up o... |
88,645 | <p>I am trying to echo the number of posts for the current month from all categories but it isnt working.</p>
<pre><code><?php
$month = date('m');
$year = date('Y');
$countposts = get_posts('post_type=post&year=' . $year . '&monthnum=' . $month . '&cat=3');
echo 'New posts ' . count($countposts);
?>... | [
{
"answer_id": 88651,
"author": "Sunyatasattva",
"author_id": 24240,
"author_profile": "https://wordpress.stackexchange.com/users/24240",
"pm_score": 2,
"selected": false,
"text": "<p>This is because the paramenter <code>posts_per_page</code> of the <code>get_posts()</code> function <a h... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88645",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17284/"
] | I am trying to echo the number of posts for the current month from all categories but it isnt working.
```
<?php
$month = date('m');
$year = date('Y');
$countposts = get_posts('post_type=post&year=' . $year . '&monthnum=' . $month . '&cat=3');
echo 'New posts ' . count($countposts);
?>
```
category 3 is a parent ca... | This is because the paramenter `posts_per_page` of the `get_posts()` function [defaults to 5](http://codex.wordpress.org/Function_Reference/get_posts). Set it to -1 in your `$args`. |
88,654 | <pre><code> Array
(
[post] => Array
(
[jw_objective] => Exposure to e<b>nd to end development</b> of various applications; right from requirement analysis to system study, designing, coding, testing, de-bugging, <i>documentation and i</i>mplementation. Adept in &l... | [
{
"answer_id": 101352,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 2,
"selected": false,
"text": "<p>Is it that your tags are being stripped, or that you aren't preparing them prior to displaying them. Try w... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28105/"
] | ```
Array
(
[post] => Array
(
[jw_objective] => Exposure to e<b>nd to end development</b> of various applications; right from requirement analysis to system study, designing, coding, testing, de-bugging, <i>documentation and i</i>mplementation. Adept in <u>handling the design and coding funct... | Is it that your tags are being stripped, or that you aren't preparing them prior to displaying them. Try wrapping your output:
```
echo apply_filters('the_content', get_post_meta($post->ID, '_custom_field_name', true));
``` |
88,659 | <p>I have a snippet of code I've written in the functions.php file which is simply to remove menu pages if the user cannot activate plugins. It works as intended; however it is showing a PHP error in the admin area only if the logged in user is an administrator.</p>
<p>Here's the code snippet:</p>
<pre><code><?ph... | [
{
"answer_id": 88662,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You are only defining your function when a user cannot 'activate_plugins' but you are attempting to use the f... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88659",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23672/"
] | I have a snippet of code I've written in the functions.php file which is simply to remove menu pages if the user cannot activate plugins. It works as intended; however it is showing a PHP error in the admin area only if the logged in user is an administrator.
Here's the code snippet:
```
<?php
/************ Remove ad... | Put the `add_action` line inside the `if (!current_user_can('activate_plugins') ) {`:
```
<?php
/************ Remove admin menu items from anyone who isn't an admin ************/
if (!current_user_can('activate_plugins') ) {
function my_remove_menu_pages() {
remove_menu_page('link-manager.php');
... |
88,666 | <p>I've a problem. I've tried a lot of things but I could not find a solution.
I use query_vars parameters in <a href="http://www.oyunkayit.com/oyunara?ara=s4&kategori=1" rel="nofollow">this page</a> and there isn't any problem. But i don't use different parameters or the same parameters in different custom page (.... | [
{
"answer_id": 88662,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You are only defining your function when a user cannot 'activate_plugins' but you are attempting to use the f... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88666",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28117/"
] | I've a problem. I've tried a lot of things but I could not find a solution.
I use query\_vars parameters in [this page](http://www.oyunkayit.com/oyunara?ara=s4&kategori=1) and there isn't any problem. But i don't use different parameters or the same parameters in different custom page (../videolar). Parameter value is ... | Put the `add_action` line inside the `if (!current_user_can('activate_plugins') ) {`:
```
<?php
/************ Remove admin menu items from anyone who isn't an admin ************/
if (!current_user_can('activate_plugins') ) {
function my_remove_menu_pages() {
remove_menu_page('link-manager.php');
... |
88,668 | <p>I have a short function to clean up the WP Nav Menu. </p>
<pre><code>add_filter('nav_menu_css_class','strip_classes');
function strip_classes($a){
return (in_array('menu-item-71',$a))? array('contact') : array();
}
</code></pre>
<p>The class name <code>menu-item-71</code> of a certain nav point is replaced ... | [
{
"answer_id": 88662,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You are only defining your function when a user cannot 'activate_plugins' but you are attempting to use the f... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21110/"
] | I have a short function to clean up the WP Nav Menu.
```
add_filter('nav_menu_css_class','strip_classes');
function strip_classes($a){
return (in_array('menu-item-71',$a))? array('contact') : array();
}
```
The class name `menu-item-71` of a certain nav point is replaced by `contact`. Now I’d like a second n... | Put the `add_action` line inside the `if (!current_user_can('activate_plugins') ) {`:
```
<?php
/************ Remove admin menu items from anyone who isn't an admin ************/
if (!current_user_can('activate_plugins') ) {
function my_remove_menu_pages() {
remove_menu_page('link-manager.php');
... |
88,674 | <p>I have a meta key called 'prijs' in each post. The value of this meta key consist of numbers in the follow structure: 2,100.00</p>
<p>I want to remove the comma in the meta value to get this output: 2100.00</p>
<p>So, i created a function but it doesn't work:</p>
<pre><code>add_action('wp_insert_post', 'deleteCom... | [
{
"answer_id": 88662,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You are only defining your function when a user cannot 'activate_plugins' but you are attempting to use the f... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88674",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28122/"
] | I have a meta key called 'prijs' in each post. The value of this meta key consist of numbers in the follow structure: 2,100.00
I want to remove the comma in the meta value to get this output: 2100.00
So, i created a function but it doesn't work:
```
add_action('wp_insert_post', 'deleteCommaDB');
function deleteComma... | Put the `add_action` line inside the `if (!current_user_can('activate_plugins') ) {`:
```
<?php
/************ Remove admin menu items from anyone who isn't an admin ************/
if (!current_user_can('activate_plugins') ) {
function my_remove_menu_pages() {
remove_menu_page('link-manager.php');
... |
88,700 | <p>When you hover over my drop-down menu using IE8 or IE9, the menu div will display behind the YouTube embedment. It works fine on all other browsers.</p>
<p>Upon research, I found out that many others have <a href="http://goo.gl/aIbUQ" rel="nofollow">the same problem</a> and the solution is to set the <code>wmode</c... | [
{
"answer_id": 94359,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>You can filter the HTML output for oEmbed with <code>oembed_result</code>. Now test the HTTP host of the URL for <code>... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24875/"
] | When you hover over my drop-down menu using IE8 or IE9, the menu div will display behind the YouTube embedment. It works fine on all other browsers.
Upon research, I found out that many others have [the same problem](http://goo.gl/aIbUQ) and the solution is to set the `wmode` attribute to `transparent`. So for instanc... | You can filter the HTML output for oEmbed with `oembed_result`. Now test the HTTP host of the URL for `www.youtube.com` and add the parameter.
The oEmbed result is cached in a post meta field to avoid too many requests. To update old posts I have added an activation helper that clears those cached content for Youtube ... |
88,709 | <p>I'm using Wishlist Member plugin and I'm building a function which compares user_levels and post_levels, but I can't get my function to work:</p>
<pre><code>check_user_access($userid, $postid){
// get user_levels
$user_levels = WLMAPI::GetUserLevels($userid);
// get the post levels
$post_level... | [
{
"answer_id": 88756,
"author": "jfacemyer",
"author_id": 12660,
"author_profile": "https://wordpress.stackexchange.com/users/12660",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe because $user_levels is an array?</p>\n\n<p>Try something like:</p>\n\n<pre><code>// Compare user_leve... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/420/"
] | I'm using Wishlist Member plugin and I'm building a function which compares user\_levels and post\_levels, but I can't get my function to work:
```
check_user_access($userid, $postid){
// get user_levels
$user_levels = WLMAPI::GetUserLevels($userid);
// get the post levels
$post_levels = WLMAPI::... | Maybe because $user\_levels is an array?
Try something like:
```
// Compare user_levels with post_level
$result = '';
foreach($user_levels as $user_level) {
$result .= array_search($user_level, $post_levels);
}
if ($result) {
return true;
}
``` |
88,718 | <p>Maybe I'm not getting the whole concept, but is there a way to modify a Custom Post Type so that it includes other 'fields' like a 'real' db table. I don't mean a Custom Field (get_meta)... I mean inside the table that can be manipulated with rules. I want to make a post type with several -mandatory- fields.</p>
<p... | [
{
"answer_id": 88756,
"author": "jfacemyer",
"author_id": 12660,
"author_profile": "https://wordpress.stackexchange.com/users/12660",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe because $user_levels is an array?</p>\n\n<p>Try something like:</p>\n\n<pre><code>// Compare user_leve... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88718",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17248/"
] | Maybe I'm not getting the whole concept, but is there a way to modify a Custom Post Type so that it includes other 'fields' like a 'real' db table. I don't mean a Custom Field (get\_meta)... I mean inside the table that can be manipulated with rules. I want to make a post type with several -mandatory- fields.
eg.
```... | Maybe because $user\_levels is an array?
Try something like:
```
// Compare user_levels with post_level
$result = '';
foreach($user_levels as $user_level) {
$result .= array_search($user_level, $post_levels);
}
if ($result) {
return true;
}
``` |
88,720 | <p>I'm looking for a way to separate my users and usermeta table to be in a different database than my main WP install. The end goal is sharing these table over a number of WP installs.</p>
<p>From what I read, HyperDB should allow for this, however their documentation is a little sparse when it comes to creating and ... | [
{
"answer_id": 89024,
"author": "Crazycoolcam",
"author_id": 28144,
"author_profile": "https://wordpress.stackexchange.com/users/28144",
"pm_score": 2,
"selected": false,
"text": "<p>Problem solved. Here is what I did:</p>\n\n<pre><code>$wpdb->add_database(array( //Connect to Users Da... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88720",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28144/"
] | I'm looking for a way to separate my users and usermeta table to be in a different database than my main WP install. The end goal is sharing these table over a number of WP installs.
From what I read, HyperDB should allow for this, however their documentation is a little sparse when it comes to creating and linking da... | Problem solved. Here is what I did:
```
$wpdb->add_database(array( //Connect to Users Database
'host' => DB_HOST, // I am using the same host for my two DBs
'user' => DB_USER, // I am using the same username for my two DBs
'password' => DB_PASSWORD, // I am using the same p/w for my two DBs
'na... |
88,735 | <p>I have been reading around and cannot seem to figure this out.</p>
<p>Everything is working fine except that pagination seems to not work, I am adding a second rewrite rule, shouldn't this fix that?</p>
<p>I can get to the first page fine, but any page beyond throws a 404.</p>
<p>Here is my code:</p>
<pre><code>... | [
{
"answer_id": 89024,
"author": "Crazycoolcam",
"author_id": 28144,
"author_profile": "https://wordpress.stackexchange.com/users/28144",
"pm_score": 2,
"selected": false,
"text": "<p>Problem solved. Here is what I did:</p>\n\n<pre><code>$wpdb->add_database(array( //Connect to Users Da... | 2013/02/27 | [
"https://wordpress.stackexchange.com/questions/88735",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18241/"
] | I have been reading around and cannot seem to figure this out.
Everything is working fine except that pagination seems to not work, I am adding a second rewrite rule, shouldn't this fix that?
I can get to the first page fine, but any page beyond throws a 404.
Here is my code:
```
// Rewrite the Sermon URL
function ... | Problem solved. Here is what I did:
```
$wpdb->add_database(array( //Connect to Users Database
'host' => DB_HOST, // I am using the same host for my two DBs
'user' => DB_USER, // I am using the same username for my two DBs
'password' => DB_PASSWORD, // I am using the same p/w for my two DBs
'na... |
88,746 | <p>So I have a bunch of posts assigned categories like: a main one and uncategorized one (which I forgot to unselect).</p>
<p>The problem is that i'm using <code>%category%/%postname%</code> as permalink which will use the lower ID category in permalink, which obviously will be <code>uncategorized</code>.</p>
<p>How ... | [
{
"answer_id": 89024,
"author": "Crazycoolcam",
"author_id": 28144,
"author_profile": "https://wordpress.stackexchange.com/users/28144",
"pm_score": 2,
"selected": false,
"text": "<p>Problem solved. Here is what I did:</p>\n\n<pre><code>$wpdb->add_database(array( //Connect to Users Da... | 2013/02/28 | [
"https://wordpress.stackexchange.com/questions/88746",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27848/"
] | So I have a bunch of posts assigned categories like: a main one and uncategorized one (which I forgot to unselect).
The problem is that i'm using `%category%/%postname%` as permalink which will use the lower ID category in permalink, which obviously will be `uncategorized`.
How do I unassign `uncategorized` category ... | Problem solved. Here is what I did:
```
$wpdb->add_database(array( //Connect to Users Database
'host' => DB_HOST, // I am using the same host for my two DBs
'user' => DB_USER, // I am using the same username for my two DBs
'password' => DB_PASSWORD, // I am using the same p/w for my two DBs
'na... |
88,760 | <p>On the <a href="http://codex.wordpress.org/WordPress_Optimization/WordPress_Performance" rel="nofollow">WordPress Optimization/Performance page</a> it suggests hardcoding static variables rather than referencing them through WordPress functions. I think I get the rationale behind that.</p>
<p>But what about doing s... | [
{
"answer_id": 88761,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>There is trade off between cpu & memory optimization. If you store values in variables rather than cal... | 2013/02/28 | [
"https://wordpress.stackexchange.com/questions/88760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9058/"
] | On the [WordPress Optimization/Performance page](http://codex.wordpress.org/WordPress_Optimization/WordPress_Performance) it suggests hardcoding static variables rather than referencing them through WordPress functions. I think I get the rationale behind that.
But what about doing something like the following:
```
fu... | This is a PHP question not related at all to WP, but since it was upvoted....
TL;Dr version - Compilres do this kind of micro optimizations much better then you, no point in even trying.
lets look at what compilers will do with your question code
```
// is this less efficient
$meta = get_post_meta($post->ID,'meta');... |
88,784 | <p>I've registered a new taxonomy for my custom post type, and now I'm trying to edit the taxonomy table.</p>
<p>I've successfully removed the description column but I can't figure it out <strong>how to edit column width for the column that shows the number of custom post types found</strong> in that particular taxono... | [
{
"answer_id": 88788,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>Add following code in functions.php file to achieve this :</p>\n\n<pre><code>add_action('admin_head', 'my_... | 2013/02/28 | [
"https://wordpress.stackexchange.com/questions/88784",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25095/"
] | I've registered a new taxonomy for my custom post type, and now I'm trying to edit the taxonomy table.
I've successfully removed the description column but I can't figure it out **how to edit column width for the column that shows the number of custom post types found** in that particular taxonomy. The column's CSS cl... | This should do the trick:
```
add_action( 'admin_print_styles', 'cor_admin_print_styles', 200 );
function cor_admin_print_styles() {
$screen = get_current_screen();
if ( 'edit-tags' === $screen->base && 'department' === $screen->taxonomy ) {
echo <<<EOF
<style>
.fixed .column-posts {
width:... |
88,793 | <p>If I have WordPress installation in English, then I can define my theme translation file in the wp-config.php file with following:</p>
<pre><code>define('WPLANG', 'sv_SE');
</code></pre>
<p>But if I have WordPress installed in the local language then there is already WordPress translation file defined there, then ... | [
{
"answer_id": 88794,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": true,
"text": "<p>It all depends a bit if your current theme already supports localization.</p>\n\n<p>Does your theme's function file... | 2013/02/28 | [
"https://wordpress.stackexchange.com/questions/88793",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28161/"
] | If I have WordPress installation in English, then I can define my theme translation file in the wp-config.php file with following:
```
define('WPLANG', 'sv_SE');
```
But if I have WordPress installed in the local language then there is already WordPress translation file defined there, then how can I define my theme ... | It all depends a bit if your current theme already supports localization.
Does your theme's function file contain something like this?
`load_theme_textdomain( 'twentytwelve', get_template_directory() . '/languages' );`
If not, add it in there. And change `twentytwelve` to your `theme-directory-name`.
After that cre... |
88,801 | <p>I have created a widget that has quite a few settings, and so I am trying to create a tabbed menu (using jQuery UI) inside the widget settings of the admin page.</p>
<p>The problem is basically that tabs don't happen (i.e. the a tags just appear on the top and the related divs underneath them).</p>
<p>This is a sh... | [
{
"answer_id": 88830,
"author": "Khior",
"author_id": 28172,
"author_profile": "https://wordpress.stackexchange.com/users/28172",
"pm_score": 0,
"selected": false,
"text": "<p>It looks as though you might be including your js before the jQuery UI library is loaded. To fix the issue, I wo... | 2013/02/28 | [
"https://wordpress.stackexchange.com/questions/88801",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28164/"
] | I have created a widget that has quite a few settings, and so I am trying to create a tabbed menu (using jQuery UI) inside the widget settings of the admin page.
The problem is basically that tabs don't happen (i.e. the a tags just appear on the top and the related divs underneath them).
This is a shortened version o... | Ok, so, for some reason I can't comprehend, the answer is that the div element containing the tabs should have a **class** and not an **id** for jQuery UI to work properly, as such:
```
<div class="mytabs">
```
and
```
jQuery(document).ready(function($) {
$(".mytabs").tabs();
});
```
Just for the record, the... |
88,811 | <p>I am currently using a plug-in called Wishlist member. It allows you to create membership levels in WordPress. I want to be able to display different content on a page depending on if the user is added to two levels.</p>
<p>Am using the code of "Bainternet":</p>
<p>// get the current user level from WP more import... | [
{
"answer_id": 89001,
"author": "Bob Tolbert",
"author_id": 28237,
"author_profile": "https://wordpress.stackexchange.com/users/28237",
"pm_score": 0,
"selected": false,
"text": "<p>There was a plugin that was available to wishlist insider member called Wishlist Shortcodes Plus.</p>\n\n<... | 2013/02/28 | [
"https://wordpress.stackexchange.com/questions/88811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26147/"
] | I am currently using a plug-in called Wishlist member. It allows you to create membership levels in WordPress. I want to be able to display different content on a page depending on if the user is added to two levels.
Am using the code of "Bainternet":
// get the current user level from WP more important is global $us... | If you're running the latest version of WishList Member, it now has built-in API functions for stuff like this. Using those, you'd do this:
```
wp_get_current_user();
$gold_sku = 123456789;
$silver_sku = 987654321;
$user_id = $user->ID;
if ( wlmapi_is_user_a_member($gold_sku, $user_id) ) {
//Do gold stuff here
... |
88,834 | <p>I added infinite scroll support of the Jetpack plugin to my own theme using <a href="http://jetpack.me/support/infinite-scroll/">this tutorial</a>:</p>
<pre><code>add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer' => false,
'render' => 'vividflow_infscroll_render',... | [
{
"answer_id": 88837,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>A solution to <em>the problem</em> of only affecting the last set of posts, but not to <em>the question</em> of ge... | 2013/02/28 | [
"https://wordpress.stackexchange.com/questions/88834",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I added infinite scroll support of the Jetpack plugin to my own theme using [this tutorial](http://jetpack.me/support/infinite-scroll/):
```
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer' => false,
'render' => 'vividflow_infscroll_render',
'wrapper' => 'post_summaries'... | Grabbing the values
-------------------
Normally you just access the `$wp_query` object or, in case you did do a custom query like `$my_query = new WP_Query();`, the `$my_query` object. From there you can get the `$wp_query->numberposts` (or better, as non-deprecated: `$wp_query->found_posts`) for the full amount of p... |
88,890 | <p>I have put together this loop to display all children posts of the desired cat, but i am not getting any of the posts from one of the children cats..<br>
Not sure if i am using the best method to accomplish what I am trying to do..</p>
<pre><code> <?php
$posts = array();
$categories = get_catego... | [
{
"answer_id": 88900,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 2,
"selected": true,
"text": "<p>Your foreach is way wrong. Try combining the category ids in an array, then running one query only to get the posts ... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/88890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28195/"
] | I have put together this loop to display all children posts of the desired cat, but i am not getting any of the posts from one of the children cats..
Not sure if i am using the best method to accomplish what I am trying to do..
```
<?php
$posts = array();
$categories = get_categories('child_of=5')... | Your foreach is way wrong. Try combining the category ids in an array, then running one query only to get the posts you want.
Edit: read your comments. Try use using an array function like array\_merge instead of the + to combine the resulting post arrays. See if that helps. |
88,893 | <p>I try to create an array of years, which is avaible in my template-files and in at least one other function in the functions.php.</p>
<pre><code>function get_the_years()
{
global $year_arr = range(2001, date('Y'));
return $year_arr;
}
</code></pre>
<p>Then I want to use it in a function, which creates a t... | [
{
"answer_id": 88895,
"author": "Sunyatasattva",
"author_id": 24240,
"author_profile": "https://wordpress.stackexchange.com/users/24240",
"pm_score": 3,
"selected": true,
"text": "<p>In order to access a variable defined in the <code>global</code> scope you must reference it with the <co... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/88893",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28046/"
] | I try to create an array of years, which is avaible in my template-files and in at least one other function in the functions.php.
```
function get_the_years()
{
global $year_arr = range(2001, date('Y'));
return $year_arr;
}
```
Then I want to use it in a function, which creates a term for every year in the ... | In order to access a variable defined in the `global` scope you must reference it with the `global` keyword wherever you want to call it again.
In your case, the function `create_year_terms()` must call the `global $year_arr` within its scope.
Also, you can always get your variable in the `global` scope by using the ... |
88,894 | <p>I am using the commenting system to all users to add a private note that only they can see to posts and I am using the wordpress comments system to do it. I wrote a function to call the logged in user comments in a shortcode to display on their profile page. I can get this to work without passing it through a variab... | [
{
"answer_id": 88895,
"author": "Sunyatasattva",
"author_id": 24240,
"author_profile": "https://wordpress.stackexchange.com/users/24240",
"pm_score": 3,
"selected": true,
"text": "<p>In order to access a variable defined in the <code>global</code> scope you must reference it with the <co... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/88894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20227/"
] | I am using the commenting system to all users to add a private note that only they can see to posts and I am using the wordpress comments system to do it. I wrote a function to call the logged in user comments in a shortcode to display on their profile page. I can get this to work without passing it through a variable ... | In order to access a variable defined in the `global` scope you must reference it with the `global` keyword wherever you want to call it again.
In your case, the function `create_year_terms()` must call the `global $year_arr` within its scope.
Also, you can always get your variable in the `global` scope by using the ... |
88,921 | <p>How can I change the size of a featured image thumbnail on the Edit Post screen for one of my custom post types?</p>
<p>Please note that I am looking to modify the size of the image displayed in the admin 'Edit Post' screen, and not on the front end of my site.</p>
<p>The size is determined by WP itself at the mom... | [
{
"answer_id": 88928,
"author": "iamsar",
"author_id": 16151,
"author_profile": "https://wordpress.stackexchange.com/users/16151",
"pm_score": 0,
"selected": false,
"text": "<p>Featured images are called by using <code>the_post_thumbnail()</code> from within The Loop. You can specify a s... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/88921",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | How can I change the size of a featured image thumbnail on the Edit Post screen for one of my custom post types?
Please note that I am looking to modify the size of the image displayed in the admin 'Edit Post' screen, and not on the front end of my site.
The size is determined by WP itself at the moment, and I don't ... | From my past research I concluded that there is no sane way to affect the featured images box with actions and filters. My solution was to use jQuery inserted on the admin\_head hook, to change things after they are loaded.
What I wanted was to add some textual detail outlining how the featured image would be used by... |
88,934 | <p>This code uses <a href="https://en-gb.wordpress.org/plugins/taxonomy-images/" rel="nofollow noreferrer">Taxonomy Images</a> plugin to display images for categories. This code display subcategories of main category in parent category page (<code>category.php</code>), But I want to display only one level of subcategor... | [
{
"answer_id": 88936,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I'm going to guess here. I assume you are using the <a href=\"http://wordpress.org/extend/plugins/taxonomy-images/... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/88934",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28212/"
] | This code uses [Taxonomy Images](https://en-gb.wordpress.org/plugins/taxonomy-images/) plugin to display images for categories. This code display subcategories of main category in parent category page (`category.php`), But I want to display only one level of subcategory in the page for example
hardware (parent categor... | I'm going to guess here. I assume you are using the [Taxonomy Images plugin](http://wordpress.org/extend/plugins/taxonomy-images/)?
This:
```
if($term->term_id == $categories_item->term_id) {
```
Can be changed to:
```
if($term->term_id == $categories_item->term_id && $term->parent == $categories_item->cat_ID) {
... |
88,935 | <p>I ran into a strange Problem today developing a new Plugin.</p>
<p>I set it up as usual, creating the <code>f711-roomprice</code> folder in the Plugindirectory, and creating the <code>f711-roomprice.php</code> as well as an <code>inc</code> directory in there.</p>
<p>Everything worked fine with the activation hook... | [
{
"answer_id": 88936,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I'm going to guess here. I assume you are using the <a href=\"http://wordpress.org/extend/plugins/taxonomy-images/... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/88935",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15680/"
] | I ran into a strange Problem today developing a new Plugin.
I set it up as usual, creating the `f711-roomprice` folder in the Plugindirectory, and creating the `f711-roomprice.php` as well as an `inc` directory in there.
Everything worked fine with the activation hook and the included functions, until i created an in... | I'm going to guess here. I assume you are using the [Taxonomy Images plugin](http://wordpress.org/extend/plugins/taxonomy-images/)?
This:
```
if($term->term_id == $categories_item->term_id) {
```
Can be changed to:
```
if($term->term_id == $categories_item->term_id && $term->parent == $categories_item->cat_ID) {
... |
88,953 | <p>Well, this should be pretty simple, however I couldn't find answer anywhere on the web. all answers I found were close but no exactly what I needed.
what I need is to display just the current term of a custom post type I am in.
<strong>not all the terms just one!</strong> (the relevant one) </p>
<p>this is what I'm... | [
{
"answer_id": 88955,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": false,
"text": "<p>You should use <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_post_terms\" rel=\"noreferrer\">... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/88953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7730/"
] | Well, this should be pretty simple, however I couldn't find answer anywhere on the web. all answers I found were close but no exactly what I needed.
what I need is to display just the current term of a custom post type I am in.
**not all the terms just one!** (the relevant one)
this is what I'm using but it displays ... | Ok, so I finally found what I needed here:
[How to get current term in my custom taxonomy in WordPress?](https://wordpress.stackexchange.com/questions/9414/how-to-get-current-term-in-my-custom-taxonomy-in-wordpress)
the last update at the bottom courtesy of @user3208:
```
<?php // Get terms for post
$terms = get_t... |
88,959 | <p>I am trying to add another field (subtitle) to my already created and existing custom post_type: team (code from functions.php in my *<em>child</em>*theme)</p>
<pre><code><?php
/**
* Custom Post type register framework
*/
include(get_stylesheet_directory(). '/inc/acpt/init.php');
add_action('init', 'makethem')... | [
{
"answer_id": 89084,
"author": "Syed Balkhi",
"author_id": 12620,
"author_profile": "https://wordpress.stackexchange.com/users/12620",
"pm_score": 1,
"selected": false,
"text": "<p>Try changing the pages to an array like so:</p>\n\n<pre><code>'pages' => array('page'), // post type\n<... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/88959",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3435/"
] | I am trying to add another field (subtitle) to my already created and existing custom post\_type: team (code from functions.php in my \**child*\*theme)
```
<?php
/**
* Custom Post type register framework
*/
include(get_stylesheet_directory(). '/inc/acpt/init.php');
add_action('init', 'makethem');
function makethem()... | In your code, you are using:
```
add_filter( 'team_Meta_Box', 'team_sample_metaboxes' );
```
On the site you linked to, they are using:
```
add_filter( 'cmb_meta_boxes', 'wpb_sample_metaboxes' );
```
So my question is: did you change all instances of "cmb" to "team" in the init.php file?
If you did, then the cor... |
88,966 | <p>I am having problems with <code>add_theme_support('custom-header');</code> I can change the Header Text color but I <b>can't hide</b> my Header Text when I leave unchecked <b>"Show header text with your image"</b> inside admin panel (obviously it should hide header text if unchecked). I have no idea should I add som... | [
{
"answer_id": 88968,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 1,
"selected": false,
"text": "<p>Chances are, the theme you are using does not take into account the Custom header settings when it puts in... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/88966",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20941/"
] | I am having problems with `add_theme_support('custom-header');` I can change the Header Text color but I **can't hide** my Header Text when I leave unchecked **"Show header text with your image"** inside admin panel (obviously it should hide header text if unchecked). I have no idea should I add some specific CSS for t... | I have added this code to my header.php and it worked nicely:
```
#header a{
<?php if(get_header_textcolor()=='blank') {
echo 'visibility: hidden;'; } else {
?>
color:#<?php echo get_header_textcolor(); } ?>
}
``` |
88,984 | <p>When you add an image with "Add media" to the WYSIWYG editor the link around the image automatically gets a rel="attachment wp-att-XX". I would like to remove this with a script - Can anyone help me? :)</p>
| [
{
"answer_id": 88998,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 3,
"selected": true,
"text": "<p>You can remove it right before post is printed to the screen by stripping it out from content. But remember i... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/88984",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17400/"
] | When you add an image with "Add media" to the WYSIWYG editor the link around the image automatically gets a rel="attachment wp-att-XX". I would like to remove this with a script - Can anyone help me? :) | You can remove it right before post is printed to the screen by stripping it out from content. But remember it still will meddle in Editor.
```
<?php
function my_remove_rel_attr($content) {
return preg_replace('/\s+rel="attachment wp-att-[0-9]+"/i', '', $content);
}
add_filter('the_content', 'my_remove_rel_attr');... |
89,002 | <p>I've an issue on custom post type,
I've create a custom post type called "Agenda" and the rewrite url for <a href="http://example.com/agenda" rel="nofollow">http://example.com/agenda</a> it works correctly, it points to the archive-agenda.php template but for <a href="http://example.com/agenda/page/2" rel="nofollow... | [
{
"answer_id": 89018,
"author": "David Chase",
"author_id": 28116,
"author_profile": "https://wordpress.stackexchange.com/users/28116",
"pm_score": 1,
"selected": false,
"text": "<p>You need to setup pagination when you query your custom post something like this</p>\n\n<p><code>$paged = ... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/89002",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9399/"
] | I've an issue on custom post type,
I've create a custom post type called "Agenda" and the rewrite url for <http://example.com/agenda> it works correctly, it points to the archive-agenda.php template but for <http://example.com/agenda/page/2> it shows 404 error,
what do you suggest me?
The code that I've used to add th... | You need to reset your permalinks... "powercycle them" :) click "Numeric" -> Save then back to "Post Name" and save (or vice versa) |
89,022 | <p>I'm searching for an action hook which I can use to control access to certain parts of my Wordpress site. I want to write some custom PHP which will check certain user attributes and decide if they can view a particular part of the site (ie only users with certain attributes can view pages which fall under particula... | [
{
"answer_id": 89143,
"author": "diggy",
"author_id": 25765,
"author_profile": "https://wordpress.stackexchange.com/users/25765",
"pm_score": 1,
"selected": true,
"text": "<p>Put this at the very top of your <code>page.php</code> file, before the <code>get_header()</code> call:</p>\n\n<p... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/89022",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28249/"
] | I'm searching for an action hook which I can use to control access to certain parts of my Wordpress site. I want to write some custom PHP which will check certain user attributes and decide if they can view a particular part of the site (ie only users with certain attributes can view pages which fall under particular u... | Put this at the very top of your `page.php` file, before the `get_header()` call:
```
<?php
// redirect if user isn't logged in
if( ! is_user_logged_in() ) {
wp_safe_redirect( home_url( '/signup/' ) );
exit;
}
// supply IDs of both parent pages
$keys = array( '21', '23' );
// ... |
89,036 | <p>I am trying to create a shortcode that will return a link to a book on Amazon with a specific affiliate tracking code specific to the author. I created a user option called "amz" to hold the author's tracking code. This works fine when I'm using it elsewhere. This is the shortcode I created:</p>
<p><code>
fun... | [
{
"answer_id": 89143,
"author": "diggy",
"author_id": 25765,
"author_profile": "https://wordpress.stackexchange.com/users/25765",
"pm_score": 1,
"selected": true,
"text": "<p>Put this at the very top of your <code>page.php</code> file, before the <code>get_header()</code> call:</p>\n\n<p... | 2013/03/01 | [
"https://wordpress.stackexchange.com/questions/89036",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25300/"
] | I am trying to create a shortcode that will return a link to a book on Amazon with a specific affiliate tracking code specific to the author. I created a user option called "amz" to hold the author's tracking code. This works fine when I'm using it elsewhere. This is the shortcode I created:
`function amazon_link_func... | Put this at the very top of your `page.php` file, before the `get_header()` call:
```
<?php
// redirect if user isn't logged in
if( ! is_user_logged_in() ) {
wp_safe_redirect( home_url( '/signup/' ) );
exit;
}
// supply IDs of both parent pages
$keys = array( '21', '23' );
// ... |
89,052 | <p>I'm working on a plugin and I've added a button to the tinymce editor that pops up a modal form, with options for the shortcode, and then inserts the shortcode with the selected options in to the post.</p>
<p>The modal pops up a php file with an html form and some javascript in it. I'd like to use wp_dropdown_categ... | [
{
"answer_id": 89060,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 1,
"selected": false,
"text": "<p>Some people like to stream audio in the browser, others like to download. Each of them is able set up the br... | 2013/03/02 | [
"https://wordpress.stackexchange.com/questions/89052",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28260/"
] | I'm working on a plugin and I've added a button to the tinymce editor that pops up a modal form, with options for the shortcode, and then inserts the shortcode with the selected options in to the post.
The modal pops up a php file with an html form and some javascript in it. I'd like to use wp\_dropdown\_categories() ... | Some people like to stream audio in the browser, others like to download. Each of them is able set up the browser to choose between downloading or streaming different MIME types to get what they need.
On the other hand you can force download of certain MIME type files using PHP `header()` function.
See [How can I for... |
89,057 | <p>I installed a plugin called "Symbiosis" which creates categories automatically copying a user's username upon them signing up.</p>
<p>Whenever any user creates a post on the site, I am trying to figure out how to assign that category that was already created with the new post.</p>
<p>I want to set WP Default Categ... | [
{
"answer_id": 89060,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 1,
"selected": false,
"text": "<p>Some people like to stream audio in the browser, others like to download. Each of them is able set up the br... | 2013/03/02 | [
"https://wordpress.stackexchange.com/questions/89057",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28262/"
] | I installed a plugin called "Symbiosis" which creates categories automatically copying a user's username upon them signing up.
Whenever any user creates a post on the site, I am trying to figure out how to assign that category that was already created with the new post.
I want to set WP Default Category to the author... | Some people like to stream audio in the browser, others like to download. Each of them is able set up the browser to choose between downloading or streaming different MIME types to get what they need.
On the other hand you can force download of certain MIME type files using PHP `header()` function.
See [How can I for... |
89,058 | <p>I want to show posts which are filed 2 or more custom taxonomy terms. For example, I want to show the posts from custom post type "Classified" and filed under Books <em>and</em> House terms.</p>
<p>The code below show posts which are marked in <em>either</em> of the terms. I want only the posts marked in <em>both<... | [
{
"answer_id": 89071,
"author": "Simon",
"author_id": 9458,
"author_profile": "https://wordpress.stackexchange.com/users/9458",
"pm_score": 0,
"selected": false,
"text": "<p>I think you need to add the <code>relation</code>argument :</p>\n\n<pre><code>$args = array(\n 'posts_per_page'... | 2013/03/02 | [
"https://wordpress.stackexchange.com/questions/89058",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28264/"
] | I want to show posts which are filed 2 or more custom taxonomy terms. For example, I want to show the posts from custom post type "Classified" and filed under Books *and* House terms.
The code below show posts which are marked in *either* of the terms. I want only the posts marked in *both* the terms:
```
$args = arr... | You need to combine two tax queries with and `AND` relation:
```
$args = array(
'posts_per_page' => 10, // Number of posts per page
'post_type' => 'classifieds', // Custom Post Type like Movies
'tax_query' => array(
'relation' => 'AND'
array(
'taxonomy' => 'classifieds_tags',... |
89,066 | <p>I'm currently working on a plugin that creates a custom post type. The issue I'm strugging with at the moment is that the custom post type is created fine, but when I go to add a new post I receive an "Invalid Post Type" error.</p>
<p>The ui is hidden and I'm trying to link to it from add_submenu_page. I need ass... | [
{
"answer_id": 89069,
"author": "Ünsal Korkmaz",
"author_id": 1372,
"author_profile": "https://wordpress.stackexchange.com/users/1372",
"pm_score": 3,
"selected": true,
"text": "<p>Magic here is:</p>\n\n<pre><code>'show_ui' => true,\n'show_in_menu' => 'plugins.php',\n</code></pre>\... | 2013/03/02 | [
"https://wordpress.stackexchange.com/questions/89066",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8882/"
] | I'm currently working on a plugin that creates a custom post type. The issue I'm strugging with at the moment is that the custom post type is created fine, but when I go to add a new post I receive an "Invalid Post Type" error.
The ui is hidden and I'm trying to link to it from add\_submenu\_page. I need assistance fo... | Magic here is:
```
'show_ui' => true,
'show_in_menu' => 'plugins.php',
```
Try this:
```
function restaurant_menu_items() {
$labels = array(
'name' => __('Restaurant Menu Items', 'post type general name'),
'singular_name' => __('Restaurant Menu Item', 'post type singular name'),
'add_ne... |
89,090 | <p>For some reason I can not find any good solution to making the post images link to the post.</p>
<p>I found a script on <a href="http://wpguy.com/plugins/linked-image/" rel="nofollow">http://wpguy.com/plugins/linked-image/</a> which works - but does not remove the old link, instead it wraps the old link and the ima... | [
{
"answer_id": 89097,
"author": "Simon",
"author_id": 9458,
"author_profile": "https://wordpress.stackexchange.com/users/9458",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, don't use regex for parsing HTML but use DOM instead. </p>\n\n<p>This is how I would work it out : </p>\n\n<p... | 2013/03/02 | [
"https://wordpress.stackexchange.com/questions/89090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17400/"
] | For some reason I can not find any good solution to making the post images link to the post.
I found a script on <http://wpguy.com/plugins/linked-image/> which works - but does not remove the old link, instead it wraps the old link and the image in a new a tag.
What I want is for the old link to be removed so the ima... | Yes, don't use regex for parsing HTML but use DOM instead.
This is how I would work it out :
In your toolbox, a function to get innerDOM of a node :
```
// GET INNER HTML OF A NODE
function DOMinnerHTML($element)
{
$innerHTML = "";
$children = $element->childNodes;
foreach ($children as $child)
... |
89,095 | <p>Wordpress converts my theme options text with smart quotes.</p>
<p>I know that to remove problem from posts etc:</p>
<pre><code>remove_filter('the_content', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
remove_filter('comment_text', 'wptexturize');
</code></pre>
<p>But how to remove this effects ... | [
{
"answer_id": 89097,
"author": "Simon",
"author_id": 9458,
"author_profile": "https://wordpress.stackexchange.com/users/9458",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, don't use regex for parsing HTML but use DOM instead. </p>\n\n<p>This is how I would work it out : </p>\n\n<p... | 2013/03/02 | [
"https://wordpress.stackexchange.com/questions/89095",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28279/"
] | Wordpress converts my theme options text with smart quotes.
I know that to remove problem from posts etc:
```
remove_filter('the_content', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
remove_filter('comment_text', 'wptexturize');
```
But how to remove this effects when saving into Wordpress option... | Yes, don't use regex for parsing HTML but use DOM instead.
This is how I would work it out :
In your toolbox, a function to get innerDOM of a node :
```
// GET INNER HTML OF A NODE
function DOMinnerHTML($element)
{
$innerHTML = "";
$children = $element->childNodes;
foreach ($children as $child)
... |
89,110 | <p>I am trying to add form field to a WordPress widget dynamically. So if the user want to add another date to an event they can click a button to get more fields. </p>
<p>The question is: <strong>How do save newly created input fields to my database?</strong>
Do i need to write a custom update function? Any tips?</p>... | [
{
"answer_id": 89166,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 4,
"selected": true,
"text": "<p>Interesting Question!<br>\nI've never seen repeatable fields used in Widgets. Giving a full Answer would requ... | 2013/03/02 | [
"https://wordpress.stackexchange.com/questions/89110",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11552/"
] | I am trying to add form field to a WordPress widget dynamically. So if the user want to add another date to an event they can click a button to get more fields.
The question is: **How do save newly created input fields to my database?**
Do i need to write a custom update function? Any tips?
This is how the widget lo... | Interesting Question!
I've never seen repeatable fields used in Widgets. Giving a full Answer would require too much work/time, so I'll give you links to the resources I know, and hopefully you'll make this work and share the solution with us ;)
All this examples deal with Meta Boxes, you'll need to copy the jQuery... |
89,113 | <p>After every instance of <a href="https://github.com/WordPress/WordPress/blob/3.5.1/wp-includes/ms-blogs.php#L484"><code>switch_to_blog()</code></a> you should call <a href="https://github.com/WordPress/WordPress/blob/3.5.1/wp-includes/ms-blogs.php#L556"><code>restore_current_blog()</code></a> to restore the current ... | [
{
"answer_id": 89114,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": false,
"text": "<p>If you want to run over multiple blogs there is no need to restore the previous blog each time. The only thing that gr... | 2013/03/02 | [
"https://wordpress.stackexchange.com/questions/89113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9364/"
] | After every instance of [`switch_to_blog()`](https://github.com/WordPress/WordPress/blob/3.5.1/wp-includes/ms-blogs.php#L484) you should call [`restore_current_blog()`](https://github.com/WordPress/WordPress/blob/3.5.1/wp-includes/ms-blogs.php#L556) to restore the current (actually, previous) blog.
But if you're loop... | After every instance of `switch_to_blog()` you **need** to call `restore_current_blog()` otherwise WP will think it is in a "switched" mode and can potentially return incorrect data.
If you view the source code for both functions you will see those functions push/pop data into a global called `$GLOBALS['_wp_switched_... |
89,123 | <p>I making a widgetized footer with three widgetized areas (footer1, footer2, footer3), The problem is that even if there's no widgets assigned to any widgetized footer area, the footer is still there with his black background! what I want is to remove the footer if there isn't any widget assigned.</p>
| [
{
"answer_id": 89124,
"author": "Rahman Sharif",
"author_id": 24483,
"author_profile": "https://wordpress.stackexchange.com/users/24483",
"pm_score": 0,
"selected": false,
"text": "<p>I tried this solution but it doesn't work at all!</p>\n\n<pre>\n if( !dynamic_sidebar('footer1') || !dyn... | 2013/03/02 | [
"https://wordpress.stackexchange.com/questions/89123",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24483/"
] | I making a widgetized footer with three widgetized areas (footer1, footer2, footer3), The problem is that even if there's no widgets assigned to any widgetized footer area, the footer is still there with his black background! what I want is to remove the footer if there isn't any widget assigned. | I would use the [`is_active_sidebar()`](http://codex.wordpress.org/Function_Reference/is_active_sidebar) conditional:
```
<?php
if ( is_active_sidebar( 'footer' ) ) {
?>
<div id="sidebar-footer">
<?php dynamic_sidebar( 'footer' ); ?>
</div>
<?php
}
?>
```
That way, you can conditionally outpu... |
89,137 | <p>Helping a friend w/ a navigational menu on a WordPress PHP site -- called it <strong>Primary Menu</strong>. I'm trying to override the default navigational menu with the jquery-mega-menu I created in the widget area I created.</p>
<p><strong>Here's the problem:</strong></p>
<p>I'd like to have the menu in the wid... | [
{
"answer_id": 89141,
"author": "Got The Fever Media",
"author_id": 28153,
"author_profile": "https://wordpress.stackexchange.com/users/28153",
"pm_score": 1,
"selected": false,
"text": "<p>it seems that you're calling a sidebar. Is your menu within the sidebar, as a widget? Where is you... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89137",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26710/"
] | Helping a friend w/ a navigational menu on a WordPress PHP site -- called it **Primary Menu**. I'm trying to override the default navigational menu with the jquery-mega-menu I created in the widget area I created.
**Here's the problem:**
I'd like to have the menu in the widget area I created, "**my\_mega\_menu**", wh... | The Problem here is that you call your function `inkthemes_nav()` and also call the sidebar with the widget for the menu in it `dynamic_sidebar('my_mega_menu')`.
So you have two solutions:
* Skip the Function, just calling it from the Widget inside your sidebar
* Skip the Sidebar, and let the Function handle the Men... |
89,138 | <p>I'm looking for a way to hide certain widgets from specific user types in the admin, <kbd>Appearance > Widgets</kbd> page?</p>
<p>For instance, admins can see all widgets, but authors can only see a select few?</p>
<p>I noticed there was a Code Canyon plugin, but it requires a framework with it also which I am not... | [
{
"answer_id": 89165,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>You have to check for <a href=\"http://codex.wordpress.org/Roles_and_Capabilities\" rel=\"nofollow noreferrer... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89138",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26762/"
] | I'm looking for a way to hide certain widgets from specific user types in the admin, `Appearance > Widgets` page?
For instance, admins can see all widgets, but authors can only see a select few?
I noticed there was a Code Canyon plugin, but it requires a framework with it also which I am not using. | You have to check for [Roles and Capabilities](http://codex.wordpress.org/Roles_and_Capabilities) in the action hook `widgets_init` and proceed accordingly.
```
add_action( 'widgets_init', 'remove_widgets_wpse_89138' , 15 );
function remove_widgets_wpse_89138()
{
// http://codex.wordpress.org/Function_Reference/... |
89,154 | <p>I'm want to get posts from the last 30days in a sidebar but I don't want to use query_posts, is there a way to achieve this with the get posts function?</p>
| [
{
"answer_id": 89159,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, simple add a filter before you call it and remove it after you do </p>\n\n<pre><code>function filter_wher... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89154",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35798/"
] | I'm want to get posts from the last 30days in a sidebar but I don't want to use query\_posts, is there a way to achieve this with the get posts function? | Yes, simple add a filter before you call it and remove it after you do
```
function filter_where_wpa89154($where = '') {
//posts in the last 30 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where_wpa89154');
$args = ar... |
89,156 | <p>Is it possible to make shortcodes available in the Author bio textarea?</p>
| [
{
"answer_id": 89163,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 4,
"selected": true,
"text": "<p>It a matter of using <a href=\"http://codex.wordpress.org/Function_Reference/do_shortcode\" rel=\"noreferrer\... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89156",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9060/"
] | Is it possible to make shortcodes available in the Author bio textarea? | It a matter of using [**`do_shortcode`**](http://codex.wordpress.org/Function_Reference/do_shortcode) in your `author.php` template file (or wherever applies). This function has to be "`echo`ed". And instead of using `the_author_meta` (which `echo`'s the result), use `get_the_author_meta`.
```
<?php echo do_shortcode(... |
89,164 | <p>I am now passing parameters to a custom template in the following format</p>
<pre><code>www.example.com/?pageid=12&rid=24&title=this-is-the-title
</code></pre>
<p>I have created two tables . So I need to fetch data and display them on those pages.</p>
<p>I would like it to be using clean URL format like:... | [
{
"answer_id": 89206,
"author": "Kim",
"author_id": 28312,
"author_profile": "https://wordpress.stackexchange.com/users/28312",
"pm_score": 0,
"selected": false,
"text": "<p>If you want a simple solution this might be it (haven't tested the code so might not be so simple if it's not work... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89164",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27422/"
] | I am now passing parameters to a custom template in the following format
```
www.example.com/?pageid=12&rid=24&title=this-is-the-title
```
I have created two tables . So I need to fetch data and display them on those pages.
I would like it to be using clean URL format like:
```
www.example.com/pageid/12/rid/24/tit... | [`add_rewrite_rule()`](https://codex.wordpress.org/Rewrite_API/add_rewrite_rule) allows you to turn the pretty url into variables.
* numbers: `(\d*)`
* section: `/rid/` or `/pageid/`
* slug: `([a-zA-Z0-9-]+`
Here is a class to register the rewrite and handle the request if a match has been found.
```
<?php
if ( ! c... |
89,167 | <p>Using WAMPSERVER for windows 7, smartgit and Safe Search Replace I have pulled a wordpress code from my git, downloaded a database and inserted into my localhost's phpmyadmin. My home page works but when I click on one of the links I get the WAMP homepage. What am I doing wrong?</p>
<p>I have tried the following in... | [
{
"answer_id": 89179,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>You probably have just the wrong links saved in the DB you pulled. WordPress only stores <em>absolute</em> URLs in ... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89167",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16340/"
] | Using WAMPSERVER for windows 7, smartgit and Safe Search Replace I have pulled a wordpress code from my git, downloaded a database and inserted into my localhost's phpmyadmin. My home page works but when I click on one of the links I get the WAMP homepage. What am I doing wrong?
I have tried the following in WP-Config... | Ok, based on that, I'm almost positive that you need to re-enable permalinks for your site. You are probably missing your .htaccess file or it is missing WordPress's rewrite rules.
Go to your admin and find Settings > Permalinks. Select an option, and click "Save Changes" *twice* (there is a quirk that this avoids).
... |