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 |
|---|---|---|---|---|---|---|
109,565 | <p>I'm trying to figure out the php syntax here, so I can show only related products that are of the current taxonomy term. I would like the $args filter 'product_brand' to dynamically grab the current products term. </p>
<p>So I need a method of getting the slug for the current product term. I've tried this but it's ... | [
{
"answer_id": 109562,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": false,
"text": "<p>You could try this one:</p>\n\n<pre><code>add_shortcode( 'myshortcode', 'myshortcode_callback' );\n\nfunction... | 2013/08/09 | [
"https://wordpress.stackexchange.com/questions/109565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36438/"
] | I'm trying to figure out the php syntax here, so I can show only related products that are of the current taxonomy term. I would like the $args filter 'product\_brand' to dynamically grab the current products term.
So I need a method of getting the slug for the current product term. I've tried this but it's not worki... | The `<br />` tags are being added to the content by the `wpautop()` function. If you run your shortcode before it runs they will not be there. It is added in `\wp-includes\default-filters.php` with the default priority of `10`.
```
add_filter( 'the_content', 'myshortcode', 1 );
function myshortcode( $atts, $content =... |
109,569 | <p>I've got a situation where I need to limit the top level menu items on a custom menu. The design only has room for 4 fixed width items, and I want to future proof it from displaying more.</p>
<p>Looking at <a href="https://wordpress.stackexchange.com/questions/2094/is-there-a-way-to-limit-the-number-of-top-level-it... | [
{
"answer_id": 109573,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 2,
"selected": true,
"text": "<p>A few lines before that filter is this line:</p>\n\n<pre><code>$sorted_menu_items = apply_filters( 'w... | 2013/08/09 | [
"https://wordpress.stackexchange.com/questions/109569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19027/"
] | I've got a situation where I need to limit the top level menu items on a custom menu. The design only has room for 4 fixed width items, and I want to future proof it from displaying more.
Looking at [Is there a way to limit the number of top level items in a custom menu?](https://wordpress.stackexchange.com/questions/... | A few lines before that filter is this line:
```
$sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args );
```
That filter passes the top level menu item objects before `walk_nav_menu_tree()` is called.
Here is some test code:
```
add_filter( 'wp_nav_menu_objects', 'my_nav_menu_object... |
109,584 | <p>Here's a little coding problem for you. The code:</p>
<pre><code>if ($categories) {
foreach ($categories as $tag) {
$tag_link = get_category_link($tag->term_id);
//new line
if (isset($instance['new-line'])) {
$html .= "<div>";
}
$html .= "&... | [
{
"answer_id": 109588,
"author": "Morgan Estes",
"author_id": 26317,
"author_profile": "https://wordpress.stackexchange.com/users/26317",
"pm_score": 2,
"selected": false,
"text": "<p>In line 195 you're using <code>get_categories</code>, which can be filtered to exclude specific category... | 2013/08/09 | [
"https://wordpress.stackexchange.com/questions/109584",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34277/"
] | Here's a little coding problem for you. The code:
```
if ($categories) {
foreach ($categories as $tag) {
$tag_link = get_category_link($tag->term_id);
//new line
if (isset($instance['new-line'])) {
$html .= "<div>";
}
$html .= "<span class="tagsy-box" ... | In line 195 you're using `get_categories`, which can be filtered to exclude specific category numbers, either through an array of arguments, or a query string. Since `$options` is already set, you could add to it before you call `get_categories`:
```
if ($show_assigned_categories == 'true' && is_single()) {
$c... |
109,611 | <p>Slider is created using Meta Slider Lite v2.2.1.</p>
<p>Meta Slider shows it usage as</p>
<pre><code>Shortcode
[metaslider id=449]
Template Include
<?php echo do_shortcode("[metaslider id=449]"); ?>
</code></pre>
<p>Pinboard theme is used.
Text module is added to its header element.
Text element contai... | [
{
"answer_id": 109588,
"author": "Morgan Estes",
"author_id": 26317,
"author_profile": "https://wordpress.stackexchange.com/users/26317",
"pm_score": 2,
"selected": false,
"text": "<p>In line 195 you're using <code>get_categories</code>, which can be filtered to exclude specific category... | 2013/08/10 | [
"https://wordpress.stackexchange.com/questions/109611",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36453/"
] | Slider is created using Meta Slider Lite v2.2.1.
Meta Slider shows it usage as
```
Shortcode
[metaslider id=449]
Template Include
<?php echo do_shortcode("[metaslider id=449]"); ?>
```
Pinboard theme is used.
Text module is added to its header element.
Text element contains
```
[metaslider id=449]
<?php echo ... | In line 195 you're using `get_categories`, which can be filtered to exclude specific category numbers, either through an array of arguments, or a query string. Since `$options` is already set, you could add to it before you call `get_categories`:
```
if ($show_assigned_categories == 'true' && is_single()) {
$c... |
109,633 | <p>I am using latest Wordpress 3.6. I'd like to add some HTML code to the page using js. I put a </p>
<pre><code><script>
$('p.content').addClass('highlight');
</script>
</code></pre>
<p>in the head are, but it doesn't work. </p>
<p>So I want to add the class highlight to a p element w... | [
{
"answer_id": 109588,
"author": "Morgan Estes",
"author_id": 26317,
"author_profile": "https://wordpress.stackexchange.com/users/26317",
"pm_score": 2,
"selected": false,
"text": "<p>In line 195 you're using <code>get_categories</code>, which can be filtered to exclude specific category... | 2013/08/10 | [
"https://wordpress.stackexchange.com/questions/109633",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17376/"
] | I am using latest Wordpress 3.6. I'd like to add some HTML code to the page using js. I put a
```
<script>
$('p.content').addClass('highlight');
</script>
```
in the head are, but it doesn't work.
So I want to add the class highlight to a p element with calss=content.
the reason I want to use it,... | In line 195 you're using `get_categories`, which can be filtered to exclude specific category numbers, either through an array of arguments, or a query string. Since `$options` is already set, you could add to it before you call `get_categories`:
```
if ($show_assigned_categories == 'true' && is_single()) {
$c... |
109,665 | <p>I want to make a archive page that pulls in all uploaded images to the site. I am using the current script. Its paginating somewhat but not showing all the images. Showing around 90 out of 140. </p>
<pre><code> <?php query_posts(array('posts_per_page'=>'8','paged' => get_query_var('paged'))); ?>
... | [
{
"answer_id": 109704,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Your <code>since83_pagination()</code> function is assuming the main query-- <code>$wp_query</code>-- but yo... | 2013/08/11 | [
"https://wordpress.stackexchange.com/questions/109665",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31195/"
] | I want to make a archive page that pulls in all uploaded images to the site. I am using the current script. Its paginating somewhat but not showing all the images. Showing around 90 out of 140.
```
<?php query_posts(array('posts_per_page'=>'8','paged' => get_query_var('paged'))); ?>
<?php
if ( $images = g... | Your `since83_pagination()` function is assuming the main query-- `$wp_query`-- but you are needing to paginate something very different. You need to be paginating the results in `$attachments` which you are retrieving with [`get_children()`](http://codex.wordpress.org/Function_Reference/get_children). That was my gues... |
109,694 | <p>I have a question and a technical issue in wordpress. That is, i have a login form on my website to allow visitors to login to see special content. The question goes here, when the time they log in, i am managed to redirect them to a targeted page. When the time they logging out from the member zone, i am out of ide... | [
{
"answer_id": 109697,
"author": "hacksy",
"author_id": 8780,
"author_profile": "https://wordpress.stackexchange.com/users/8780",
"pm_score": 0,
"selected": false,
"text": "<p>First i think will be better to </p>\n\n<pre><code>add_action('wp_logout',create_function('','wp_redirect(home_u... | 2013/08/11 | [
"https://wordpress.stackexchange.com/questions/109694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23036/"
] | I have a question and a technical issue in wordpress. That is, i have a login form on my website to allow visitors to login to see special content. The question goes here, when the time they log in, i am managed to redirect them to a targeted page. When the time they logging out from the member zone, i am out of idea h... | [`home_url()`](http://codex.wordpress.org/Function_Reference/home_url) will accept a parameter that will be used in the creation of the URL.
The bare minimum solution would be:
```
add_action(
'wp_logout',
create_function(
'',
'wp_redirect(home_url("/path/to/page"));exit();'
)
);
```
[`site_url()`](ht... |
109,710 | <p>I want to get all posts by certain author id (current user). Later, I want to pick the first post made by this user (ASC).
I guess I do not use the right arguments in get_posts, am I? $current_user_posts
always contains an Array with all blog posts in multiple different WP_Post Objects.</p>
<pre><code>global $curr... | [
{
"answer_id": 109729,
"author": "Marin Bînzari",
"author_id": 35115,
"author_profile": "https://wordpress.stackexchange.com/users/35115",
"pm_score": 6,
"selected": true,
"text": "<p>I'm a bit confused. If you want to get onlya element from the posts array you can get it like this:</p>\... | 2013/08/11 | [
"https://wordpress.stackexchange.com/questions/109710",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36493/"
] | I want to get all posts by certain author id (current user). Later, I want to pick the first post made by this user (ASC).
I guess I do not use the right arguments in get\_posts, am I? $current\_user\_posts
always contains an Array with all blog posts in multiple different WP\_Post Objects.
```
global $current_user;
... | I'm a bit confused. If you want to get onlya element from the posts array you can get it like this:
* reset($current\_user\_posts) - first post
* end($current\_user\_posts) - lat post
But if you want to get just one post with the `get_posts()` you can use the `posts_per_page` argument to limit the results.
```
$args... |
109,719 | <p>I am writing a plugin that creates custom post types, but i want users to be able to turn them on and off via a filter in the <code>functions.php</code> file.</p>
<p>The issue i'm having is that custom post types <code>register_post_type</code> has to be called during <code>init</code> and <code>functions.php</code... | [
{
"answer_id": 109729,
"author": "Marin Bînzari",
"author_id": 35115,
"author_profile": "https://wordpress.stackexchange.com/users/35115",
"pm_score": 6,
"selected": true,
"text": "<p>I'm a bit confused. If you want to get onlya element from the posts array you can get it like this:</p>\... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35459/"
] | I am writing a plugin that creates custom post types, but i want users to be able to turn them on and off via a filter in the `functions.php` file.
The issue i'm having is that custom post types `register_post_type` has to be called during `init` and `functions.php` is read far after this.
How can I allow users to pr... | I'm a bit confused. If you want to get onlya element from the posts array you can get it like this:
* reset($current\_user\_posts) - first post
* end($current\_user\_posts) - lat post
But if you want to get just one post with the `get_posts()` you can use the `posts_per_page` argument to limit the results.
```
$args... |
109,728 | <p>I have been working on adding some customizations to <a href="http://wordpress.org/plugins/download-monitor/" rel="nofollow">Download Monitor</a></p>
<p>So far I have been able to add custom meta check boxes, and save them using the following code.</p>
<pre><code>global $post, $download;
//add additional meta to ... | [
{
"answer_id": 109729,
"author": "Marin Bînzari",
"author_id": 35115,
"author_profile": "https://wordpress.stackexchange.com/users/35115",
"pm_score": 6,
"selected": true,
"text": "<p>I'm a bit confused. If you want to get onlya element from the posts array you can get it like this:</p>\... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109728",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36470/"
] | I have been working on adding some customizations to [Download Monitor](http://wordpress.org/plugins/download-monitor/)
So far I have been able to add custom meta check boxes, and save them using the following code.
```
global $post, $download;
//add additional meta to download monitor post screen.
function add_cust... | I'm a bit confused. If you want to get onlya element from the posts array you can get it like this:
* reset($current\_user\_posts) - first post
* end($current\_user\_posts) - lat post
But if you want to get just one post with the `get_posts()` you can use the `posts_per_page` argument to limit the results.
```
$args... |
109,733 | <p>I would like a condition such as the following:</p>
<p>1) User is logged. Select Page Shop and displays all content.
2) If user is not logged. Select Shop page, they are redirected to another page, for example Sign Up page.</p>
<p>I hope it is possible. I have tried many plugins but failed. At the moment the only ... | [
{
"answer_id": 109741,
"author": "Siavash1991",
"author_id": 35070,
"author_profile": "https://wordpress.stackexchange.com/users/35070",
"pm_score": 0,
"selected": false,
"text": "<p>Past this code in your Page.php file in your theme. it should do what you need.</p>\n\n<pre><code><?ph... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109733",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36474/"
] | I would like a condition such as the following:
1) User is logged. Select Page Shop and displays all content.
2) If user is not logged. Select Shop page, they are redirected to another page, for example Sign Up page.
I hope it is possible. I have tried many plugins but failed. At the moment the only one that works wi... | You can do this by using
1) [is\_shop](http://docs.woothemes.com/wc-apidocs/function-is_shop.html) fx
2) [template\_redirect](http://codex.wordpress.org/Function_Reference/wp_safe_redirect) action hook
3) [wp\_safe\_redirect](http://codex.wordpress.org/Function_Reference/wp_safe_redirect) fx
```
add_action('templat... |
109,739 | <p>I'm having an issue with a loop pulling every custom post in my template and not the one that has been requested. This can be seen here: <a href="https://i.imgur.com/1YKeLtV.png" rel="nofollow noreferrer">http://i.imgur.com/1YKeLtV.png</a></p>
<p>Here is the code I'm using to display the custom post:</p>
<pre><cod... | [
{
"answer_id": 109741,
"author": "Siavash1991",
"author_id": 35070,
"author_profile": "https://wordpress.stackexchange.com/users/35070",
"pm_score": 0,
"selected": false,
"text": "<p>Past this code in your Page.php file in your theme. it should do what you need.</p>\n\n<pre><code><?ph... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11945/"
] | I'm having an issue with a loop pulling every custom post in my template and not the one that has been requested. This can be seen here: [http://i.imgur.com/1YKeLtV.png](https://i.imgur.com/1YKeLtV.png)
Here is the code I'm using to display the custom post:
```
<?php /*Template Name: Game Listing Page */ ?>
<?php get... | You can do this by using
1) [is\_shop](http://docs.woothemes.com/wc-apidocs/function-is_shop.html) fx
2) [template\_redirect](http://codex.wordpress.org/Function_Reference/wp_safe_redirect) action hook
3) [wp\_safe\_redirect](http://codex.wordpress.org/Function_Reference/wp_safe_redirect) fx
```
add_action('templat... |
109,744 | <p>I'm developing a Wordpress theme and I faced a problem while customizing a comment form.
What I wanted is to eliminate URL field and put my own classes for name and email fields. I'm doing it like this: </p>
<pre><code> $commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$... | [
{
"answer_id": 109741,
"author": "Siavash1991",
"author_id": 35070,
"author_profile": "https://wordpress.stackexchange.com/users/35070",
"pm_score": 0,
"selected": false,
"text": "<p>Past this code in your Page.php file in your theme. it should do what you need.</p>\n\n<pre><code><?ph... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109744",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36504/"
] | I'm developing a Wordpress theme and I faced a problem while customizing a comment form.
What I wanted is to eliminate URL field and put my own classes for name and email fields. I'm doing it like this:
```
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $... | You can do this by using
1) [is\_shop](http://docs.woothemes.com/wc-apidocs/function-is_shop.html) fx
2) [template\_redirect](http://codex.wordpress.org/Function_Reference/wp_safe_redirect) action hook
3) [wp\_safe\_redirect](http://codex.wordpress.org/Function_Reference/wp_safe_redirect) fx
```
add_action('templat... |
109,750 | <p>I'm using WooCommerce with free <a href="http://www.woothemes.com/products/artificer/" rel="nofollow noreferrer">Artificer theme</a> and I'm trying to change the text for <strong>My Basket</strong> and <strong>Checkout</strong> shown on image below:
<img src="https://i.stack.imgur.com/CvA0S.png" alt="enter image des... | [
{
"answer_id": 109820,
"author": "Nikola",
"author_id": 7238,
"author_profile": "https://wordpress.stackexchange.com/users/7238",
"pm_score": 2,
"selected": true,
"text": "<p>The functions are defined in the <code>includes</code> folder of the artificer theme, in the <code>theme-woocomme... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109750",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7238/"
] | I'm using WooCommerce with free [Artificer theme](http://www.woothemes.com/products/artificer/) and I'm trying to change the text for **My Basket** and **Checkout** shown on image below:

Now, I've searched the localization files for any string matchi... | The functions are defined in the `includes` folder of the artificer theme, in the `theme-woocommerce.php` file:
```
// Add the cart link to the header
add_action('woo_nav_before', 'artificer_header_cart_link', 20);
if ( ! function_exists( 'artificer_header_cart_link' ) ) {
function artificer_header_cart_link() {
... |
109,753 | <p>When starting with a fresh Network install, the first step is a single site install that has one additional line in the <code>wp-config.php</code> file:</p>
<pre><code>define( 'WP_ALLOW_MULTISITE', true );
</code></pre>
<p>After that we have to go to <code>Tools > Network Setup</code>, enter some details like n... | [
{
"answer_id": 109762,
"author": "Ünsal Korkmaz",
"author_id": 1372,
"author_profile": "https://wordpress.stackexchange.com/users/1372",
"pm_score": -1,
"selected": false,
"text": "<p>Inspect <code>wp-admin/network.php</code> and <code>wp-admin/includes/schema.php</code> files. You can c... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109753",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | When starting with a fresh Network install, the first step is a single site install that has one additional line in the `wp-config.php` file:
```
define( 'WP_ALLOW_MULTISITE', true );
```
After that we have to go to `Tools > Network Setup`, enter some details like network name and super admin email and finally hit t... | I haven't tested this, but if you would need to find such a solution, I would probably try to do it in the following way by adding a script into the `if ( SOME_CHECK_IF_STEP-1_WAS_PASSED )` condition you've described above, that would:
* check the DB for the `{$wpdb->prefix}sitemeta` table;
* if it does not exist -> r... |
109,754 | <pre><code><?php
mysql_connect("localhost", "xxxxxx", "xxxxx") or die(mysql_error());
mysql_select_db("xxxxx") or die(mysql_error());
$data = mysql_query("SELECT
p1.*,
wm2.meta_value
FROM
xxxxx_posts p1
LEFT JOIN
xxxxxx_postmeta wm1
ON (
wm1.post_id = p1.id
AND wm1.meta_valu... | [
{
"answer_id": 109762,
"author": "Ünsal Korkmaz",
"author_id": 1372,
"author_profile": "https://wordpress.stackexchange.com/users/1372",
"pm_score": -1,
"selected": false,
"text": "<p>Inspect <code>wp-admin/network.php</code> and <code>wp-admin/includes/schema.php</code> files. You can c... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109754",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36510/"
] | ```
<?php
mysql_connect("localhost", "xxxxxx", "xxxxx") or die(mysql_error());
mysql_select_db("xxxxx") or die(mysql_error());
$data = mysql_query("SELECT
p1.*,
wm2.meta_value
FROM
xxxxx_posts p1
LEFT JOIN
xxxxxx_postmeta wm1
ON (
wm1.post_id = p1.id
AND wm1.meta_value IS NOT N... | I haven't tested this, but if you would need to find such a solution, I would probably try to do it in the following way by adding a script into the `if ( SOME_CHECK_IF_STEP-1_WAS_PASSED )` condition you've described above, that would:
* check the DB for the `{$wpdb->prefix}sitemeta` table;
* if it does not exist -> r... |
109,760 | <p>I use GravityForms in my WordPress site, and have the GravityForms to Salesforce API plugin that adds people who fill out a form as leads in Salesforce. It works fine, except for when people don't enter a company name. Is there a way to have it default to their full name if they don't enter a company?</p>
<p>Here's... | [
{
"answer_id": 109758,
"author": "kingkool68",
"author_id": 2744,
"author_profile": "https://wordpress.stackexchange.com/users/2744",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress supports scheduling posts to go live at some point in the future. WordPress.com goes into great de... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36515/"
] | I use GravityForms in my WordPress site, and have the GravityForms to Salesforce API plugin that adds people who fill out a form as leads in Salesforce. It works fine, except for when people don't enter a company name. Is there a way to have it default to their full name if they don't enter a company?
Here's my code. ... | I have a feeling that there is information missing from this question but the obvious answer is to schedule your posts with the built in post publication scheduler.
 |
109,773 | <p>I'm trying to display the title and excerpt of the most recent 8 posts on the sidebar.</p>
<p>I'm getting a list where:</p>
<ul>
<li>All items link to the oldest post</li>
<li>All titles are "id number of a post that should be displayed"+"oldest post title"</li>
<li>All excerpts are from the oldest post</li>
</ul>... | [
{
"answer_id": 109774,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 5,
"selected": true,
"text": "<p>Don't use the 'helper' methods, they tend to cause more trouble than they're worth.</p>\n\n<p>Any time you wa... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109773",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22510/"
] | I'm trying to display the title and excerpt of the most recent 8 posts on the sidebar.
I'm getting a list where:
* All items link to the oldest post
* All titles are "id number of a post that should be displayed"+"oldest post title"
* All excerpts are from the oldest post
---
```
<?php
$args = array( 'numbe... | Don't use the 'helper' methods, they tend to cause more trouble than they're worth.
Any time you want to grab posts, be it the latest, the oldest, in a category etc, use a `WP_Query` loop, here is its standard form:
```
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {... |
109,775 | <p>I was surprised this morning to hear that the contents on my WP site are erased, said my client. I tried disable all plugins one by one, but the problem still exists. I also changed the memory limit via the wp-config and that could not solve the problem either. Then I switched to another theme, twenty-eleven and twe... | [
{
"answer_id": 109774,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 5,
"selected": true,
"text": "<p>Don't use the 'helper' methods, they tend to cause more trouble than they're worth.</p>\n\n<p>Any time you wa... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109775",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26454/"
] | I was surprised this morning to hear that the contents on my WP site are erased, said my client. I tried disable all plugins one by one, but the problem still exists. I also changed the memory limit via the wp-config and that could not solve the problem either. Then I switched to another theme, twenty-eleven and twenty... | Don't use the 'helper' methods, they tend to cause more trouble than they're worth.
Any time you want to grab posts, be it the latest, the oldest, in a category etc, use a `WP_Query` loop, here is its standard form:
```
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {... |
109,777 | <p>A very common issue that I experience with new authors is that they forget to complete a few essential tasks prior to submitting their post for review (even though I have a guide available for them).</p>
<p>Is it possible to add a confirmation box that appear only when a contributor clicks on the "Submit for Review... | [
{
"answer_id": 109783,
"author": "Greeso",
"author_id": 34253,
"author_profile": "https://wordpress.stackexchange.com/users/34253",
"pm_score": 0,
"selected": false,
"text": "<p>It is possible to do so. You have to use the <code>wp_insert_post_data</code> filter hook. I will give you the... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109777",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24875/"
] | A very common issue that I experience with new authors is that they forget to complete a few essential tasks prior to submitting their post for review (even though I have a guide available for them).
Is it possible to add a confirmation box that appear only when a contributor clicks on the "Submit for Review" button? ... | A useful fast way is to use JavaScript in combination with an Ajax action that outputs the box.
Create a small plugin. Create a folder inside plugins directory, naming it 'SubmitReviewConf'. In this folder create a PHP file named `SubmitReviewConf.php`.
In this file, put this code:
```
<?php
/**
* Plugin Name: Submi... |
109,793 | <p><strong>Note</strong></p>
<p><em>Use at your own risk, it is buggy and I have run across a couple instances where it would delete ALL attachments. Unsure why.</em></p>
<p>Is it possible to delete media associated with a page when that page is deleted? I know in the Insert Media page you can filter by images "Uploa... | [
{
"answer_id": 109791,
"author": "Jon Mitten",
"author_id": 36309,
"author_profile": "https://wordpress.stackexchange.com/users/36309",
"pm_score": 1,
"selected": false,
"text": "<p>Found it here: <a href=\"https://stackoverflow.com/questions/4893435/getting-the-wordpress-post-id-of-curr... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109793",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | **Note**
*Use at your own risk, it is buggy and I have run across a couple instances where it would delete ALL attachments. Unsure why.*
Is it possible to delete media associated with a page when that page is deleted? I know in the Insert Media page you can filter by images "Uploaded to this page" so could I get a li... | You can simply call `get_post()`, it returns the current post if no ID is specified.
[`get_the_ID()`](https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-includes/post-template.php#L20) actually does the same. |
109,799 | <p>Using wordpress 3.6 and can embed video in pages/posts. But These videos are not responsive. Is there a way to make them responsive? I found a style="width:100%; height:100%" method for media element player but don't know how to use it with video tag.</p>
| [
{
"answer_id": 109806,
"author": "joshrathke",
"author_id": 36526,
"author_profile": "https://wordpress.stackexchange.com/users/36526",
"pm_score": 0,
"selected": false,
"text": "<p>Yep, it's called intrinsic aspect ratio. <a href=\"http://css-tricks.com/NetMag/FluidWidthVideo/Article-F... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109799",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6028/"
] | Using wordpress 3.6 and can embed video in pages/posts. But These videos are not responsive. Is there a way to make them responsive? I found a style="width:100%; height:100%" method for media element player but don't know how to use it with video tag. | Try adding this CSS:
```
.wp-video-shortcode {
max-width: 100%;
}
.wp-audio-shortcode {
max-width: 100%;
}
``` |
109,801 | <p>I have many permalinks across my site that looks like this:</p>
<pre><code>http://www.example.com/market/category/slug-here/
</code></pre>
<p>and would like to hide <code>/category/</code> for all permalinks that contain it, like so:</p>
<pre><code>http://www.example.com/market/slug-here/
</code></pre>
<p>I trie... | [
{
"answer_id": 109815,
"author": "Mark Davidson",
"author_id": 34111,
"author_profile": "https://wordpress.stackexchange.com/users/34111",
"pm_score": 2,
"selected": false,
"text": "<p>I believe the rewrite rule your wanting to alter is this</p>\n\n<pre><code>category/(.+?)/?$ index.php?... | 2013/08/12 | [
"https://wordpress.stackexchange.com/questions/109801",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2798/"
] | I have many permalinks across my site that looks like this:
```
http://www.example.com/market/category/slug-here/
```
and would like to hide `/category/` for all permalinks that contain it, like so:
```
http://www.example.com/market/slug-here/
```
I tried to use the following rule but did not find success. Anyone... | I believe the rewrite rule your wanting to alter is this
```
category/(.+?)/?$ index.php?category_name=$matches[1] category
```
to do what you want it should just be a case of adding the following rewrite rule in your `functions.php`
```
add_rewrite_rule('(.+?)/?$', 'index.php?category_name=$matches[1]', 'top');
`... |
109,836 | <p>I've been running a local version of a site on which NextGen gallery plugin is installed. It's working great. </p>
<p>I uploaded to remote hosting and updated all "localhost" paths with the remote path in MySQL as part of my normal process. Unfortunately, the NextGen gallery plugin is still looking for localhost sc... | [
{
"answer_id": 109838,
"author": "David Hechler",
"author_id": 16584,
"author_profile": "https://wordpress.stackexchange.com/users/16584",
"pm_score": 0,
"selected": false,
"text": "<p>It might be stored in the database as a reference (although that would be odd). Try using this plugin t... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8497/"
] | I've been running a local version of a site on which NextGen gallery plugin is installed. It's working great.
I uploaded to remote hosting and updated all "localhost" paths with the remote path in MySQL as part of my normal process. Unfortunately, the NextGen gallery plugin is still looking for localhost scripts:
`... | This is what you need to do:
1. In the Dashboard, go to Gallery > Other options
2. Click on "Lightbox effects" tab
3. Click "Show advanced settings"
4. In the text boxes, changes the stylesheet and javascript urls. Change from 'localhost' to your new path.
5. Click save
6. Done! It will now work... |
109,839 | <p>I have created a new image size using the add_image_size(), and I want to have it listed in the media library image size when I insert it. So I have the following code:</p>
<pre><code>add_image_size( "grade-image", 320, 300, true );
function sgr_display_image_size_names_muploader( $sizes ) {
$new_sizes = arra... | [
{
"answer_id": 109843,
"author": "David Hechler",
"author_id": 16584,
"author_profile": "https://wordpress.stackexchange.com/users/16584",
"pm_score": 4,
"selected": true,
"text": "<p>No, that seems to work right. You could test it by doing </p>\n\n<pre><code><?php echo get_the_post_t... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28229/"
] | I have created a new image size using the add\_image\_size(), and I want to have it listed in the media library image size when I insert it. So I have the following code:
```
add_image_size( "grade-image", 320, 300, true );
function sgr_display_image_size_names_muploader( $sizes ) {
$new_sizes = array(
"... | No, that seems to work right. You could test it by doing
```
<?php echo get_the_post_thumbnail('grade-image'); ?>
```
try this.
```
add_image_size( "grade-image", 320, 300, true );
add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, arra... |
109,840 | <p>I want to create one menu for all users and then hide / remove items from the menu if they don't have access to the page the link leads to. This to me seem like an SOP. I really don't understand how this is not a core functionality. I can't possibly be the first one to want or think of such an idea. anyway</p>
<p>... | [
{
"answer_id": 109847,
"author": "Digitalchild",
"author_id": 3170,
"author_profile": "https://wordpress.stackexchange.com/users/3170",
"pm_score": 1,
"selected": false,
"text": "<p>This was asked here a couple of years ago. </p>\n\n<p><a href=\"https://wordpress.stackexchange.com/questi... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109840",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35047/"
] | I want to create one menu for all users and then hide / remove items from the menu if they don't have access to the page the link leads to. This to me seem like an SOP. I really don't understand how this is not a core functionality. I can't possibly be the first one to want or think of such an idea. anyway
here is wha... | If you use the `'wp_nav_menu_objects'` filter, you get a list of menu items before the `Walker` processes them. Each menu item is a WP\_Post object with some menu specific properties added in. The `ID` property is the post ID.
```
add_filter( 'wp_nav_menu_objects', 'rm_menu_items', 10, 2 );
function rm_menu_items( $m... |
109,846 | <p>I am building a theme which Theme customizer changes colors, sizes, etc. and has also the option to choose a category and style that category specifically.</p>
<p>How can I display that category in the preview (only when the user is changing the corresponding options) instead of the default home/front page displaye... | [
{
"answer_id": 110949,
"author": "jkhedani",
"author_id": 24594,
"author_profile": "https://wordpress.stackexchange.com/users/24594",
"pm_score": 0,
"selected": false,
"text": "<p>Here's an approach I used to show things to users while they are viewing the site through the Theme Customiz... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109846",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16533/"
] | I am building a theme which Theme customizer changes colors, sizes, etc. and has also the option to choose a category and style that category specifically.
How can I display that category in the preview (only when the user is changing the corresponding options) instead of the default home/front page displayed by defau... | I ended up with this solution:
1.Require an extra file that will contain the hooks only in the theme preview
```
function mytheme_customizer_live_preview() {
require_once('library/preview.php');
}
add_action( 'customize_preview_init', 'mytheme_customizer_live_preview' );
```
2.What I had to do is modify the que... |
109,849 | <p>I need to do multi-level ordering in a query. The issue is with ordering one value DESC and the other ASC as in SQL. The following SQL seems to give me what I want when I run it in terminal:</p>
<pre><code>SELECT DISTINCT * FROM wp_posts
INNER JOIN wp_postmeta
ON wp_posts.ID = wp_postmeta.post_id
WHERE wp_posts.... | [
{
"answer_id": 109853,
"author": "Marin Bînzari",
"author_id": 35115,
"author_profile": "https://wordpress.stackexchange.com/users/35115",
"pm_score": 6,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>$args = array(\n 'post_type' => 'post',\n 'meta_key' => ... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35659/"
] | I need to do multi-level ordering in a query. The issue is with ordering one value DESC and the other ASC as in SQL. The following SQL seems to give me what I want when I run it in terminal:
```
SELECT DISTINCT * FROM wp_posts
INNER JOIN wp_postmeta
ON wp_posts.ID = wp_postmeta.post_id
WHERE wp_posts.post_type = 'p... | Try this:
```
$args = array(
'post_type' => 'post',
'meta_key' => 'pb_issue_featured',
'orderby' => 'meta_value',
'order' => 'DESC',
'posts_per_page' => $posts,
'paged' => $paged,
'paged' => 1,
'meta_query' => array(
array(
'... |
109,866 | <p>I have a generic question that I would like to ask.</p>
<p>How do we go about creating an extendable wordpress plugin. I would like to create a plugin that I can easily allow new extensions to be hooked up to it.</p>
<p>Does anyone have any tips or guides or tutorials to doing this?</p>
| [
{
"answer_id": 109870,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>The following:</p>\n\n<ul>\n<li>Use hooks and filters to power things. Pass args into a filter before doing ... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109866",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36452/"
] | I have a generic question that I would like to ask.
How do we go about creating an extendable wordpress plugin. I would like to create a plugin that I can easily allow new extensions to be hooked up to it.
Does anyone have any tips or guides or tutorials to doing this? | The following:
* Use hooks and filters to power things. Pass args into a filter before doing things with them, pass return values to filters before returning them, etc, hooks and filters everywhere
* namespace everything, `tomjn_twittercount` is a better function name than `twittercount`
* Practice good common sense g... |
109,869 | <p>How does filters and hooks actually work in WordPress?</p>
<p>I'm asking about something advanced. How is it implemented in PHP? E.g how does it collect all the hooks from the different plugins and "attach" them to the core hooks etc.</p>
| [
{
"answer_id": 109889,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 6,
"selected": true,
"text": "<h2>Overview</h2>\n\n<p>Basically the \"<a href=\"https://codex.wordpress.org/Plugin_API\">Plugin API</a>,\" which sum... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109869",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36452/"
] | How does filters and hooks actually work in WordPress?
I'm asking about something advanced. How is it implemented in PHP? E.g how does it collect all the hooks from the different plugins and "attach" them to the core hooks etc. | Overview
--------
Basically the "[Plugin API](https://codex.wordpress.org/Plugin_API)," which summons Filters and Hooks, consists out of the following functions:
1. [`apply_filters()`](http://queryposts.com/function/apply_filters/) - *execute*
2. [`do_action`](http://queryposts.com/function/do_action/) - *execute*
3.... |
109,884 | <p>I have a category organized like this:</p>
<ul>
<li><p>sport</p>
<ul>
<li>football</li>
<li>basketball</li>
<li>volleyball</li>
</ul></li>
<li><p>news</p>
<ul>
<li>economy</li>
<li>world</li>
<li>country</li>
</ul></li>
</ul>
<p>And I want to display only the <em>sport</em> and <em>news</em> root categories, but... | [
{
"answer_id": 109891,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 1,
"selected": false,
"text": "<p>If I understand you correctly, you want to display the parent Categories themselves, and not their posts,... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109884",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33913/"
] | I have a category organized like this:
* sport
+ football
+ basketball
+ volleyball
* news
+ economy
+ world
+ country
And I want to display only the *sport* and *news* root categories, but I don’t know how. | If I understand you correctly, you want to display the parent Categories themselves, and not their posts, correct? [`get_terms`](http://codex.wordpress.org/Function_Reference/get_terms) is what you need.
```
$top_level_categories = get_terms( 'category', array(
'parent' => 0, // This will get ONLY top level items
... |
109,901 | <p>Im having a problem where WP for some odd reason is stripping out my BR tags. Ive looked online and have read a few solutions that people offered including the installation of TinyMCE advanced plugin and still....the same thing.</p>
<p>The problem is that not matter what i do, even if i go to the html tab and manua... | [
{
"answer_id": 109910,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>I'm guessing this is a custom field you are referring to?</p>\n\n<p>You haven't posted any code, but however... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109901",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12944/"
] | Im having a problem where WP for some odd reason is stripping out my BR tags. Ive looked online and have read a few solutions that people offered including the installation of TinyMCE advanced plugin and still....the same thing.
The problem is that not matter what i do, even if i go to the html tab and manually insert... | Don't use `the_excerpt()` if you want to have line-breaks ;) |
109,927 | <p>I create a form for user to submit content from the frontend. The only problem is I don't know how to handler the image upload.</p>
<p>So, I want to know how to use the WP media uploader in the frontend. The media uploader should be appeared like in the 'wp-admin/media-new.php'.
I don't want the pop up version of ... | [
{
"answer_id": 109945,
"author": "Puggan Se",
"author_id": 36573,
"author_profile": "https://wordpress.stackexchange.com/users/36573",
"pm_score": 0,
"selected": false,
"text": "<p>the Ajax calls for <a href=\"http://core.trac.wordpress.org/browser/tags/3.6/wp-admin/media-upload.php\" re... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109927",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31705/"
] | I create a form for user to submit content from the frontend. The only problem is I don't know how to handler the image upload.
So, I want to know how to use the WP media uploader in the frontend. The media uploader should be appeared like in the 'wp-admin/media-new.php'.
I don't want the pop up version of the upload... | Add this code to your theme's functions.php file:
```
function add_media_upload_scripts() {
if ( is_admin() ) {
return;
}
wp_enqueue_media();
}
add_action('wp_enqueue_scripts', 'add_media_upload_scripts');
```
This will cause the the media upload files to load on your front end pages. If you ... |
109,932 | <p>I am setting up a Wordpress site with Buddypress functionality for a client. The client wants the "What's new" text under the "Activity" tab changed to something else. I feel like this should be editable in the Buddypress theme files, but I can't seem to find it.</p>
<p>Here's a screenshot with the text I'm talking... | [
{
"answer_id": 109945,
"author": "Puggan Se",
"author_id": 36573,
"author_profile": "https://wordpress.stackexchange.com/users/36573",
"pm_score": 0,
"selected": false,
"text": "<p>the Ajax calls for <a href=\"http://core.trac.wordpress.org/browser/tags/3.6/wp-admin/media-upload.php\" re... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109932",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36167/"
] | I am setting up a Wordpress site with Buddypress functionality for a client. The client wants the "What's new" text under the "Activity" tab changed to something else. I feel like this should be editable in the Buddypress theme files, but I can't seem to find it.
Here's a screenshot with the text I'm talking about:
... | Add this code to your theme's functions.php file:
```
function add_media_upload_scripts() {
if ( is_admin() ) {
return;
}
wp_enqueue_media();
}
add_action('wp_enqueue_scripts', 'add_media_upload_scripts');
```
This will cause the the media upload files to load on your front end pages. If you ... |
109,955 | <p>I am looking to add a custom column to a custom post type post listing table in the dashboard.</p>
<p>I have read many questions / answers on WPSE, along with <a href="http://scribu.net/wordpress/custom-sortable-columns.html" rel="noreferrer">this article</a>. Although, it seems like everyone wants to query by meta... | [
{
"answer_id": 119584,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 5,
"selected": true,
"text": "<p>To achieve adding a custom sortable column to the <code>WP_List_Table</code> of your post type within th... | 2013/08/13 | [
"https://wordpress.stackexchange.com/questions/109955",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9579/"
] | I am looking to add a custom column to a custom post type post listing table in the dashboard.
I have read many questions / answers on WPSE, along with [this article](http://scribu.net/wordpress/custom-sortable-columns.html). Although, it seems like everyone wants to query by meta key / value.
I am trying to add a ta... | To achieve adding a custom sortable column to the `WP_List_Table` of your post type within the WordPress administration back-end dashboard, you will need to do the following:
1. Replace all occurrences of `YOUR-POST-TYPE-NAME` with your actual post type name.
2. Replace all occurrences of `YOUR-TAXONOMY-NAME` with you... |
109,970 | <p>I can rename wp-admin menu items But How Can I active it for all users except Super Admin ?</p>
<pre><code>add_filter('gettext', 'rename_admin_menu_items');
add_filter('ngettext', 'rename_admin_menu_items');
function rename_admin_menu_items( $menu ) {
$menu = str_ireplace( 'Dashboard', 'Home', $menu );
return $menu... | [
{
"answer_id": 119584,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 5,
"selected": true,
"text": "<p>To achieve adding a custom sortable column to the <code>WP_List_Table</code> of your post type within th... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/109970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29072/"
] | I can rename wp-admin menu items But How Can I active it for all users except Super Admin ?
```
add_filter('gettext', 'rename_admin_menu_items');
add_filter('ngettext', 'rename_admin_menu_items');
function rename_admin_menu_items( $menu ) {
$menu = str_ireplace( 'Dashboard', 'Home', $menu );
return $menu;
}
``` | To achieve adding a custom sortable column to the `WP_List_Table` of your post type within the WordPress administration back-end dashboard, you will need to do the following:
1. Replace all occurrences of `YOUR-POST-TYPE-NAME` with your actual post type name.
2. Replace all occurrences of `YOUR-TAXONOMY-NAME` with you... |
109,973 | <p>Two quick questions.</p>
<p><strong>How does default thumbnail size work?</strong></p>
<pre><code>if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails');
set_post_thumbnail_size( 800, 600, true );
}
</code></pre>
<p>What does above code really mean?</p>
<p>Does it mean all my... | [
{
"answer_id": 119584,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 5,
"selected": true,
"text": "<p>To achieve adding a custom sortable column to the <code>WP_List_Table</code> of your post type within th... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/109973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | Two quick questions.
**How does default thumbnail size work?**
```
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails');
set_post_thumbnail_size( 800, 600, true );
}
```
What does above code really mean?
Does it mean all my thumbnails will be 800x600 or smaller? Because even ... | To achieve adding a custom sortable column to the `WP_List_Table` of your post type within the WordPress administration back-end dashboard, you will need to do the following:
1. Replace all occurrences of `YOUR-POST-TYPE-NAME` with your actual post type name.
2. Replace all occurrences of `YOUR-TAXONOMY-NAME` with you... |
109,985 | <p>I declared an action for a single event in Wordpress which accepts an array as an argument:</p>
<pre><code>$asins = array(); //I had to declare this since I'm getting a notice of undefined variable if I don't
add_action('z_purge_products_cache', array($this, 'purge_products_cache', $asins));
</code></pre>
<p>I al... | [
{
"answer_id": 109987,
"author": "Ben Miller - Remember Monica",
"author_id": 32110,
"author_profile": "https://wordpress.stackexchange.com/users/32110",
"pm_score": 2,
"selected": true,
"text": "<p>The parameter needs to be passed to the callback function in the <a href=\"https://codex.... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/109985",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27291/"
] | I declared an action for a single event in Wordpress which accepts an array as an argument:
```
$asins = array(); //I had to declare this since I'm getting a notice of undefined variable if I don't
add_action('z_purge_products_cache', array($this, 'purge_products_cache', $asins));
```
I also tried this one, but it ... | The parameter needs to be passed to the callback function in the [wp\_schedule\_single\_event](https://codex.wordpress.org/Function_Reference/wp_schedule_single_event) function, not the [add\_action](https://codex.wordpress.org/Function_Reference/add_action) function.
Try this:
```
add_action('z_purge_products_cache'... |
109,993 | <p>i have a <strong>php code</strong> inside my website to a quotation form that has
<strong>java script</strong> for making </p>
<pre><code> name , telephone number and email
</code></pre>
<p>rquired fields before submiting the form and its working fine but a few day ago i found that someone is sending me alot of ... | [
{
"answer_id": 109997,
"author": "Puggan Se",
"author_id": 36573,
"author_profile": "https://wordpress.stackexchange.com/users/36573",
"pm_score": 1,
"selected": false,
"text": "<p>you need the same checks, coded in php, at the php that recives the post-data from the form.</p>\n\n<p>a si... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/109993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27084/"
] | i have a **php code** inside my website to a quotation form that has
**java script** for making
```
name , telephone number and email
```
rquired fields before submiting the form and its working fine but a few day ago i found that someone is sending me alot of junk for that form and he send the form empty is that... | It may possible that he is trying to hack. I am sure you are storing form data after escaping/sanitizing the content which eliminate the risk of Sql injection

and since user can submit empty form it mean you haven done the server side validation. w... |
110,004 | <p>To get images loaded correctly when I use img src in HTML, I have to give the entire file path. Using CSS I would only need to use:</p>
<pre><code>`background-image: url(images/morebutton.png)`
</code></pre>
<p>With img src I have to use this: </p>
<pre><code><img src="wp-content/themes/blankslate/images/moreb... | [
{
"answer_id": 110005,
"author": "joshrathke",
"author_id": 36526,
"author_profile": "https://wordpress.stackexchange.com/users/36526",
"pm_score": 2,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code><img src=\"<?php echo get_bloginfo( 'template_directory' ); ?>/images... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/110004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35640/"
] | To get images loaded correctly when I use img src in HTML, I have to give the entire file path. Using CSS I would only need to use:
```
`background-image: url(images/morebutton.png)`
```
With img src I have to use this:
```
<img src="wp-content/themes/blankslate/images/morebutton.png">
```
Using this file path g... | No your file path setup is correct, you need to provide the absolute path in you img src for images to load on other pages as relative path would change to,
```
http://yourwebsite.com/page/wp-content/themes/blankslate/images/morebutton.png
```
and instead it should be
```
http://yourwebsite.com/wp-content/themes/... |
110,019 | <p>I'm using this little snippet of code to try and list the terms of a custom taxonomy for use in a meta box select box but it doesn't show anything when I implement it (Despite working with the default 'category' taxonomy)</p>
<pre><code>$partners = array();
$partners_obj = get_categories(array('taxonomy' => 'par... | [
{
"answer_id": 110022,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 1,
"selected": false,
"text": "<p>Are your taxonomy terms empty? They will not show by default. You could try using:</p>\n\n<pre><code>$partner... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/110019",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33310/"
] | I'm using this little snippet of code to try and list the terms of a custom taxonomy for use in a meta box select box but it doesn't show anything when I implement it (Despite working with the default 'category' taxonomy)
```
$partners = array();
$partners_obj = get_categories(array('taxonomy' => 'partner-cat'));
$par... | ```
get_categories()
```
fetches taxonomies of type 'categories' particularly <http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/category.php#L0>,
to fetch custom taxonomy you should use get\_terms() instead, here <http://codex.wordpress.org/Function_Reference/get_terms>
```
$terms = get_terms( 'partner-c... |
110,034 | <p>I'm making a magazine theme for a client and using a custom 'issue' taxonomy. There is a new issue every week, and I also have a function that get's the latest issue. But the editor creates a new issue a few days before the articles for that issue are published. My current function uses max() to just find the highes... | [
{
"answer_id": 110043,
"author": "Kumar",
"author_id": 32466,
"author_profile": "https://wordpress.stackexchange.com/users/32466",
"pm_score": 2,
"selected": true,
"text": "<pre><code>function get_issues() {\n $output = array();\n $hlterms = get_terms('issue', array('orderby' => 'id',... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/110034",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35659/"
] | I'm making a magazine theme for a client and using a custom 'issue' taxonomy. There is a new issue every week, and I also have a function that get's the latest issue. But the editor creates a new issue a few days before the articles for that issue are published. My current function uses max() to just find the highest n... | ```
function get_issues() {
$output = array();
$hlterms = get_terms('issue', array('orderby' => 'id', 'order' => 'DESC','hide_empty' => false));
foreach($hlterms as $term){
array_push($output, $term->term_id);
}
return $output;
}
```
This would return you term id as per the recent and then in your second f... |
110,036 | <p>I was wondering if there is a way to actually <em>limit</em> the amount of users that can register to a Wordpress site? </p>
<p>As an example, I am wanting to create a small site that will hold information for a customer, where they can only have a maximum of (for example) 50 users. The idea is that you will need t... | [
{
"answer_id": 110042,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": true,
"text": "<p>As you can see in the <a href=\"http://codex.wordpress.org/Option_Reference\" rel=\"nofollow\">WordPress Option Ref... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/110036",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36618/"
] | I was wondering if there is a way to actually *limit* the amount of users that can register to a Wordpress site?
As an example, I am wanting to create a small site that will hold information for a customer, where they can only have a maximum of (for example) 50 users. The idea is that you will need to log in to view ... | As you can see in the [WordPress Option Reference](http://codex.wordpress.org/Option_Reference), there's an option called `users_can_register`. You can - per default - set it in your (network-)sites settings.
* `1` => Yes
* `0` => No
As usual: There's a filter to intercept that from a plugin.
```
"option_{$option_na... |
110,037 | <p>I want to add an action whenever the admin publishes a product, but the WP hook publish_post does not trigger then - even though a wc product is just another type of post.</p>
<p>I haven't found a woocommerce hook that triggers when a product is published.</p>
<p>Any thoughts?</p>
| [
{
"answer_id": 110052,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 3,
"selected": true,
"text": "<p>I recommand you to use the <code>transition_post_status</code>. See example below :</p>\n\n<pre><code> add_action... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/110037",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35726/"
] | I want to add an action whenever the admin publishes a product, but the WP hook publish\_post does not trigger then - even though a wc product is just another type of post.
I haven't found a woocommerce hook that triggers when a product is published.
Any thoughts? | I recommand you to use the `transition_post_status`. See example below :
```
add_action('transition_post_status', 'wpse_110037_new_posts', 10, 3);
function wpse_110037_new_posts($new_status, $old_status, $post) {
if(
$old_status != 'publish'
&& $new_status == 'publish'
&& !empty($post->ID... |
110,077 | <p>How do I get the following code to insert a link only if the custom function has a value?</p>
<pre><code><td><a href="<?php echo esc_html( get_post_meta( get_the_ID(), 'game_review_link', true ) ); ?>"><div class="rating-<?php echo esc_html( get_post_meta( get_the_ID(), 'game_rating', true )... | [
{
"answer_id": 110078,
"author": "Rachel Baker",
"author_id": 8054,
"author_profile": "https://wordpress.stackexchange.com/users/8054",
"pm_score": 3,
"selected": true,
"text": "<pre><code><td>\n<?php $review_link = get_post_meta( get_the_ID(), 'game_review_link', true );\nif ( ... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/110077",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11945/"
] | How do I get the following code to insert a link only if the custom function has a value?
```
<td><a href="<?php echo esc_html( get_post_meta( get_the_ID(), 'game_review_link', true ) ); ?>"><div class="rating-<?php echo esc_html( get_post_meta( get_the_ID(), 'game_rating', true ) ); ?>"><?php echo esc_html( get_post_... | ```
<td>
<?php $review_link = get_post_meta( get_the_ID(), 'game_review_link', true );
if ( ! empty( $review_link ) ) : ?>
<a href="<?php echo esc_html( $review_link ); ?>">
<div class="rating-<?php echo esc_html( $review_link ); ?>">
<?php echo esc_html( $review_link ); ?>
</div>
</... |
110,082 | <p>I have several installations of wordpress and now im trying to create my own small framework so I can create and maintain my themes more efficiently. What I would like to do is to have a wrapper for the hooks that wordpress offer. </p>
<p>I would like to call hooks like this in my application </p>
<pre><code>$_a... | [
{
"answer_id": 110114,
"author": "Leandro Villagran",
"author_id": 36631,
"author_profile": "https://wordpress.stackexchange.com/users/36631",
"pm_score": 0,
"selected": false,
"text": "<p>I figure it out. the problem is that add_action is expecting an object with a method. <code>add_ac... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/110082",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36631/"
] | I have several installations of wordpress and now im trying to create my own small framework so I can create and maintain my themes more efficiently. What I would like to do is to have a wrapper for the hooks that wordpress offer.
I would like to call hooks like this in my application
```
$_addThumb = function(){
a... | As you have noticed already, `$this` will not work as you expected prior to PHP 5.4. You can [read this in the PHP wiki](https://wiki.php.net/rfc/closures/object-extension). The reason:
>
> For PHP 5.3 `$this` support for Closures was removed because no consensus could be reached how to implement it in a sane fashion... |
110,085 | <p>Anyone else having issues with WordPress 3.6 and the Accordion UI?</p>
<p>I have a website that was working just fine till I updated it to WordPress 3.6. The accordion menu stopped working. No errors.</p>
<p>Enqueue</p>
<pre><code>wp_register_script('accordion',get_template_directory_uri().'/js/accordion.js', arr... | [
{
"answer_id": 110093,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure if it's because \"accordion\" all of the sudden became a reserved word in wordpress. But once I ... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/110085",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30984/"
] | Anyone else having issues with WordPress 3.6 and the Accordion UI?
I have a website that was working just fine till I updated it to WordPress 3.6. The accordion menu stopped working. No errors.
Enqueue
```
wp_register_script('accordion',get_template_directory_uri().'/js/accordion.js', array('jquery', 'jquery-ui-acco... | I'm not sure if it's because "accordion" all of the sudden became a reserved word in wordpress. But once I switched my wp\_enqueue\_script/wp\_register\_script handle from accordion to myaccordion - everything worked. |
110,094 | <p>My custom login form redirects to the wp-admin login when an user doesn't manage to guesses his/her credentials right. How can I manage to redirect the user to the current form instead? And of course show the proper errors?</p>
<p>Here is the code: (same as on WordPress manual)</p>
<pre><code>$args = array(
... | [
{
"answer_id": 119576,
"author": "Kumar",
"author_id": 32466,
"author_profile": "https://wordpress.stackexchange.com/users/32466",
"pm_score": 1,
"selected": false,
"text": "<p>Did you tried echoing the </p>\n\n<pre><code>site_url($_SERVER['REQUEST_URI'] );\n</code></pre>\n\n<p>this one ... | 2013/08/14 | [
"https://wordpress.stackexchange.com/questions/110094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32164/"
] | My custom login form redirects to the wp-admin login when an user doesn't manage to guesses his/her credentials right. How can I manage to redirect the user to the current form instead? And of course show the proper errors?
Here is the code: (same as on WordPress manual)
```
$args = array(
'echo' => true,
... | While coding a custom login page, one needs to take care of the errors, else WordPress would redirect the page to /wp-admin or wp-login.php on wrong passwords or empty credentials. Please follow the below to solve this issue:--
Please use the below in your theme's functions.php file:-
```
/**
* Function Name: front_... |
110,111 | <p>I just transferred a WordPress installation from the domain to my localhost. I did all the usual steps: copy files, export DB and replace <code>domain.com</code> with <code>localhost</code>, update <code>wp-config.php</code> and refresh permalinks. All pages and custom rewrite rules work, but some images are giving ... | [
{
"answer_id": 110117,
"author": "George Yates",
"author_id": 36363,
"author_profile": "https://wordpress.stackexchange.com/users/36363",
"pm_score": 0,
"selected": false,
"text": "<p>If it's not there in your FTP client - therefore not on your server - it's not going to be showing up on... | 2013/08/15 | [
"https://wordpress.stackexchange.com/questions/110111",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8536/"
] | I just transferred a WordPress installation from the domain to my localhost. I did all the usual steps: copy files, export DB and replace `domain.com` with `localhost`, update `wp-config.php` and refresh permalinks. All pages and custom rewrite rules work, but some images are giving a 404.
When I check those images on... | Changing the `home` and `siteurl` in your `wp_options` table is not enough unfortunately. You will still have your post content with your non-localhost URL (`http://domain.com`) causing your website to not display properly on your localhost.
Once you've downloaded and imported your database to your localhost. Follow t... |
110,139 | <p>Recently I have downloaded a wordpress theme . I use Theme Authenticity Checker (TAC) (<a href="http://wordpress.org/plugins/tac/" rel="nofollow">http://wordpress.org/plugins/tac/</a>) plugin to find any malicious data . According to it's report the theme contains some encrypted code like this </p>
<pre><code>$pid ... | [
{
"answer_id": 110147,
"author": "M-R",
"author_id": 17061,
"author_profile": "https://wordpress.stackexchange.com/users/17061",
"pm_score": 1,
"selected": false,
"text": "<p>It does not seems to be harmful. Looks like, <code>base64_decode</code> function is just used to decrypt the encr... | 2013/08/15 | [
"https://wordpress.stackexchange.com/questions/110139",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23926/"
] | Recently I have downloaded a wordpress theme . I use Theme Authenticity Checker (TAC) (<http://wordpress.org/plugins/tac/>) plugin to find any malicious data . According to it's report the theme contains some encrypted code like this
```
$pid = base64_decode($_POST['control_id']);
```
I don't understand , ... | That is most likely a false positive : <https://en.wikipedia.org/wiki/Type_I_and_type_II_errors>
`base64_decode` is not bad in of itself : <https://en.wikipedia.org/wiki/Base64>
The plugin is not smart enough to know a legitimate reason to use `base64_decode` of which there are many. |
110,140 | <p><strong>Current query:</strong></p>
<pre><code>if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } else if ( get_query_var('page') ) {$paged = get_query_var('page'); } else {$paged = 1; }
$args_main = array(
'cat' => $my_categories_variable,
'posts_per_page' => 3,
... | [
{
"answer_id": 110143,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>You're assigning three different values to your variable:</p>\n\n<pre><code>if ( get_query_var('paged') )\n{\n ... | 2013/08/15 | [
"https://wordpress.stackexchange.com/questions/110140",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4513/"
] | **Current query:**
```
if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } else if ( get_query_var('page') ) {$paged = get_query_var('page'); } else {$paged = 1; }
$args_main = array(
'cat' => $my_categories_variable,
'posts_per_page' => 3,
'paged' => $paged
);
... | You're assigning three different values to your variable:
```
if ( get_query_var('paged') )
{
$paged = get_query_var('paged');
}
else if ( get_query_var('page') )
{
$paged = get_query_var('page');
}
else
{
$paged = 1;
}
```
Short explanation:
1. On `single.php`, `singular.php` and other single view tem... |
110,146 | <p>My function to detect is a gallery is on a page has broken and Im not sure why. So in my theme template's attachment page Im calling this function:</p>
<pre><code>global $post;
$parent_id = $post->post_parent;
if ( strpos(get_post($parent_id)->post_content,'[gallery ') == false ){
$navigation_markup = '... | [
{
"answer_id": 110143,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>You're assigning three different values to your variable:</p>\n\n<pre><code>if ( get_query_var('paged') )\n{\n ... | 2013/08/15 | [
"https://wordpress.stackexchange.com/questions/110146",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19536/"
] | My function to detect is a gallery is on a page has broken and Im not sure why. So in my theme template's attachment page Im calling this function:
```
global $post;
$parent_id = $post->post_parent;
if ( strpos(get_post($parent_id)->post_content,'[gallery ') == false ){
$navigation_markup = 'no gallery';
}else{ ... | You're assigning three different values to your variable:
```
if ( get_query_var('paged') )
{
$paged = get_query_var('paged');
}
else if ( get_query_var('page') )
{
$paged = get_query_var('page');
}
else
{
$paged = 1;
}
```
Short explanation:
1. On `single.php`, `singular.php` and other single view tem... |
110,175 | <p>I'm basing my first WP theme off a blank/boilerplate theme which generates the front page post feed using this code (which is generally present in most WP themes):</p>
<pre><code><?php while ( have_posts() ) : the_post() ?>
<?php get_template_part( 'entry' ); ?>
<?php comments_template(); ?>
<?... | [
{
"answer_id": 110186,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>Use the <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=\"nofollow\"><code>pr... | 2013/08/15 | [
"https://wordpress.stackexchange.com/questions/110175",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23236/"
] | I'm basing my first WP theme off a blank/boilerplate theme which generates the front page post feed using this code (which is generally present in most WP themes):
```
<?php while ( have_posts() ) : the_post() ?>
<?php get_template_part( 'entry' ); ?>
<?php comments_template(); ?>
<?php endwhile; ?>
```
I have one c... | I think you can go even simpler in the coding. Just add the below to your **functions.php** file within your theme folder.
```
function myFeedExcluder($query) {
if ($query->is_feed) {
$query->set('cat','-73,-9'); // categories 73 and 9 are being excluded
}
return $query;
}
add_filter('pre_get_posts','... |
110,182 | <p>I am trying to create a rewrite rule for one of my custom page and here is the rewrite rule</p>
<pre><code>function add_my_rule() {
global $wp;
$wp->add_query_var('name_state');
$wp->add_query_var('arg_second');
add_rewrite_rule('state/([^/]+)/([^/]+)/page/([^/]+)','index.php?pagename=places-t... | [
{
"answer_id": 110505,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 1,
"selected": false,
"text": "<p>In the tags of your answer there is <em><code><plugins></code></em> so I think you are trying to add cu... | 2013/08/15 | [
"https://wordpress.stackexchange.com/questions/110182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9415/"
] | I am trying to create a rewrite rule for one of my custom page and here is the rewrite rule
```
function add_my_rule() {
global $wp;
$wp->add_query_var('name_state');
$wp->add_query_var('arg_second');
add_rewrite_rule('state/([^/]+)/([^/]+)/page/([^/]+)','index.php?pagename=places-to-visit&name_state=$... | I am able to solve this problem.
Honestly speaking till now i was not able to fully understand how WordPress rewrite rule work and how WordPress able to pick my custom page.
I was doing everything right except one thing, i was not associating my custom template with any slug.
Moment i assigned that from WordPress dash... |
110,185 | <p>I need to get a different "get_template_part" based on the date and category. I have changed the outlay of the category which means any post in that category before today's date wont be able to use the new template but needs to still use the old one. </p>
<pre><code>if ( in_category( 'photographer-interviews' )) {
... | [
{
"answer_id": 110189,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>There are many ways of comparing dates. the following is perhaps the simplest (untested):</p>\n\n<pre><code>... | 2013/08/15 | [
"https://wordpress.stackexchange.com/questions/110185",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31195/"
] | I need to get a different "get\_template\_part" based on the date and category. I have changed the outlay of the category which means any post in that category before today's date wont be able to use the new template but needs to still use the old one.
```
if ( in_category( 'photographer-interviews' )) {
get_templat... | There are many ways of comparing dates. the following is perhaps the simplest (untested):
```
if ( in_category( 'photographer-interviews' ) && strtotime( get_the_date( 'c' ) ) > 1376524800 ) {
get_template_part( 'content', 'interview' );
} else {
get_template_part( 'content', 'blog' );
}
```
1376524800 is the Unix... |
110,204 | <p>I am trying to add archives to a sidebar in my wordpress blog. I use: <code><?php wp_get_archives('cat=1'); ?></code> to get display the archives. I now see on the screen the past few months when I have posted content however when I click on the month to see those posts it just takes me back to the homepage in... | [
{
"answer_id": 110189,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>There are many ways of comparing dates. the following is perhaps the simplest (untested):</p>\n\n<pre><code>... | 2013/08/15 | [
"https://wordpress.stackexchange.com/questions/110204",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35551/"
] | I am trying to add archives to a sidebar in my wordpress blog. I use: `<?php wp_get_archives('cat=1'); ?>` to get display the archives. I now see on the screen the past few months when I have posted content however when I click on the month to see those posts it just takes me back to the homepage instead of pulling up ... | There are many ways of comparing dates. the following is perhaps the simplest (untested):
```
if ( in_category( 'photographer-interviews' ) && strtotime( get_the_date( 'c' ) ) > 1376524800 ) {
get_template_part( 'content', 'interview' );
} else {
get_template_part( 'content', 'blog' );
}
```
1376524800 is the Unix... |
110,225 | <p>What is the best method for intercepting the_content of a post (for a single post page) and dividing the_content into sections of 500 characters (or any other number of characters), and then outputting each 500-character section wrapped in its own div container?</p>
<p>I understand that get_the_content() will retur... | [
{
"answer_id": 110263,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p><code>get_the_content()</code> return what's in the editor, but <code>wpautop</code> filters and such are attached... | 2013/08/16 | [
"https://wordpress.stackexchange.com/questions/110225",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36266/"
] | What is the best method for intercepting the\_content of a post (for a single post page) and dividing the\_content into sections of 500 characters (or any other number of characters), and then outputting each 500-character section wrapped in its own div container?
I understand that get\_the\_content() will return the ... | `get_the_content()` return what's in the editor, but `wpautop` filters and such are attached to `the_content` (which you don't need inside your split function - just apply it later manually with
```
apply_filters( 'the_content', $output );
```
at the end.
You should as well use `strip_shortcodes( get_the_content() ... |
110,233 | <p>Is there any sort of jquery I can use to check if there is only one blog post on the page, then to add custom CSS? And if there is more than one, add different CSS?</p>
<pre><code><div class="main-blog top top-fix">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post( '' ); ?... | [
{
"answer_id": 110263,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p><code>get_the_content()</code> return what's in the editor, but <code>wpautop</code> filters and such are attached... | 2013/08/16 | [
"https://wordpress.stackexchange.com/questions/110233",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36530/"
] | Is there any sort of jquery I can use to check if there is only one blog post on the page, then to add custom CSS? And if there is more than one, add different CSS?
```
<div class="main-blog top top-fix">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post( '' ); ?>
<div class="divider ... | `get_the_content()` return what's in the editor, but `wpautop` filters and such are attached to `the_content` (which you don't need inside your split function - just apply it later manually with
```
apply_filters( 'the_content', $output );
```
at the end.
You should as well use `strip_shortcodes( get_the_content() ... |
110,244 | <p>Ideally I would like to do this with both my PC and Mac OSX boxes, but for now I would be thrilled with just the Mac OSX.</p>
<p>I am trying to keep my WP Themes & Plugin Local Development synced using Dropbox. I am using XAMPP for both Windows and Mac as my LAMP Stack and am wondering what I have to set in ord... | [
{
"answer_id": 110268,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>I use Dropbox as well, but not directly linked as the Dropbox folder path could differ from install to install. My... | 2013/08/16 | [
"https://wordpress.stackexchange.com/questions/110244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36683/"
] | Ideally I would like to do this with both my PC and Mac OSX boxes, but for now I would be thrilled with just the Mac OSX.
I am trying to keep my WP Themes & Plugin Local Development synced using Dropbox. I am using XAMPP for both Windows and Mac as my LAMP Stack and am wondering what I have to set in order to get the ... | You will need to create an alias to your Dropbox folder so those files can be accessed on your server. This can be done in `httpd.conf`:
```
Alias /dropbox /Users/seth/Dropbox
```
Or you could make a direct alias to the real `wp-content` folder:
```
Alias /wp-content /Users/seth/Dropbox/Xammp-Content/wordpress/wp-c... |
110,260 | <p>Is there plugin (or an easyish way) to add code to the <code><head></code> section on a per page/post basis? </p>
<p>I have a multilingual website and I need to implement the <a href="https://support.google.com/webmasters/answer/189077?hl=en" rel="nofollow">rel="alternate" hreflang markup</a>, so need a way ... | [
{
"answer_id": 110261,
"author": "Jigar Gorakhiya",
"author_id": 36613,
"author_profile": "https://wordpress.stackexchange.com/users/36613",
"pm_score": 2,
"selected": false,
"text": "<p>Use the below code in the <code><head></code> section:</p>\n\n<pre><code><?php\nadd_action('... | 2013/08/16 | [
"https://wordpress.stackexchange.com/questions/110260",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33751/"
] | Is there plugin (or an easyish way) to add code to the `<head>` section on a per page/post basis?
I have a multilingual website and I need to implement the [rel="alternate" hreflang markup](https://support.google.com/webmasters/answer/189077?hl=en), so need a way to define `rel="alternate"` individually on each page/... | As you said per page/post basis, this would work for each post
```
add_action('wp_head', 'add_link_in_head');
function add_link_in_head()
{
global $post;
if(!empty($post))
{
$alternate = get_post_meta($post->ID, 'alternate', true);
$hreflang = get_post_meta($post->ID, 'hreflang', true);
... |
110,266 | <p>I am searching for a way by which i can print the executed sql query just after the :</p>
<pre><code>$wpdb->query(
$wpdb->prepare("INSERT
INTO tbl_watchprosite SET
keywords=%s,url_to_post=%s,description=%s,
... | [
{
"answer_id": 110269,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 7,
"selected": true,
"text": "<p>The <code>$wpdb</code> object has some properties getting set for that:</p>\n<pre><code>global $wpdb;\n\n// Print l... | 2013/08/16 | [
"https://wordpress.stackexchange.com/questions/110266",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13549/"
] | I am searching for a way by which i can print the executed sql query just after the :
```
$wpdb->query(
$wpdb->prepare("INSERT
INTO tbl_watchprosite SET
keywords=%s,url_to_post=%s,description=%s,
date_capt... | The `$wpdb` object has some properties getting set for that:
```
global $wpdb;
// Print last SQL query string
echo $wpdb->last_query;
// Print last SQL query result
echo $wpdb->last_result;
// Print last SQL query Error
echo $wpdb->last_error;
```
Note: First of all you have to set `define( 'SAVEQUERIES', true );... |
110,307 | <p>I can't for the life of me get this to work - this is the code in my <strong>single-osu_work.php</strong> file which is used for this post type, but I can't get the next and previous post links to appear - can you see a problem? I've tried putting the pagination links within the loop but still nothing.</p>
<p>Thank... | [
{
"answer_id": 110537,
"author": "Osu",
"author_id": 2685,
"author_profile": "https://wordpress.stackexchange.com/users/2685",
"pm_score": 4,
"selected": true,
"text": "<p>Ok, I found the solution in terms of getting the links to appear, however, I needed to remove the 'true' argument fo... | 2013/08/16 | [
"https://wordpress.stackexchange.com/questions/110307",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2685/"
] | I can't for the life of me get this to work - this is the code in my **single-osu\_work.php** file which is used for this post type, but I can't get the next and previous post links to appear - can you see a problem? I've tried putting the pagination links within the loop but still nothing.
Thanks,
Osu
```
if (have_... | Ok, I found the solution in terms of getting the links to appear, however, I needed to remove the 'true' argument for only moving between posts in the same category/taxonomy.
Is that right that you can't restrict the posts linked to so that they're only the ones within the same taxonomy? Here's the correct code and as... |
110,312 | <p>How can I display an authors archive by author id instead author slug like</p>
<pre><code>http://example.com/author/author_slug/
</code></pre>
<p>to</p>
<pre><code>http://example.com/author/123/
</code></pre>
| [
{
"answer_id": 110537,
"author": "Osu",
"author_id": 2685,
"author_profile": "https://wordpress.stackexchange.com/users/2685",
"pm_score": 4,
"selected": true,
"text": "<p>Ok, I found the solution in terms of getting the links to appear, however, I needed to remove the 'true' argument fo... | 2013/08/16 | [
"https://wordpress.stackexchange.com/questions/110312",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3311/"
] | How can I display an authors archive by author id instead author slug like
```
http://example.com/author/author_slug/
```
to
```
http://example.com/author/123/
``` | Ok, I found the solution in terms of getting the links to appear, however, I needed to remove the 'true' argument for only moving between posts in the same category/taxonomy.
Is that right that you can't restrict the posts linked to so that they're only the ones within the same taxonomy? Here's the correct code and as... |
110,325 | <p>I have a site with 3 different custom post types (Listings, Contacts, Events) and about 1600 'authors'.
What I"m looking to do is only show that author their posts in the backend. So when authorA logs in, and clicks on 'Listings' then they only see their own.</p>
<p>I have this code running in Functions.php to con... | [
{
"answer_id": 110331,
"author": "John",
"author_id": 3301,
"author_profile": "https://wordpress.stackexchange.com/users/3301",
"pm_score": -1,
"selected": false,
"text": "<p>You could create an author.php and then grab the author as well as their posts.</p>\n\n<pre><code><?php\n$cura... | 2013/08/16 | [
"https://wordpress.stackexchange.com/questions/110325",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36436/"
] | I have a site with 3 different custom post types (Listings, Contacts, Events) and about 1600 'authors'.
What I"m looking to do is only show that author their posts in the backend. So when authorA logs in, and clicks on 'Listings' then they only see their own.
I have this code running in Functions.php to control the f... | As @s\_ha\_dum says in his comment, your description and your code seems to be different.
If I understand the description, the code to do what you want is:
```
function __set_all_posts_for_author( $query ) {
if ( is_admin() && is_post_type_archive( array('listings', 'contacts', 'events') ) ) {
$current_user = w... |
110,326 | <p>How can I disable plupload completely from latest wordpress 3.6 and make browser upload default?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 110336,
"author": "John",
"author_id": 3301,
"author_profile": "https://wordpress.stackexchange.com/users/3301",
"pm_score": 0,
"selected": false,
"text": "<p>To disable the Flash uploader add the following filter to functions.php</p>\n\n<pre><code>function disable_flash_u... | 2013/08/16 | [
"https://wordpress.stackexchange.com/questions/110326",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1581/"
] | How can I disable plupload completely from latest wordpress 3.6 and make browser upload default?
Thanks in advance. | This is how the plupload upoader is loaded on Media > Add New
```
do_action( 'pre-plupload-upload-ui' );
// all the html output for plupload's use
do_action( 'post-plupload-upload-ui' );
```
If it was this instead:
```
ob_start();
// all the html output for plupload's use
ob_end_clean();
```
Then no UI, no pl... |
110,327 | <p>I need code to get one category - including its sticky post and a custom featured post box on my front page.
I am using twenty twelve. I have created a child theme. I have wordpress 3.6 on a wordpress.org site.</p>
<p>I selected "your latest posts" under Static Page in the theme customize tab for my front page. I w... | [
{
"answer_id": 110332,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>This may only be part of the problem. That is quite a bit of code to read (and you should post relevant code... | 2013/08/16 | [
"https://wordpress.stackexchange.com/questions/110327",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36706/"
] | I need code to get one category - including its sticky post and a custom featured post box on my front page.
I am using twenty twelve. I have created a child theme. I have wordpress 3.6 on a wordpress.org site.
I selected "your latest posts" under Static Page in the theme customize tab for my front page. I want posts ... | This may only be part of the problem. That is quite a bit of code to read (and you should post relevant code inline so that the question is not dependent on an external site) and your description is a bit hard to follow, but...
You should not be using a secondary query at all (I am pretty sure) and you certainly shoul... |
110,387 | <p>I have a custom type on my wordpress site called 'movie'.</p>
<p>If the user type this URL : <code>http://mysite.com/1994</code>,<br>
I would like to display all movies published in 1994.</p>
<p>Unfortunately, I get a consistent 404 error. When I call <code>get_post_type</code> in index.php(that is the template pa... | [
{
"answer_id": 110391,
"author": "Ryan Bayne",
"author_id": 35010,
"author_profile": "https://wordpress.stackexchange.com/users/35010",
"pm_score": 0,
"selected": false,
"text": "<p>Displaying multiple posts by 1994 makes \"1994\" a term in a taxonomy, much like Categories or Tags are ta... | 2013/08/17 | [
"https://wordpress.stackexchange.com/questions/110387",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12973/"
] | I have a custom type on my wordpress site called 'movie'.
If the user type this URL : `http://mysite.com/1994`,
I would like to display all movies published in 1994.
Unfortunately, I get a consistent 404 error. When I call `get_post_type` in index.php(that is the template page called since I didn't defined 404.php... | Here is the solution of my problem, thanks to @Milo:
```
function wpa_date_archive_post_types( $query ){
if( $query->is_main_query() && $query->is_date() ):
$query->set( 'post_type' , array( 'movie' ) );
$query->set( 'year' , 0 );
$query->set( 'tag' , '1994... |
110,445 | <p>bellow is my code working nice but problem is don't coming with html tag.. like etc... no idea why... </p>
<pre><code> <?php $recent = new WP_Query("page_id=2"); while($recent->have_posts()) : $recent->the_post();?>
<?php
echo substr(get_the_excerpt(), 0,450);
?>
<a hr... | [
{
"answer_id": 110459,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/the_excerpt\" rel=\"nofollow\"><code>(get_)the_excer... | 2013/08/17 | [
"https://wordpress.stackexchange.com/questions/110445",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16755/"
] | bellow is my code working nice but problem is don't coming with html tag.. like etc... no idea why...
```
<?php $recent = new WP_Query("page_id=2"); while($recent->have_posts()) : $recent->the_post();?>
<?php
echo substr(get_the_excerpt(), 0,450);
?>
<a href="<?php the_permalink() ?>" rel="bookm... | Rather than call `WP_Query()` you can use `get_post()` and "set up" the `global $post`. This is probably a little more efficient than @tf's answer, though the ideas are broadly the same.
*Please note, in both cases you should reset the post data afterwards.*
```
/**
* Display the post content. Optionally allows post... |
110,476 | <p>I have a custom post type, called Exercises. I also have many categories within that custom post type. I use archive-exercises.php custom loop to display my main exercises page. </p>
<p>Question: How do I modify my archive-exercises.php so it will display only post from specific category?</p>
<p>I managed to get s... | [
{
"answer_id": 110480,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 0,
"selected": false,
"text": "<p>Just setup a new query restricted to your custom post type and your desired category/categories...</p>\n\n<p... | 2013/08/17 | [
"https://wordpress.stackexchange.com/questions/110476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14948/"
] | I have a custom post type, called Exercises. I also have many categories within that custom post type. I use archive-exercises.php custom loop to display my main exercises page.
Question: How do I modify my archive-exercises.php so it will display only post from specific category?
I managed to get similar effect on ... | Use the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action to modify any main query before it is sent to the database, this includes the case of your home page as well. Calling `query_posts` in the template runs a new query, overwriting the original- it's a waste of resources... |
110,484 | <p>I remember, I had edited some part of my theme for optimizing the title values. Currently in google I see <a href="https://www.google.com/search?hl=en&safe=off&q=site%3Awww.javaexperience.com&btnG=Search#bav=on.2,or.r_cp.r_qf.&ei=X7YPUpb0D4WPrQeu74D4AQ&fp=f0f325d06c6efeb0&hl=en&q=site%3aw... | [
{
"answer_id": 110486,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 0,
"selected": false,
"text": "<p>Ian Stewart's tutorial shows an understandable and SEO-friendly <code><title></code>, you can fo... | 2013/08/17 | [
"https://wordpress.stackexchange.com/questions/110484",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13571/"
] | I remember, I had edited some part of my theme for optimizing the title values. Currently in google I see [this](https://www.google.com/search?hl=en&safe=off&q=site%3Awww.javaexperience.com&btnG=Search#bav=on.2,or.r_cp.r_qf.&ei=X7YPUpb0D4WPrQeu74D4AQ&fp=f0f325d06c6efeb0&hl=en&q=site%3awww.javaexperience.com&sa=N&safe=o... | There is actually nothing you can do about this. Google changed their algorithm a few months ago where they will sometimes determine the title in their results if they feel it's a better fit.
I noticed this when working on the SEO for the last company I worked for. When searching "channel letters detroit" the results ... |
110,501 | <p>Based on code the awesome G.M. provided in an earlier question (<a href="https://wordpress.stackexchange.com/questions/110355/guest-author-how-can-i-use-custom-fields-to-create-guest-author-link">Use Custom Fields to Create Guest Author Link</a>), I now have a custom function that uses custom fields to support guest... | [
{
"answer_id": 110486,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 0,
"selected": false,
"text": "<p>Ian Stewart's tutorial shows an understandable and SEO-friendly <code><title></code>, you can fo... | 2013/08/17 | [
"https://wordpress.stackexchange.com/questions/110501",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36716/"
] | Based on code the awesome G.M. provided in an earlier question ([Use Custom Fields to Create Guest Author Link](https://wordpress.stackexchange.com/questions/110355/guest-author-how-can-i-use-custom-fields-to-create-guest-author-link)), I now have a custom function that uses custom fields to support guest authors. The ... | There is actually nothing you can do about this. Google changed their algorithm a few months ago where they will sometimes determine the title in their results if they feel it's a better fit.
I noticed this when working on the SEO for the last company I worked for. When searching "channel letters detroit" the results ... |
110,508 | <p>I have a custom post type and two custom taxonomies associated with it. One is locations and the other is activities. How can I form the permalinks in the following format?</p>
<p><a href="http://mysite.com/usa/diving" rel="nofollow">http://mysite.com/usa/diving</a></p>
<p>Therefore the first one would be the loca... | [
{
"answer_id": 111410,
"author": "Greg McMullen",
"author_id": 36028,
"author_profile": "https://wordpress.stackexchange.com/users/36028",
"pm_score": 0,
"selected": false,
"text": "<p>It seems as though you actually have multiple options here.</p>\n\n<ul>\n<li><a href=\"http://xplus3.ne... | 2013/08/17 | [
"https://wordpress.stackexchange.com/questions/110508",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | I have a custom post type and two custom taxonomies associated with it. One is locations and the other is activities. How can I form the permalinks in the following format?
<http://mysite.com/usa/diving>
Therefore the first one would be the location taxonomy and second would be the activity taxonomy? | I recently talked about this at a couple of WordCamps. [Here's my talk from WC Portland](http://wordpress.tv/2013/08/24/matt-boynes-rewrite-recipes-exploring-advanced-permalink-structures-by-example/), and [the slides, source code, etc](http://boyn.es/wcpdx/). Check out Recipe #2 specifically.
First off, you should pr... |
110,513 | <p>I have several hosted wordpress blogs, and I've been trying to visit them and they are really slow. I looked at my server logs and I found this</p>
<pre><code>stanfordflipside.com:80 188.138.33.149 - - [17/Aug/2013:17:14:28 -0700] "POST /xmlrpc.php HTTP/1.1" 200 595 "-" "GoogleBot/1.0"
stanfordflipside.com:80 188.1... | [
{
"answer_id": 110552,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p>I would block the IP with <code>iptables</code> if it were me, and if you have that kind of server level acce... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110513",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36758/"
] | I have several hosted wordpress blogs, and I've been trying to visit them and they are really slow. I looked at my server logs and I found this
```
stanfordflipside.com:80 188.138.33.149 - - [17/Aug/2013:17:14:28 -0700] "POST /xmlrpc.php HTTP/1.1" 200 595 "-" "GoogleBot/1.0"
stanfordflipside.com:80 188.138.33.149 - - ... | I would block the IP with `iptables` if it were me, and if you have that kind of server level access.
You could also disable xmlrpc. Unfortunately, since 3.5 the admin screen option to disable that feature has been removed. A single line of code should disable it though: `add_filter( 'xmlrpc_enabled', '__return_false'... |
110,514 | <p>I am writing my first plugin and to access/save options I follow <a href="http://codex.wordpress.org/Creating_Options_Pages" rel="nofollow">codex.wordpress.org/Creating_Options_Pages</a> I basically copied the example from 'See It All Together' in a separate file <code>mhomepage_admin_menu.php</code></p>
<p>The mai... | [
{
"answer_id": 110519,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 2,
"selected": true,
"text": "<blockquote>\n <p>Q1: [H]ow to fix the error?</p>\n</blockquote>\n\n<p>Stop calling the <code>do_settin... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110514",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/238/"
] | I am writing my first plugin and to access/save options I follow [codex.wordpress.org/Creating\_Options\_Pages](http://codex.wordpress.org/Creating_Options_Pages) I basically copied the example from 'See It All Together' in a separate file `mhomepage_admin_menu.php`
The main code of the plugin goes like
```
if ( is_a... | >
> Q1: [H]ow to fix the error?
>
>
>
Stop calling the `do_settings()` function in this line. It is not a WordPress function and it is apparently not a function that you have defined. Perhaps you meant to use one of [these functions](http://codex.wordpress.org/Settings_API#Function_Reference).
```
<?php do_settin... |
110,525 | <p>recently my Wordpress page with Google Maps started displaying markers in an odd fashion- look!</p>
<p><img src="https://i.stack.imgur.com/9N2R7.png" alt="enter image description here"></p>
<p>The problem is- Google changed they code and added this baby into the code: </p>
<pre><code> .gm-style div {
displa... | [
{
"answer_id": 110532,
"author": "Emad Hajjar",
"author_id": 36763,
"author_profile": "https://wordpress.stackexchange.com/users/36763",
"pm_score": -1,
"selected": true,
"text": "<p>find this in file: <code>/wp-content/themes/rentbuy/js/scripts.js</code></p>\n\n<pre><code><div class=... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110525",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36240/"
] | recently my Wordpress page with Google Maps started displaying markers in an odd fashion- look!

The problem is- Google changed they code and added this baby into the code:
```
.gm-style div {
display: block;
}
```
Overriding the code w... | find this in file: `/wp-content/themes/rentbuy/js/scripts.js`
```
<div class="overlay-simple-marker"
```
… and replace it with:
```
<span class="overlay-simple-marker"
``` |
110,531 | <p>I just did upgrade my wordpress subtree of my website to the 3.6 branch and now the site tells me that I need to upgrade my database as well:</p>
<blockquote>
<p>Database Update Required</p>
</blockquote>
<p>Nothing special so far, just business as normal. It suggests me to navigate to</p>
<pre><code>http://exa... | [
{
"answer_id": 110529,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 2,
"selected": false,
"text": "<p>I wonder why not you <a href=\"https://www.google.com/search?q=wordress+disable+cache&ie=utf-8&... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110531",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/178/"
] | I just did upgrade my wordpress subtree of my website to the 3.6 branch and now the site tells me that I need to upgrade my database as well:
>
> Database Update Required
>
>
>
Nothing special so far, just business as normal. It suggests me to navigate to
```
http://example.com/wp-admin/upgrade.php?step=1
```
... | Have you looked at [`WP_Object_Cache`](http://codex.wordpress.org/Class_Reference/WP_Object_Cache)?
If you suspect there is unwanted caching happening in the code that generates the admin panel then you might be able to use functions from the WP\_Object\_Cache to clear it.
>
> WP\_Object\_Cache is WordPress' class f... |
110,542 | <p>I've been learning hot to add theme customizer feature to a theme.
Used few sources for the code and help, but chose the Codex in the end.</p>
<p>I am using a snippet from the codex itself, slightly modified to add more settings.</p>
<p>The only thing I've done was to add few more color options. I am also using th... | [
{
"answer_id": 110628,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>In your function -> get_theme_mod(), skip the option array name and just put the mod name because get_theme_mod()... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110542",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36770/"
] | I've been learning hot to add theme customizer feature to a theme.
Used few sources for the code and help, but chose the Codex in the end.
I am using a snippet from the codex itself, slightly modified to add more settings.
The only thing I've done was to add few more color options. I am also using the Java script to ... | My answer might come a bit late for you, but as I had the same problem today, here's what I found out:
1) First of all, if you set `'type' => 'option'` for your custom settings, you should use the `get_option()` function to retrieve the values. If you set `'type' => 'theme_mod'` (or don't set a type at all as it defau... |
110,562 | <p>I currently developing a wordpress plugin that is using two custom post types. What I want to know here: is it possible to add a custom post type menu as another custom post type's sub menu?</p>
| [
{
"answer_id": 110565,
"author": "epilektric",
"author_id": 36634,
"author_profile": "https://wordpress.stackexchange.com/users/36634",
"pm_score": 7,
"selected": true,
"text": "<p>Yes. When you register your post type you need to set <code>show_in_menu</code> to the page you would like ... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110562",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32989/"
] | I currently developing a wordpress plugin that is using two custom post types. What I want to know here: is it possible to add a custom post type menu as another custom post type's sub menu? | Yes. When you register your post type you need to set `show_in_menu` to the page you would like it displayed on.
Adding a custom post type as a sub-menu of Posts
------------------------------------------------
Here we set the "movies" post type to be included in the sub-menu under Posts.
```
register_post_type( 'mo... |
110,564 | <p>i know how to define custom post template vai plugins very easily but i want without plugins how can i define custom post template for particular category post. </p>
<p>say like i have one category "members" under this category have ten post. so i want when show those member post that time show custom template. </p... | [
{
"answer_id": 110565,
"author": "epilektric",
"author_id": 36634,
"author_profile": "https://wordpress.stackexchange.com/users/36634",
"pm_score": 7,
"selected": true,
"text": "<p>Yes. When you register your post type you need to set <code>show_in_menu</code> to the page you would like ... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110564",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16755/"
] | i know how to define custom post template vai plugins very easily but i want without plugins how can i define custom post template for particular category post.
say like i have one category "members" under this category have ten post. so i want when show those member post that time show custom template.
see bellow ... | Yes. When you register your post type you need to set `show_in_menu` to the page you would like it displayed on.
Adding a custom post type as a sub-menu of Posts
------------------------------------------------
Here we set the "movies" post type to be included in the sub-menu under Posts.
```
register_post_type( 'mo... |
110,577 | <p>We know that in WordPress the default post template file is <code>single.php</code>. Now, I have one category name "members" and want <em>members</em> posts to show a custom template, like <code>content-members.php</code>.</p>
<p>I can do that via custom post template plugins. but is there a way to make that withou... | [
{
"answer_id": 110578,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 3,
"selected": true,
"text": "<p>I believe you might need to use <a href=\"http://codex.wordpress.org/Function_Reference/in_category\" rel=\"nofollo... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110577",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16755/"
] | We know that in WordPress the default post template file is `single.php`. Now, I have one category name "members" and want *members* posts to show a custom template, like `content-members.php`.
I can do that via custom post template plugins. but is there a way to make that without plugins?
Maybe we can do that like t... | I believe you might need to use [in\_category()](http://codex.wordpress.org/Function_Reference/in_category) instead of [is\_category()](http://codex.wordpress.org/Function_Reference/is_category).
in\_category() checks if the current post is in a category, is\_category() checks if it's a category archive page. |
110,580 | <p>I'm using <code>query_posts</code> to build a list of posts from a single category, and I'm trying to add pagination to this setup. Here's my code:</p>
<pre><code><ul>
<h1><?php the_title(); ?></h1>
<?php
$paged = get_query_var( 'paged' );
$args = array( 'posts_per_pag... | [
{
"answer_id": 110581,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>You should use the following expression to compute paged parameter for the query.</p>\n\n<pre><code>$page... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23236/"
] | I'm using `query_posts` to build a list of posts from a single category, and I'm trying to add pagination to this setup. Here's my code:
```
<ul>
<h1><?php the_title(); ?></h1>
<?php
$paged = get_query_var( 'paged' );
$args = array( 'posts_per_page' => 5, 'category' => 6, 'order' => 'DESC', 'paged'... | Try this:
```
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 5,
'category' => 6,
'order' => 'DESC',
'paged' => $paged,
);
```
Currently, you are setting The `paged` argument to `1`. |
110,587 | <p>I am trying to use a checkbox on Custom Option page by using Setting API. Every thing works fine at back-end and I can update the checkbox states by registering the settings.But when I would like to see the result on the page I am getting same result <strong>" The checkbox has not been checked."</strong> even so the... | [
{
"answer_id": 110581,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>You should use the following expression to compute paged parameter for the query.</p>\n\n<pre><code>$page... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35444/"
] | I am trying to use a checkbox on Custom Option page by using Setting API. Every thing works fine at back-end and I can update the checkbox states by registering the settings.But when I would like to see the result on the page I am getting same result **" The checkbox has not been checked."** even so the checkboxed has ... | Try this:
```
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 5,
'category' => 6,
'order' => 'DESC',
'paged' => $paged,
);
```
Currently, you are setting The `paged` argument to `1`. |
110,589 | <p>Using the code below, I have been able to make a list of custom field values (on a seperate page template) from across all the posts for a specific custom meta key "realname". The code gives me a nice alphabetically ordered list of all the custom values.</p>
<pre><code><?php
function get_meta_values( $key = '', ... | [
{
"answer_id": 110592,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 0,
"selected": false,
"text": "<p>I think you could do something like this within your foreach loop:</p>\n\n<pre><code><?php echo get_permalink($... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110589",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25508/"
] | Using the code below, I have been able to make a list of custom field values (on a seperate page template) from across all the posts for a specific custom meta key "realname". The code gives me a nice alphabetically ordered list of all the custom values.
```
<?php
function get_meta_values( $key = '', $type = 'post', $... | You achieve this by modifying your code as following and using [get\_results](http://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results) function instead of get\_col function.
```
<?php
function get_meta_values( $key = '', $type = 'post', $status = 'publish' ) {
global $wpdb;
if( empty( $key ) )
retur... |
110,591 | <p>Using the relationship field from Advanced Custom Fields I link artists to events. Both these artist and events are custom post types. For each event, the post IDs of the related artists are stored in an array as a custom meta field (lineup_artists).</p>
<p>On each event page I list all the artists. When you click ... | [
{
"answer_id": 110592,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 0,
"selected": false,
"text": "<p>I think you could do something like this within your foreach loop:</p>\n\n<pre><code><?php echo get_permalink($... | 2013/08/18 | [
"https://wordpress.stackexchange.com/questions/110591",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36783/"
] | Using the relationship field from Advanced Custom Fields I link artists to events. Both these artist and events are custom post types. For each event, the post IDs of the related artists are stored in an array as a custom meta field (lineup\_artists).
On each event page I list all the artists. When you click on an art... | You achieve this by modifying your code as following and using [get\_results](http://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results) function instead of get\_col function.
```
<?php
function get_meta_values( $key = '', $type = 'post', $status = 'publish' ) {
global $wpdb;
if( empty( $key ) )
retur... |
110,613 | <p>I just got this code from a tutorial. I can't seem to get it to work.</p>
<p>HTML (home.php)</p>
<pre><code> <form name="myform" id="myform" action="" method="POST">
<!-- The Name form field -->
<label for="name" id="name_label">Name</label>
<input type="text" na... | [
{
"answer_id": 110614,
"author": "jepser",
"author_id": 6519,
"author_profile": "https://wordpress.stackexchange.com/users/6519",
"pm_score": 0,
"selected": false,
"text": "<p>First of all, sanitize all your data.</p>\n\n<p>Second, I will rather do this:</p>\n\n<pre><code>jQuery(function... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36675/"
] | I just got this code from a tutorial. I can't seem to get it to work.
HTML (home.php)
```
<form name="myform" id="myform" action="" method="POST">
<!-- The Name form field -->
<label for="name" id="name_label">Name</label>
<input type="text" name="name" id="name" size="30" value=""/>
... | This was very frustrating to figure out. I spent hours on this issue and discovered your problem is in this input:
```
<input type="text" name="name" id="name" size="30" value=""/>
```
Try changing the input field name to anything but "name", for example:
```
<input type="text" name="user_name" id="name" size="30"... |
110,619 | <p>I'm really new to WordPress and having a problem with my page template and a sidebar loop. I made a block that displays posts in a category in the sidebar, it also displays a custom field below the title of each post and the code looks like this:</p>
<pre><code><?php $published = get_post_meta( $post->ID, 'ar... | [
{
"answer_id": 110614,
"author": "jepser",
"author_id": 6519,
"author_profile": "https://wordpress.stackexchange.com/users/6519",
"pm_score": 0,
"selected": false,
"text": "<p>First of all, sanitize all your data.</p>\n\n<p>Second, I will rather do this:</p>\n\n<pre><code>jQuery(function... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110619",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36791/"
] | I'm really new to WordPress and having a problem with my page template and a sidebar loop. I made a block that displays posts in a category in the sidebar, it also displays a custom field below the title of each post and the code looks like this:
```
<?php $published = get_post_meta( $post->ID, 'article_Details', true... | This was very frustrating to figure out. I spent hours on this issue and discovered your problem is in this input:
```
<input type="text" name="name" id="name" size="30" value=""/>
```
Try changing the input field name to anything but "name", for example:
```
<input type="text" name="user_name" id="name" size="30"... |
110,625 | <p>I am using a custom field to embed any supported video on Wordpress
so for example the user enters a video address on the custom field box : </p>
<pre><code>http://vimeo.com/72104173
</code></pre>
<p>and I implemented the following code on my theme : </p>
<pre><code><?php
$videourl = my_meta('video'); // get c... | [
{
"answer_id": 110629,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>You can add query args to the end of the URL like so:</p>\n\n<pre><code>$videourl = add_query_arg( array('key1' =... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110625",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20460/"
] | I am using a custom field to embed any supported video on Wordpress
so for example the user enters a video address on the custom field box :
```
http://vimeo.com/72104173
```
and I implemented the following code on my theme :
```
<?php
$videourl = my_meta('video'); // get custom field value
if($videourl!=''){ // ... | You can add query args to the end of the URL like so:
```
$videourl = add_query_arg( array('key1' => 'value1' ), $videourl ); // you can add as many as you want in key/value pairs...
$htmlcode = wp_oembed_get( $videourl );
// rest of your code...
``` |
110,627 | <p>So I am running the following to update user meta on regsitration:</p>
<pre><code>function set_user_rcp_default_subscriber($user_id) {
update_user_meta( $user_id, 'wp_user_level', '0' );
update_user_meta( $user_id, 'rcp_subscription_level', '1' );
update_user_meta( $user_id, 'rcp_status', 'active' );
... | [
{
"answer_id": 110629,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>You can add query args to the end of the URL like so:</p>\n\n<pre><code>$videourl = add_query_arg( array('key1' =... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110627",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33324/"
] | So I am running the following to update user meta on regsitration:
```
function set_user_rcp_default_subscriber($user_id) {
update_user_meta( $user_id, 'wp_user_level', '0' );
update_user_meta( $user_id, 'rcp_subscription_level', '1' );
update_user_meta( $user_id, 'rcp_status', 'active' );
update_user_... | You can add query args to the end of the URL like so:
```
$videourl = add_query_arg( array('key1' => 'value1' ), $videourl ); // you can add as many as you want in key/value pairs...
$htmlcode = wp_oembed_get( $videourl );
// rest of your code...
``` |
110,649 | <p>I am trying to find how all posts of a specific author will appear without the author box, while all the others authors posts will have their author boxes.</p>
<p>Can somebody help me with this?</p>
| [
{
"answer_id": 110629,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>You can add query args to the end of the URL like so:</p>\n\n<pre><code>$videourl = add_query_arg( array('key1' =... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36802/"
] | I am trying to find how all posts of a specific author will appear without the author box, while all the others authors posts will have their author boxes.
Can somebody help me with this? | You can add query args to the end of the URL like so:
```
$videourl = add_query_arg( array('key1' => 'value1' ), $videourl ); // you can add as many as you want in key/value pairs...
$htmlcode = wp_oembed_get( $videourl );
// rest of your code...
``` |
110,668 | <p>I want to add two custom field to table wp_posts, and that I need for my plugin. now to enable these fields I have changed core file of wordpress</p>
<pre><code>wordpress/wp-admin/post.php
$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'po... | [
{
"answer_id": 145595,
"author": "Edd Aslin",
"author_id": 51738,
"author_profile": "https://wordpress.stackexchange.com/users/51738",
"pm_score": 1,
"selected": false,
"text": "<p>You should not be editing core files, it makes it very difficult to upgrade.</p>\n\n<p>Use the <a href=\"ht... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36808/"
] | I want to add two custom field to table wp\_posts, and that I need for my plugin. now to enable these fields I have changed core file of wordpress
```
wordpress/wp-admin/post.php
$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', ... | You should not be editing core files, it makes it very difficult to upgrade.
Use the [`add_meta_box()`](http://codex.wordpress.org/Function_Reference/add_meta_box) function and put it in a plugin file.
See example below, this plugin will add a meta box to all pages in your wordpress installation. Just edit it for you... |
110,669 | <p>The below code works like a charm, but it's a static href!</p>
<pre><code><li class="fb-like fb" data-href="http://developers.facebook.com/docs/reference/plugins/like" data-layout="button_count" data-show-faces="true" data-send="false"></li>
</code></pre>
<p>When I change the href to the_permalink, the... | [
{
"answer_id": 145595,
"author": "Edd Aslin",
"author_id": 51738,
"author_profile": "https://wordpress.stackexchange.com/users/51738",
"pm_score": 1,
"selected": false,
"text": "<p>You should not be editing core files, it makes it very difficult to upgrade.</p>\n\n<p>Use the <a href=\"ht... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110669",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24483/"
] | The below code works like a charm, but it's a static href!
```
<li class="fb-like fb" data-href="http://developers.facebook.com/docs/reference/plugins/like" data-layout="button_count" data-show-faces="true" data-send="false"></li>
```
When I change the href to the\_permalink, the button disappears!
```
<li class="f... | You should not be editing core files, it makes it very difficult to upgrade.
Use the [`add_meta_box()`](http://codex.wordpress.org/Function_Reference/add_meta_box) function and put it in a plugin file.
See example below, this plugin will add a meta box to all pages in your wordpress installation. Just edit it for you... |
110,672 | <p>I'm developing a Wordpress Woocommerce plugin. On my local environment it works fine but I have problems when adding the plugin to a replica of the prod environment. I am new to wordpress and not very familiar with web dev (I'm a Java programmer).</p>
<p>In the plugin file, I instantiate a class from the Woocommerc... | [
{
"answer_id": 110676,
"author": "JMau",
"author_id": 31376,
"author_profile": "https://wordpress.stackexchange.com/users/31376",
"pm_score": 2,
"selected": false,
"text": "<p>The proper way would be : </p>\n\n<pre><code> if( class_exists('WC_Coupon') ) $coupon = new WC_Coupon($some_code... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110672",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35454/"
] | I'm developing a Wordpress Woocommerce plugin. On my local environment it works fine but I have problems when adding the plugin to a replica of the prod environment. I am new to wordpress and not very familiar with web dev (I'm a Java programmer).
In the plugin file, I instantiate a class from the Woocommerce plugin p... | You have to check if the class exists, but before that you have to *wait* that all plugin are loaded: no one can assure that your plugin is loaded after WooCommerce.
For run a code from plugin when all plugin are loaded hook into `plugins_loaded` hook.
Be aware that you cannot use this hook in a theme, because when t... |
110,675 | <p>Excuse me, I'm very new to PHP and WordPress, but I'm trying to link to an exterenal js file called <strong>trans.js</strong>, that relies on jQuery. Here is the code at the beginning of the header.php:</p>
<pre><code> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/trans.js">... | [
{
"answer_id": 110679,
"author": "Srikanth AD",
"author_id": 7281,
"author_profile": "https://wordpress.stackexchange.com/users/7281",
"pm_score": 0,
"selected": false,
"text": "<p>If you place the below code snippet in your functions.php then, trans.js file should be available in the so... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33541/"
] | Excuse me, I'm very new to PHP and WordPress, but I'm trying to link to an exterenal js file called **trans.js**, that relies on jQuery. Here is the code at the beginning of the header.php:
```
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/trans.js"></script>
```
and here is the enqueue... | You could use only one function to do all because it's the same hook `wp_enqueue_scripts`:
```
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
function my_scripts_method() {
//global $wp_styles; //here no use unless you have to use it in a conditional stylesheet for example
wp_enqueue_style( 'twentytwel... |
110,677 | <p>I'm trying to retrieve information on my database. I wanted to display all <code>pages</code> using this statement, but I'm getting a blank <code>ARRAY</code> </p>
<pre><code>global $wpdb;
$result = $wpdb->get_results (
"
SELECT *
FROM $wpdb->wp_posts
WHERE post_type = 'pag... | [
{
"answer_id": 110681,
"author": "Srikanth AD",
"author_id": 7281,
"author_profile": "https://wordpress.stackexchange.com/users/7281",
"pm_score": 0,
"selected": false,
"text": "<p>By \"blank Array\" do you mean an 'empty array' or is the output 'ARRAY'. If it's the latter then, it is th... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25549/"
] | I'm trying to retrieve information on my database. I wanted to display all `pages` using this statement, but I'm getting a blank `ARRAY`
```
global $wpdb;
$result = $wpdb->get_results (
"
SELECT *
FROM $wpdb->wp_posts
WHERE post_type = 'page'
"
);
echo $result; // ... | ```
global $wpdb;
$result = $wpdb->get_results ( "
SELECT *
FROM $wpdb->posts
WHERE post_type = 'page'
" );
foreach ( $result as $page )
{
echo $page->ID.'<br/>';
echo $page->post_title.'<br/>';
}
``` |
110,739 | <p>below is a query where it supposed to get a contents from a page by a specified page title</p>
<pre><code><?php
$page = get_page_by_title( 'About Us' );
$content = apply_filters('the_content', $page->post_content);
the_content_rss('', TRUE, '', 100);
?>
<a href="<?php the_permalink... | [
{
"answer_id": 110720,
"author": "epilektric",
"author_id": 36634,
"author_profile": "https://wordpress.stackexchange.com/users/36634",
"pm_score": 2,
"selected": false,
"text": "<p>If you manually provide an excerpt for the post WordPress will use the one you provided instead of automat... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36811/"
] | below is a query where it supposed to get a contents from a page by a specified page title
```
<?php
$page = get_page_by_title( 'About Us' );
$content = apply_filters('the_content', $page->post_content);
the_content_rss('', TRUE, '', 100);
?>
<a href="<?php the_permalink() ?>" title="Read the whole ... | If you manually provide an excerpt for the post WordPress will use the one you provided instead of automatically generating one. Any HTML links you include in your manual excerpt will still be displayed correctly. Or you can leave the links out and just include the text you want.
To preserve HTML links in the automati... |
110,752 | <p>I was able to get all the items of a custom taxonomy for a post, like this:</p>
<pre><code>$args=array('orderby'=>'parent',"fields" => "all");
$term_list = wp_get_post_terms($post->ID, 'tvr_amenity', $args);
</code></pre>
<p>My problem is that i would like to show the tree (respecting the parents)</p>
<p... | [
{
"answer_id": 110757,
"author": "Angelique",
"author_id": 32037,
"author_profile": "https://wordpress.stackexchange.com/users/32037",
"pm_score": 3,
"selected": true,
"text": "<p>What about:</p>\n\n<pre><code>$taxName = \"tvr_amenity\";\n$terms = get_terms($taxName,array('parent' => ... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110752",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3435/"
] | I was able to get all the items of a custom taxonomy for a post, like this:
```
$args=array('orderby'=>'parent',"fields" => "all");
$term_list = wp_get_post_terms($post->ID, 'tvr_amenity', $args);
```
My problem is that i would like to show the tree (respecting the parents)
So i would like to get them ordered by na... | What about:
```
$taxName = "tvr_amenity";
$terms = get_terms($taxName,array('parent' => 0));
foreach($terms as $term) {
echo '<a href="'.get_term_link($term->slug,$taxName).'">'.$term->name.'</a>';
$term_children = get_term_children($term->term_id,$taxName);
echo '<ul>';
foreach($term_children as $term_chi... |
110,776 | <p>Is it somehow possible to <code>get_post_meta</code> or <code>get_post_custom</code> and have meta_id returned along with the <code>meta_value</code>? For example:</p>
<pre><code>$data = get_post_meta( $post_id, 'my_key' );
// returns this:
array( 0 => array('myvalue1', 1002 ), 1 => array( 'myvalue2', 1003 ))... | [
{
"answer_id": 110777,
"author": "Anjum",
"author_id": 3311,
"author_profile": "https://wordpress.stackexchange.com/users/3311",
"pm_score": 2,
"selected": false,
"text": "<p>add this code in your functions.php</p>\n\n<pre><code>function get_mid_by_key( $post_id, $meta_key ) {\n globa... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110776",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12495/"
] | Is it somehow possible to `get_post_meta` or `get_post_custom` and have meta\_id returned along with the `meta_value`? For example:
```
$data = get_post_meta( $post_id, 'my_key' );
// returns this:
array( 0 => array('myvalue1', 1002 ), 1 => array( 'myvalue2', 1003 ));
```
The basic idea is that because there may be ... | This function worked for me:
```
function get_complete_meta( $post_id, $meta_key ) {
global $wpdb;
$mid = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, $meta_key) );
if( $mid != '' )
return $mid;
return false;
}
```
it will return an a... |
110,782 | <p>I want to remove or hide Categories / Tags submenu under Posts in the Admin Menu. I know this works with the themes submenus: </p>
<p><code>remove_submenu_page( 'themes.php', 'widgets.php' );</code></p>
<p>The same doesn't seem to work for posts unfortunately:</p>
<p><code>remove_submenu_page( 'edit.php', 'edit-t... | [
{
"answer_id": 110784,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 5,
"selected": true,
"text": "<pre><code>add_action('admin_menu', 'my_remove_sub_menus');\n\nfunction my_remove_sub_menus() {\n remove_subme... | 2013/08/19 | [
"https://wordpress.stackexchange.com/questions/110782",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | I want to remove or hide Categories / Tags submenu under Posts in the Admin Menu. I know this works with the themes submenus:
`remove_submenu_page( 'themes.php', 'widgets.php' );`
The same doesn't seem to work for posts unfortunately:
`remove_submenu_page( 'edit.php', 'edit-tags.php' );`
I'm using the admin\_menu ... | ```
add_action('admin_menu', 'my_remove_sub_menus');
function my_remove_sub_menus() {
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=category');
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=post_tag');
}
``` |
110,813 | <p>I want to get post type of currently visited category or term. As for example, I have post_type <strong>post</strong> and category named <strong>Blog</strong>.</p>
<p>On Blog listing page, how can I get that this is a category of the <code>post_type</code> <strong>Post</strong>?</p>
| [
{
"answer_id": 110784,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 5,
"selected": true,
"text": "<pre><code>add_action('admin_menu', 'my_remove_sub_menus');\n\nfunction my_remove_sub_menus() {\n remove_subme... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110813",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33338/"
] | I want to get post type of currently visited category or term. As for example, I have post\_type **post** and category named **Blog**.
On Blog listing page, how can I get that this is a category of the `post_type` **Post**? | ```
add_action('admin_menu', 'my_remove_sub_menus');
function my_remove_sub_menus() {
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=category');
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=post_tag');
}
``` |
110,827 | <p>I have the following code on index.php and I want to include this line of code (bellow) to display author info on top of the loop.</p>
<pre><code> <?php include 'author-top.php'; ?><!--author-->
</code></pre>
<p>I want it to display right after the header as shows here</p>
<pre><code><?php get_head... | [
{
"answer_id": 111021,
"author": "Raul",
"author_id": 36854,
"author_profile": "https://wordpress.stackexchange.com/users/36854",
"pm_score": 3,
"selected": false,
"text": "<p>I will answer my own question here.</p>\n\n<p>The reason the user information didn't display is because the php ... | 2013/08/20 | [
"https://wordpress.stackexchange.com/questions/110827",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36854/"
] | I have the following code on index.php and I want to include this line of code (bellow) to display author info on top of the loop.
```
<?php include 'author-top.php'; ?><!--author-->
```
I want it to display right after the header as shows here
```
<?php get_header(); ?>
<!--This is where I want my author div to d... | I will answer my own question here.
The reason the user information didn't display is because the php tags need the author ID when used outside the loop.
For instance the following tag:
```
<?php the_author(); ?>
```
Should be like this:
```
<?php the_author_meta('display_name', 1); ?>
```
[This](http://codex.... |