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 |
|---|---|---|---|---|---|---|
179,337 | <p>I'm developing a plugin that adds a new tab to the media modal, and I need to know a way trigger a refresh of the attachments tab so it shows newly added attachments. This is the code I'm using:</p>
<pre><code>wp.media.view.Toolbar.Custom = wp.media.view.Toolbar.extend({
initialize: function() {
_.defau... | [
{
"answer_id": 340494,
"author": "tru.d",
"author_id": 167464,
"author_profile": "https://wordpress.stackexchange.com/users/167464",
"pm_score": 1,
"selected": false,
"text": "<p>Try out:</p>\n\n<pre><code>wp.media.editor.get(wpActiveEditor).views._views[\".media-frame-content\"][0].view... | 2015/02/25 | [
"https://wordpress.stackexchange.com/questions/179337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33049/"
] | I'm developing a plugin that adds a new tab to the media modal, and I need to know a way trigger a refresh of the attachments tab so it shows newly added attachments. This is the code I'm using:
```
wp.media.view.Toolbar.Custom = wp.media.view.Toolbar.extend({
initialize: function() {
_.defaults( this.opti... | You can checkout this link <https://codex.wordpress.org/Javascript_Reference/wp.media>
```
jQuery(function($){
// Set all variables to be used in scope
var frame,
metaBox = $('#meta-box-id.postbox'), // Your meta box id here
addImgLink = metaBox.find('.upload-custom-img'),
delImgLink = metaBox.f... |
179,339 | <p>So here is my code to display the post created date:</p>
<pre><code> $date_create = '<div class="mydate-created">';
$date_create .= get_the_date('',$product->id);
$date_create .='</div>';
$output .= '</div>';
$output .= '<div class="mydate-created">';
$output .= get... | [
{
"answer_id": 179343,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 3,
"selected": true,
"text": "<p>Here you go. This goes in <code>functions.php</code></p>\n\n<p>This changes the time on your website everyw... | 2015/02/25 | [
"https://wordpress.stackexchange.com/questions/179339",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67604/"
] | So here is my code to display the post created date:
```
$date_create = '<div class="mydate-created">';
$date_create .= get_the_date('',$product->id);
$date_create .='</div>';
$output .= '</div>';
$output .= '<div class="mydate-created">';
$output .= get_the_date('',$product->id);
$output .... | Here you go. This goes in `functions.php`
This changes the time on your website everywhere. Now you can keep using `<?php echo get_the_date(); ?>` in your loop or theme files.
```
// Relative date & time
function wpse_relative_date() {
return human_time_diff( get_the_time('U'), current_time( 'timestamp' ) ) . ' ago... |
179,370 | <p>How can I have a post (or custom post) with a definite URL:</p>
<pre><code>www.test.com/category/post-name
</code></pre>
<p>and a child-URL referring to a specific section of that post</p>
<pre><code>www.test.com/category/post-name/sub-url
</code></pre>
<p>without being obliged to create a specific post related ... | [
{
"answer_id": 179381,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>I'd say what you need to look deeper into is the <em>Rewrite API</em> and <em>Endpoints</em>, for s... | 2015/02/25 | [
"https://wordpress.stackexchange.com/questions/179370",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65042/"
] | How can I have a post (or custom post) with a definite URL:
```
www.test.com/category/post-name
```
and a child-URL referring to a specific section of that post
```
www.test.com/category/post-name/sub-url
```
without being obliged to create a specific post related to that child-URL?
I have a post with the URL
... | I just completed something like this (with great help from folks on this site).
First, you need to add the rewrite endpoint to your functions:
```
function wpa_read_endpoint(){
add_rewrite_endpoint( 'sub-url', EP_PERMALINK);
}
add_action( 'init', 'wpa_read_endpoint' );
```
Make sure to then go to the permalink... |
179,393 | <p>I'm running a 4.1.1 Wordpress without plugins and while trying to upload an image (2mb in this exemplary case) I get:</p>
<pre><code> 'http error'
</code></pre>
<p>when I retry it returns </p>
<blockquote>
<p>has failed to upload due to an error
File is empty. Please upload something more substantial. This... | [
{
"answer_id": 179381,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>I'd say what you need to look deeper into is the <em>Rewrite API</em> and <em>Endpoints</em>, for s... | 2015/02/25 | [
"https://wordpress.stackexchange.com/questions/179393",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68169/"
] | I'm running a 4.1.1 Wordpress without plugins and while trying to upload an image (2mb in this exemplary case) I get:
```
'http error'
```
when I retry it returns
>
> has failed to upload due to an error
> File is empty. Please upload something more substantial. This error could
> also be caused by uploads... | I just completed something like this (with great help from folks on this site).
First, you need to add the rewrite endpoint to your functions:
```
function wpa_read_endpoint(){
add_rewrite_endpoint( 'sub-url', EP_PERMALINK);
}
add_action( 'init', 'wpa_read_endpoint' );
```
Make sure to then go to the permalink... |
179,400 | <p>I write code to save data in to the database table.</p>
<p>I want Replace a row in a table if it exists or insert a new row in a table if the row did not already exist.</p>
<p><a href="http://codex.wordpress.org/Class_Reference/wpdb" rel="nofollow">http://codex.wordpress.org/Class_Reference/wpdb</a></p>
<p>I use ... | [
{
"answer_id": 179443,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": false,
"text": "<p><code>replace</code> will only replace a row if one of the column values you supply is a <code>primary key</code> ... | 2015/02/25 | [
"https://wordpress.stackexchange.com/questions/179400",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48589/"
] | I write code to save data in to the database table.
I want Replace a row in a table if it exists or insert a new row in a table if the row did not already exist.
<http://codex.wordpress.org/Class_Reference/wpdb>
I use `$wpdb->replace` function and then add `$wpdb->insert`\_id to end of code.
For Update all fields ,... | You Can use This solution..
[How to delete all records from or empty a custom database table?](https://wordpress.stackexchange.com/questions/125380/how-to-delete-all-records-from-or-empty-a-custom-database-table)
In this solution First delete all records an then insert new records
(your table should be have records ... |
179,448 | <p>This one has been bothering me for a few days now, so I'd really appreciate any help you can give me.</p>
<p><strong>Problem overview:</strong></p>
<p>I have a plugin which automatically creates a post and assigns the category "YouTube" whenever a new video is uploaded to a YouTube channel. This part works fine.
H... | [
{
"answer_id": 179443,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": false,
"text": "<p><code>replace</code> will only replace a row if one of the column values you supply is a <code>primary key</code> ... | 2015/02/26 | [
"https://wordpress.stackexchange.com/questions/179448",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51266/"
] | This one has been bothering me for a few days now, so I'd really appreciate any help you can give me.
**Problem overview:**
I have a plugin which automatically creates a post and assigns the category "YouTube" whenever a new video is uploaded to a YouTube channel. This part works fine.
However - I'm also wanting the ... | You Can use This solution..
[How to delete all records from or empty a custom database table?](https://wordpress.stackexchange.com/questions/125380/how-to-delete-all-records-from-or-empty-a-custom-database-table)
In this solution First delete all records an then insert new records
(your table should be have records ... |
179,484 | <p>I'm trying to display all the categories that belong to the custom post type that the user is in.</p>
<p>For example this post: <a href="http://bit.ly/1ANisxN" rel="nofollow noreferrer">http://bit.ly/1ANisxN</a>
Is a custom post type that belongs to this page category: <a href="http://bit.ly/1FYscKh" rel="nofollow ... | [
{
"answer_id": 179494,
"author": "Przemek Maczewski",
"author_id": 68013,
"author_profile": "https://wordpress.stackexchange.com/users/68013",
"pm_score": 2,
"selected": true,
"text": "<p>If you're in the single custom post template, you can get the terms that the post belongs to by use ... | 2015/02/26 | [
"https://wordpress.stackexchange.com/questions/179484",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68230/"
] | I'm trying to display all the categories that belong to the custom post type that the user is in.
For example this post: <http://bit.ly/1ANisxN>
Is a custom post type that belongs to this page category: <http://bit.ly/1FYscKh>
As you can see the page category shows it's child categories which is exactly what I want t... | If you're in the single custom post template, you can get the terms that the post belongs to by use of
```
$terms = get_the_terms( get_the_ID(), 'btp_work_category' );
```
Then you need to determine parent term and display it with its children.
The code below assumes that the post belongs to one top category (term)... |
179,527 | <p>Firstly this is neither an SEO question nor a question about changing the title tag sitewide. If you google my question those are all the answers you see.</p>
<p>So we have our own theme and we have complete control over header.php. We know how to set the title. Currently it looks like this:</p>
<pre><code><hea... | [
{
"answer_id": 179532,
"author": "Przemek Maczewski",
"author_id": 68013,
"author_profile": "https://wordpress.stackexchange.com/users/68013",
"pm_score": 2,
"selected": false,
"text": "<p>You may want to filter out the title.</p>\n\n<pre><code>add_filter( 'wp_title', 'wpse179527_wp_titl... | 2015/02/26 | [
"https://wordpress.stackexchange.com/questions/179527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/875/"
] | Firstly this is neither an SEO question nor a question about changing the title tag sitewide. If you google my question those are all the answers you see.
So we have our own theme and we have complete control over header.php. We know how to set the title. Currently it looks like this:
```
<head>
<title><?php wp_t... | First, let's change your `<title>` to
```
<title><?php wp_title(' | ', true, 'right'); ?></title>
```
Because adding to the title string in that was isn't very future-forward, instead it's best to use a filter to do any modifications to the title. So let's instead ad (in functions.php):
```
add_filter('wp_title', '... |
179,548 | <p>I am trying to list my news items in 3 columns in a vertical design: image, date, title. I'm having some trouble calling the featured image. Is there a specific function that would help me with this? Also add CSS style to list them in 3 columns? </p>
<p>Website Example: <a href="http://www.enterpriseflorida.com/why... | [
{
"answer_id": 179532,
"author": "Przemek Maczewski",
"author_id": 68013,
"author_profile": "https://wordpress.stackexchange.com/users/68013",
"pm_score": 2,
"selected": false,
"text": "<p>You may want to filter out the title.</p>\n\n<pre><code>add_filter( 'wp_title', 'wpse179527_wp_titl... | 2015/02/26 | [
"https://wordpress.stackexchange.com/questions/179548",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68271/"
] | I am trying to list my news items in 3 columns in a vertical design: image, date, title. I'm having some trouble calling the featured image. Is there a specific function that would help me with this? Also add CSS style to list them in 3 columns?
Website Example: <http://www.enterpriseflorida.com/why-florida/infrastru... | First, let's change your `<title>` to
```
<title><?php wp_title(' | ', true, 'right'); ?></title>
```
Because adding to the title string in that was isn't very future-forward, instead it's best to use a filter to do any modifications to the title. So let's instead ad (in functions.php):
```
add_filter('wp_title', '... |
179,559 | <p>I have a local Xampp wordpress installation that I am using as sort of an intranet with some people I work with.
I require them to be able to access it on our LAN router -- I found that I needed to change the site url and links from <a href="http://localhost:8080" rel="noreferrer">http://localhost:8080</a> to my IP ... | [
{
"answer_id": 179790,
"author": "Taberkinslaw",
"author_id": 22990,
"author_profile": "https://wordpress.stackexchange.com/users/22990",
"pm_score": 4,
"selected": true,
"text": "<p>If anyone out there has a similar situation as me, I found a solution by adding:</p>\n\n<pre><code>/* Tha... | 2015/02/27 | [
"https://wordpress.stackexchange.com/questions/179559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22990/"
] | I have a local Xampp wordpress installation that I am using as sort of an intranet with some people I work with.
I require them to be able to access it on our LAN router -- I found that I needed to change the site url and links from <http://localhost:8080> to my IP <http://192.168.x.xx:8080> for images and css to show.... | If anyone out there has a similar situation as me, I found a solution by adding:
```
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/* THIS IS CUSTOM CODE CREATED AT ZEROFRACTAL TO MAKE SITE ACCESS ... |
179,585 | <p>I have the following code in my theme's archive.php:</p>
<pre><code><?php the_archive_title( '<h1 class="page-title">', '</h1>' ); ?>
</code></pre>
<p>This gives me titles like "Category: Russia", "Tag: America", "Author: John".</p>
<p>I would like to remove the "Category:", "Tag:" and "Author:"... | [
{
"answer_id": 179590,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 8,
"selected": true,
"text": "<p>You can extend the <a href=\"https://developer.wordpress.org/reference/functions/get_the_archive_title/\... | 2015/02/27 | [
"https://wordpress.stackexchange.com/questions/179585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68284/"
] | I have the following code in my theme's archive.php:
```
<?php the_archive_title( '<h1 class="page-title">', '</h1>' ); ?>
```
This gives me titles like "Category: Russia", "Tag: America", "Author: John".
I would like to remove the "Category:", "Tag:" and "Author:" part and just display the category, tag and author... | You can extend the [`get_the_archive_title` filter](https://developer.wordpress.org/reference/functions/get_the_archive_title/) which I've mentioned in [this answer](https://wordpress.stackexchange.com/a/175903/31545)
```php
add_filter('get_the_archive_title', function ($title) {
if (is_category()) {
$titl... |
179,614 | <p>I want to add a text in admin login page, i searched a lot about this but can't find any thing else a plugin (its my last option).</p>
<p>I also use this filter:</p>
<pre><code>function my_login_logo_url_title() {
return 'Your Site Name and Info';
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );... | [
{
"answer_id": 179590,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 8,
"selected": true,
"text": "<p>You can extend the <a href=\"https://developer.wordpress.org/reference/functions/get_the_archive_title/\... | 2015/02/27 | [
"https://wordpress.stackexchange.com/questions/179614",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64316/"
] | I want to add a text in admin login page, i searched a lot about this but can't find any thing else a plugin (its my last option).
I also use this filter:
```
function my_login_logo_url_title() {
return 'Your Site Name and Info';
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );
```
But nothing ha... | You can extend the [`get_the_archive_title` filter](https://developer.wordpress.org/reference/functions/get_the_archive_title/) which I've mentioned in [this answer](https://wordpress.stackexchange.com/a/175903/31545)
```php
add_filter('get_the_archive_title', function ($title) {
if (is_category()) {
$titl... |
179,618 | <p>I would like to implement an <strong>inline file uploader</strong> to my plugin's option page as introduced in new media grid view of the WP media library:</p>
<p><img src="https://i.stack.imgur.com/F2xeo.png" alt="enter image description here"></p>
<p>I imagine having this drag & drop uploader in the page and... | [
{
"answer_id": 181524,
"author": "DiverseAndRemote.com",
"author_id": 23690,
"author_profile": "https://wordpress.stackexchange.com/users/23690",
"pm_score": 1,
"selected": false,
"text": "<p>The first thing you'll need to do is call <code>wp_enqueue_media</code>. A safe place for this m... | 2015/02/27 | [
"https://wordpress.stackexchange.com/questions/179618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51687/"
] | I would like to implement an **inline file uploader** to my plugin's option page as introduced in new media grid view of the WP media library:

I imagine having this drag & drop uploader in the page and getting an JSON object of either errors or atta... | Okay, here is what I came up with: It's all about using the [plupload library](http://plupload.com/) that comes shipped with WP.
1. Add a `<div>` to your plugin's option page that later becomes the drag'n'drop area
-------------------------------------------------------------------------------------
```
<div clas... |
179,654 | <p>When I use Joomla I can change a core string using the language files. So where it would say "Cart" you would go into the language file and change it to what you want it to say.</p>
<p>I want to be able to do this for one of our client's websites which uses WordPress. Is this possible? I am using the wpex-adapt the... | [
{
"answer_id": 181524,
"author": "DiverseAndRemote.com",
"author_id": 23690,
"author_profile": "https://wordpress.stackexchange.com/users/23690",
"pm_score": 1,
"selected": false,
"text": "<p>The first thing you'll need to do is call <code>wp_enqueue_media</code>. A safe place for this m... | 2015/02/27 | [
"https://wordpress.stackexchange.com/questions/179654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68312/"
] | When I use Joomla I can change a core string using the language files. So where it would say "Cart" you would go into the language file and change it to what you want it to say.
I want to be able to do this for one of our client's websites which uses WordPress. Is this possible? I am using the wpex-adapt theme.
The e... | Okay, here is what I came up with: It's all about using the [plupload library](http://plupload.com/) that comes shipped with WP.
1. Add a `<div>` to your plugin's option page that later becomes the drag'n'drop area
-------------------------------------------------------------------------------------
```
<div clas... |
179,666 | <p>I'm fairly new to Wordpress and am trying to do something very specific. I am currently using <a href="http://html5blank.com/" rel="nofollow">the awesome html5blank</a> to create my custom theme. I am using the native menus for my nav tabs. I am currently using <code>background-image</code>'s to make my nav tabs ima... | [
{
"answer_id": 179673,
"author": "Travis Seitler",
"author_id": 49522,
"author_profile": "https://wordpress.stackexchange.com/users/49522",
"pm_score": 3,
"selected": true,
"text": "<p>Given the amount of customization you're looking to make, your best bet may be to integrate a custom Wa... | 2015/02/27 | [
"https://wordpress.stackexchange.com/questions/179666",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60779/"
] | I'm fairly new to Wordpress and am trying to do something very specific. I am currently using [the awesome html5blank](http://html5blank.com/) to create my custom theme. I am using the native menus for my nav tabs. I am currently using `background-image`'s to make my nav tabs images instead of text but that is posing p... | Given the amount of customization you're looking to make, your best bet may be to integrate a custom Walker function. From [the Codex](http://codex.wordpress.org/Function_Reference/wp_nav_menu#Using_a_Custom_Walker_Function):
>
> For deeper conditional classes, you'll need to use a custom walker function (created in ... |
179,667 | <p>We have the site from <a href="http://asceticexperience.com/" rel="nofollow">http://asceticexperience.com/</a></p>
<p>Feel free to dig the site in order to understand our question below.</p>
<p>Of course, any feedback appreciated :-) but my main question is the following:</p>
<p>We have a photo multiple times on ... | [
{
"answer_id": 179669,
"author": "Nathan",
"author_id": 11952,
"author_profile": "https://wordpress.stackexchange.com/users/11952",
"pm_score": 1,
"selected": false,
"text": "<p>I'm guessing you're referring to images which have been placed into WordPress' post content editor, right?</p>... | 2015/02/27 | [
"https://wordpress.stackexchange.com/questions/179667",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1198/"
] | We have the site from <http://asceticexperience.com/>
Feel free to dig the site in order to understand our question below.
Of course, any feedback appreciated :-) but my main question is the following:
We have a photo multiple times on site (in blog, portfolio, and in slide-shows from the menus Body, Mind, Heart).
... | Plugin idea #1
--------------
When we insert an image into the editor, the plugin automatically modifies the *caption* and the *alt* attribute to:
```
[caption id="attachment_729" align="alignnone" width="300"]
<a href="http://example.tld/wp-content/uploads/2015/02/wordpress.jpg">
<img src="http://example.tld... |
179,683 | <p>I stupidly created a ton of websites with custom themes (not child themes, 100% custom) and named my theme folder "custom". Now they are starting to auto-update and get replaced with some theme from the repository that happens to use the same folder name.</p>
<p>I could disable the updates in wp_config, but I don'... | [
{
"answer_id": 179684,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>If the theme slug matches, but you have no version number in the style.css file (even if Name is missing too), it w... | 2015/02/27 | [
"https://wordpress.stackexchange.com/questions/179683",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41149/"
] | I stupidly created a ton of websites with custom themes (not child themes, 100% custom) and named my theme folder "custom". Now they are starting to auto-update and get replaced with some theme from the repository that happens to use the same folder name.
I could disable the updates in wp\_config, but I don't really l... | If the theme slug matches, but you have no version number in the style.css file (even if Name is missing too), it will always try to update that theme. The easiest way to prevent this is to add a Version in the style.css header and set it to a really high number that is unlikely to be lower than that theme's version:
... |
179,694 | <p>I write Following code to run my function every day at 16:20 .. </p>
<p>But I guess is the problem in code..</p>
<p>not working </p>
<p>Epoch timestamp: 1427488800 </p>
<p>3/28/2015 1:10:00 AM</p>
<pre><code>if( !wp_next_scheduled( 'import_into_db' ) ) {
wp_schedule_event( time('1427488800'), 'daily', 'import_i... | [
{
"answer_id": 179699,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 2,
"selected": false,
"text": "<p>Well, 1427488800 resolves to March 27, 2015, so your event isn't even set to start yet.</p>\n\n<p>Also, bear... | 2015/02/27 | [
"https://wordpress.stackexchange.com/questions/179694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48589/"
] | I write Following code to run my function every day at 16:20 ..
But I guess is the problem in code..
not working
Epoch timestamp: 1427488800
3/28/2015 1:10:00 AM
```
if( !wp_next_scheduled( 'import_into_db' ) ) {
wp_schedule_event( time('1427488800'), 'daily', 'import_into_db' );
function import_into_db(){
//... | WP Cron runs, when somebody visits your website.
Thus if nobody visits, the cron never runs.
Now there are 2 solutions:
1. Disable WP Cron, use a real cron job and customize it.
<https://support.hostgator.com/articles/specialized-help/technical/wordpress/how-to-replace-wordpress-cron-with-a-real-cron-job>
2. Use a ... |
179,713 | <p>I spent hours trying to find a solution to this, but I am not able to figure it out.
I have a table that shows user's data and I am trying to add pagination to it.</p>
<p>I have tried by adding "paged" in the array but when I click on the link I get "Page not found".</p>
<p>If I understand correctly the problem is... | [
{
"answer_id": 179718,
"author": "Jason Murray",
"author_id": 68194,
"author_profile": "https://wordpress.stackexchange.com/users/68194",
"pm_score": -1,
"selected": false,
"text": "<p>The <code>previous_posts_link</code> and <code>next_posts_link</code> functions are for archive page pa... | 2015/02/28 | [
"https://wordpress.stackexchange.com/questions/179713",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25277/"
] | I spent hours trying to find a solution to this, but I am not able to figure it out.
I have a table that shows user's data and I am trying to add pagination to it.
I have tried by adding "paged" in the array but when I click on the link I get "Page not found".
If I understand correctly the problem is created due to t... | As already pointed out in comments
* `gb_bypass_filter` is not a valid parameter for `WP_Query`. If you want to suppress to effect of filters on your query, add `'suppress_filters' => true` to your query arguments
* `previous_posts_link()` does not accept two arguments, only one. Unlike `next_posts_link()`, it does no... |
179,752 | <p>I have two <code>WP_query</code> loops in my frontpage.php file:</p>
<pre><code><div id="aanbod">
<div class="container-fluid section-name-cont">
<div class="container">
<div class="row">
<div class="col-xs-12 section-name"><h1>Aanbod</h1></div>... | [
{
"answer_id": 179754,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 1,
"selected": false,
"text": "<p>The function <code>have_posts</code> is for the main loop, so the <code>if</code> statement is checking... | 2015/02/28 | [
"https://wordpress.stackexchange.com/questions/179752",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68349/"
] | I have two `WP_query` loops in my frontpage.php file:
```
<div id="aanbod">
<div class="container-fluid section-name-cont">
<div class="container">
<div class="row">
<div class="col-xs-12 section-name"><h1>Aanbod</h1></div>
</div>
</div>
</div>
<?php
$args = array(
'pos... | Try to change:
```
<?php if ( have_posts() )
```
To
```
<?php if ( $verhuurd_query->have_posts() )
``` |
179,757 | <p>I wrote some extra fields for my custom taxonomy. I added the form fields to the add form. I got it to save by handling the appropriate values in <code>$_POST</code>. In 4.1.x, the add form is Ajax-ified. How can I clear out the form fields on success?</p>
<p>More specifically, how can I view the response to the <c... | [
{
"answer_id": 179760,
"author": "Jason Murray",
"author_id": 68194,
"author_profile": "https://wordpress.stackexchange.com/users/68194",
"pm_score": 2,
"selected": false,
"text": "<p>You could achieve this with a little bit of jQuery:</p>\n\n<p>Create this file within THEMEFOLDER/js/ ca... | 2015/02/28 | [
"https://wordpress.stackexchange.com/questions/179757",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36036/"
] | I wrote some extra fields for my custom taxonomy. I added the form fields to the add form. I got it to save by handling the appropriate values in `$_POST`. In 4.1.x, the add form is Ajax-ified. How can I clear out the form fields on success?
More specifically, how can I view the response to the `add-tag` admin ajax ac... | You could achieve this with a little bit of jQuery:
Create this file within THEMEFOLDER/js/ called field-clear.js and replace `#formID` with the ID of the form you would like to reset:
```
//Code runs when an ajax request succeeds
jQuery( document ).ajaxSuccess(function( event, xhr, settings ) {
//Check ajax acti... |
179,832 | <p>Here is my current code,</p>
<p><em>aio_menu.php</em></p>
<pre><code><?php
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
add_action( 'admin_menu', 'AIO_menu_creator' );
function AIO_menu_creator() {
add_menu_page( 'AIO WooCommerce Plugin', 'AIO', 'manage_options', 'aio-dashboard', plugins_url... | [
{
"answer_id": 179850,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>The <code>$function</code> argument of <code>add_menu_page</code> should be a function that produces your page outp... | 2015/03/01 | [
"https://wordpress.stackexchange.com/questions/179832",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68381/"
] | Here is my current code,
*aio\_menu.php*
```
<?php
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
add_action( 'admin_menu', 'AIO_menu_creator' );
function AIO_menu_creator() {
add_menu_page( 'AIO WooCommerce Plugin', 'AIO', 'manage_options', 'aio-dashboard', plugins_url('AIO-WooCommerce-Plugin/menu/... | The `$function` argument of `add_menu_page` should be a function that produces your page output, or if omitted, then the `$menu_slug` argument can be a file that when included will output the menu page.
But your output right now has nothing to do with the `add_menu_page` call, the problem is that you're requiring `aio... |
179,835 | <p>I have wordpress site hosted on openshift say example.com. I am redirecting example.com to www.example.com (non www to www). I have created alias for www and non www version and updated my cname with app name.</p>
<p>I tried pointing non www cname record to www version and it was working except for homepage (same 3... | [
{
"answer_id": 179837,
"author": "George Grigorita",
"author_id": 13214,
"author_profile": "https://wordpress.stackexchange.com/users/13214",
"pm_score": 0,
"selected": false,
"text": "<p>In your htaccess add the following (before the WordPress rewrites):</p>\n\n<pre><code>Options +Follo... | 2015/03/01 | [
"https://wordpress.stackexchange.com/questions/179835",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68383/"
] | I have wordpress site hosted on openshift say example.com. I am redirecting example.com to www.example.com (non www to www). I have created alias for www and non www version and updated my cname with app name.
I tried pointing non www cname record to www version and it was working except for homepage (same 301 redirec... | I think there is some issue with openshift's php hosting.
I found [this thread on stackoverflow](https://stackoverflow.com/questions/27773105/openshift-htaccess-rewriterule-doesnt-work).
So catch is you append port no after host.
This .htaccess code **should work**.
```
RewriteEngine On
RewriteCond %{HTTP_HOST} ^exam... |
179,840 | <p>I've built a child theme of <a href="http://www.elegantthemes.com/gallery/divi/" rel="nofollow noreferrer">Divi Theme</a> to use with <a href="https://buddypress.org/" rel="nofollow noreferrer">Buddypress</a>. So far so good, except for a script conflict on commenting buttons.</p>
<p>The theme load a javascript (<c... | [
{
"answer_id": 179852,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>From a purely WordPress perspective, the only solution I see would be to copy the script to your child theme and m... | 2015/03/01 | [
"https://wordpress.stackexchange.com/questions/179840",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68388/"
] | I've built a child theme of [Divi Theme](http://www.elegantthemes.com/gallery/divi/) to use with [Buddypress](https://buddypress.org/). So far so good, except for a script conflict on commenting buttons.
The theme load a javascript (`js/custom.js` at 2642:2662) with the following function:
```
$( 'a[href*=#]:not(... | First of all, to resolve the javascript conflict I've set up a simple `tl_custom.js` under my theme `js/` folder, with the following code
```
jQuery(document).ready(function($) {
// Remove handler set by themes/Divi/js/custom.js at line 2642
$( 'a[href*=#]:not([href=#])' ).off();
});
```
Then I add the scri... |
179,856 | <p>I've searched high and low and can't seem to get it. </p>
<p>I'm trying to output an XML feed with all the images attached to a post from a custom post type:</p>
<pre><code></BasicDetails>
<Pictures>
<Picture>
<PictureUrl><?php echo wp_get_attachment_url( get_post_thumbnail_id($post-&... | [
{
"answer_id": 179859,
"author": "Jason Murray",
"author_id": 68194,
"author_profile": "https://wordpress.stackexchange.com/users/68194",
"pm_score": 3,
"selected": true,
"text": "<p>You need to loop through the attachments within your post loop, replace the section of code you posted wi... | 2015/03/01 | [
"https://wordpress.stackexchange.com/questions/179856",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4640/"
] | I've searched high and low and can't seem to get it.
I'm trying to output an XML feed with all the images attached to a post from a custom post type:
```
</BasicDetails>
<Pictures>
<Picture>
<PictureUrl><?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID)); ?></PictureUrl>
<Caption></Caption>
</Pi... | You need to loop through the attachments within your post loop, replace the section of code you posted with this (put this together from [some other code I found](https://wordpress.org/support/topic/list-all-images-attached-to-a-post-based-on-gallery) related to a similar problem, but couldn't test it):
```
</BasicDet... |
179,858 | <p>I've googled extensively and tried my best, but I just can't get the first level children of the custom taxonomy in the code below to work! It only displays the parent level. What I am trying to achieve is the following:</p>
<pre><code>Level 1 <--- at the moment, it only displays this level
Level 2 <-- I ... | [
{
"answer_id": 179905,
"author": "Saurabh Shukla",
"author_id": 20375,
"author_profile": "https://wordpress.stackexchange.com/users/20375",
"pm_score": 0,
"selected": false,
"text": "<p>Check this code</p>\n\n<pre><code>$uchildren =get_terms( 'category', array('hide_empty' => false, '... | 2015/03/01 | [
"https://wordpress.stackexchange.com/questions/179858",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58166/"
] | I've googled extensively and tried my best, but I just can't get the first level children of the custom taxonomy in the code below to work! It only displays the parent level. What I am trying to achieve is the following:
```
Level 1 <--- at the moment, it only displays this level
Level 2 <-- I want to display this... | You have two issues here, one is a performance issue, the other is big issue that should return a pile of errors if you enable debug
The performance issue here is your first instance where you are getting the terms. It seems that your goal here is to get only top level terms, yet you get all. I would just add `'parent... |
179,860 | <p>I have a WordPress site with 65,000 registered users, about 10,000 of those users are spam bots, inactive account, hard email bonces etc.</p>
<p>I have them gathered in a CSV list, how can I use that csv list to delete those users from my WordPress site?</p>
<p>I haven't been able to find a plugin that does it. </... | [
{
"answer_id": 179867,
"author": "ColinMcDermott",
"author_id": 68355,
"author_profile": "https://wordpress.stackexchange.com/users/68355",
"pm_score": -1,
"selected": false,
"text": "<p>Have you tried the <a href=\"https://wordpress.org/plugins/stop-spammer-registrations-plugin/\" rel=\... | 2015/03/01 | [
"https://wordpress.stackexchange.com/questions/179860",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35798/"
] | I have a WordPress site with 65,000 registered users, about 10,000 of those users are spam bots, inactive account, hard email bonces etc.
I have them gathered in a CSV list, how can I use that csv list to delete those users from my WordPress site?
I haven't been able to find a plugin that does it. | You could try something like this.
```
DELETE
FROM wp_users
WHERE ID in ( 5506, 5507,... );
```
Make sure to try it on a staging area first and backup your database. |
179,871 | <p>I am having issues displaying tags only if there is tags and including php inside of it as well. This is what I tried but nothing is showing.</p>
<pre><code><?php
if( has_tag() ) { ?>
<!-- Start of tags -->
<?php echo get_the_term_list( $post->ID, 'download_tag', 'Tags ', ', ', '' ... | [
{
"answer_id": 179876,
"author": "Mark",
"author_id": 59862,
"author_profile": "https://wordpress.stackexchange.com/users/59862",
"pm_score": 0,
"selected": false,
"text": "<p>Inside your condition, try this:</p>\n\n<pre><code><?php \n $var = get_the_term_list( $post->ID, 'downl... | 2015/03/02 | [
"https://wordpress.stackexchange.com/questions/179871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49017/"
] | I am having issues displaying tags only if there is tags and including php inside of it as well. This is what I tried but nothing is showing.
```
<?php
if( has_tag() ) { ?>
<!-- Start of tags -->
<?php echo get_the_term_list( $post->ID, 'download_tag', 'Tags ', ', ', '' ); ?>
<!-- End of tags -->
... | The has\_tag function doesn't do what you expect here. It actually means 'post has tag' checks if a post (or current post) has a particular tag. Something like `has_tag( 'self-important-tag' )`. [See the codex](http://codex.wordpress.org/Function_Reference/has_tag)
If you leave out the conditional and the post has no... |
179,883 | <p>I used simple-fields plugin for one addition field(premium posts) and now I need to change the popular post widget. I need to get all popular post exclude premium post.</p>
<p>What I have tried so far,</p>
<p>original query,</p>
<pre><code>$popularposts = new WP_Query('showposts=5&meta_key=post_views_count&am... | [
{
"answer_id": 179876,
"author": "Mark",
"author_id": 59862,
"author_profile": "https://wordpress.stackexchange.com/users/59862",
"pm_score": 0,
"selected": false,
"text": "<p>Inside your condition, try this:</p>\n\n<pre><code><?php \n $var = get_the_term_list( $post->ID, 'downl... | 2015/03/02 | [
"https://wordpress.stackexchange.com/questions/179883",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68403/"
] | I used simple-fields plugin for one addition field(premium posts) and now I need to change the popular post widget. I need to get all popular post exclude premium post.
What I have tried so far,
original query,
```
$popularposts = new WP_Query('showposts=5&meta_key=post_views_count&orderby=meta_value_num&order=DESC&... | The has\_tag function doesn't do what you expect here. It actually means 'post has tag' checks if a post (or current post) has a particular tag. Something like `has_tag( 'self-important-tag' )`. [See the codex](http://codex.wordpress.org/Function_Reference/has_tag)
If you leave out the conditional and the post has no... |
179,892 | <p>i have created custom post type</p>
<p>my problem is:</p>
<p>in admin column, posts are sorted by ID</p>
<p>how can change it to date. In other words, i want to sort post by recently</p>
| [
{
"answer_id": 327613,
"author": "Ehsan",
"author_id": 54976,
"author_profile": "https://wordpress.stackexchange.com/users/54976",
"pm_score": 2,
"selected": false,
"text": "<pre><code>add_action( 'pre_get_posts', 'change_post_sort', 1 );\nfunction change_post_sort( $query ) {\n i... | 2015/03/02 | [
"https://wordpress.stackexchange.com/questions/179892",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54976/"
] | i have created custom post type
my problem is:
in admin column, posts are sorted by ID
how can change it to date. In other words, i want to sort post by recently | You must add this part to function.php:
```
add_action( 'pre_get_posts', 'example_func', 1 );
function example_func( $query ) {
if ( is_admin() && $query->is_main_query() ) {
$query->set( 'order' , 'DESC' );
}
return $query;
}
``` |
179,908 | <p>i have created user vote that can vote users or author of posts. so for example have 4 users which looks:</p>
<ol>
<li><p>user --- ID=1 --- META KEY='_thumbs_rating_up' --- META VALUE='13'</p></li>
<li><p>user --- ID=2 --- META KEY='_thumbs_rating_up' --- META VALUE='17'</p></li>
<li><p>user --- ID=3 --- META KEY='... | [
{
"answer_id": 327613,
"author": "Ehsan",
"author_id": 54976,
"author_profile": "https://wordpress.stackexchange.com/users/54976",
"pm_score": 2,
"selected": false,
"text": "<pre><code>add_action( 'pre_get_posts', 'change_post_sort', 1 );\nfunction change_post_sort( $query ) {\n i... | 2015/03/02 | [
"https://wordpress.stackexchange.com/questions/179908",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52391/"
] | i have created user vote that can vote users or author of posts. so for example have 4 users which looks:
1. user --- ID=1 --- META KEY='\_thumbs\_rating\_up' --- META VALUE='13'
2. user --- ID=2 --- META KEY='\_thumbs\_rating\_up' --- META VALUE='17'
3. user --- ID=3 --- META KEY='\_thumbs\_rating\_up' --- META VALUE... | You must add this part to function.php:
```
add_action( 'pre_get_posts', 'example_func', 1 );
function example_func( $query ) {
if ( is_admin() && $query->is_main_query() ) {
$query->set( 'order' , 'DESC' );
}
return $query;
}
``` |
179,955 | <p>In my post page,
used gallery on post plugin to display images ,
while i m trying to retrieve the post content -used the_content ,
but showing the plugin images also. how i get text editor content only? </p>
| [
{
"answer_id": 179997,
"author": "DINESH BHIMANI",
"author_id": 56382,
"author_profile": "https://wordpress.stackexchange.com/users/56382",
"pm_score": -1,
"selected": false,
"text": "<p>use this code to show only content of post</p>\n\n<pre><code> $args = array(\n 'order' =>... | 2015/03/02 | [
"https://wordpress.stackexchange.com/questions/179955",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68444/"
] | In my post page,
used gallery on post plugin to display images ,
while i m trying to retrieve the post content -used the\_content ,
but showing the plugin images also. how i get text editor content only? | use this code to show only content of post
```
$args = array(
'order' => 'ASC'
);
query_posts( $args );
while ( have_posts() ) : the_post();
// get only post of content not work plug-in short code
$post_7 = get_post(get_the_ID());
echo $title = $post_7->post_content;
endwhile;
// Reset Query
wp_reset_qu... |
179,995 | <p>I want to make an author box like this :
<img src="https://i.stack.imgur.com/fgDNP.png" alt="enter image description here"></p>
<pre><code><table style="border: solid 1px #ffffff;width:100%;">
<tbody>
<tr>
<td>
<h3><b><span style="color: #555; "... | [
{
"answer_id": 179996,
"author": "Ruturaj",
"author_id": 43266,
"author_profile": "https://wordpress.stackexchange.com/users/43266",
"pm_score": 1,
"selected": false,
"text": "<p>I've not tested your code; but assuming it's correct and working well, edit your <code>single.php</code> file... | 2015/03/03 | [
"https://wordpress.stackexchange.com/questions/179995",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67503/"
] | I want to make an author box like this :

```
<table style="border: solid 1px #ffffff;width:100%;">
<tbody>
<tr>
<td>
<h3><b><span style="color: #555; ">About Author</span> </b>
<input type="hidden" name="s... | I've not tested your code; but assuming it's correct and working well, edit your `single.php` file and insert this code just after the point where you end your post content and before the Comment Section starts.
I'd suggest to write this Author Box code in a separate file and then use `get_template_part` to insert th... |
180,080 | <p>I got a little obstruction. I have a free theme, which I like, but I found out that in the footer there are too many commercial links (Let me say spammy links). I want to keep the credits to the author. But I need to remove the ''spam'' links. I've tried many things for few hour by now, but I am not familiar with PH... | [
{
"answer_id": 179996,
"author": "Ruturaj",
"author_id": 43266,
"author_profile": "https://wordpress.stackexchange.com/users/43266",
"pm_score": 1,
"selected": false,
"text": "<p>I've not tested your code; but assuming it's correct and working well, edit your <code>single.php</code> file... | 2015/03/03 | [
"https://wordpress.stackexchange.com/questions/180080",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I got a little obstruction. I have a free theme, which I like, but I found out that in the footer there are too many commercial links (Let me say spammy links). I want to keep the credits to the author. But I need to remove the ''spam'' links. I've tried many things for few hour by now, but I am not familiar with PHP s... | I've not tested your code; but assuming it's correct and working well, edit your `single.php` file and insert this code just after the point where you end your post content and before the Comment Section starts.
I'd suggest to write this Author Box code in a separate file and then use `get_template_part` to insert th... |
180,087 | <p>hello i have post_type "product" and taxonomy "price"
can someone help me to query that custom post type with the selected taxonomy?</p>
<p>my current code is like this</p>
<pre><code><?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$args = array(
'post_type' => '... | [
{
"answer_id": 179996,
"author": "Ruturaj",
"author_id": 43266,
"author_profile": "https://wordpress.stackexchange.com/users/43266",
"pm_score": 1,
"selected": false,
"text": "<p>I've not tested your code; but assuming it's correct and working well, edit your <code>single.php</code> file... | 2015/03/04 | [
"https://wordpress.stackexchange.com/questions/180087",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68523/"
] | hello i have post\_type "product" and taxonomy "price"
can someone help me to query that custom post type with the selected taxonomy?
my current code is like this
```
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$args = array(
'post_type' => 'product',
'posts_per_page... | I've not tested your code; but assuming it's correct and working well, edit your `single.php` file and insert this code just after the point where you end your post content and before the Comment Section starts.
I'd suggest to write this Author Box code in a separate file and then use `get_template_part` to insert th... |
180,132 | <p>In a multisite network, when you change the main email address in Settings / General, Wordpress sends an email that must be confirmed by the new email recipient.</p>
<p>I need to avoid or customize the message that is being sent but can't figure out how.</p>
<p>The function responsible for sending this email is no... | [
{
"answer_id": 180140,
"author": "Luis Martins",
"author_id": 62160,
"author_profile": "https://wordpress.stackexchange.com/users/62160",
"pm_score": 0,
"selected": false,
"text": "<p>As indicated by @David Gard, this can easily be done:</p>\n\n<pre><code><?php\n\nremove_action( 'add_... | 2015/03/04 | [
"https://wordpress.stackexchange.com/questions/180132",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62160/"
] | In a multisite network, when you change the main email address in Settings / General, Wordpress sends an email that must be confirmed by the new email recipient.
I need to avoid or customize the message that is being sent but can't figure out how.
The function responsible for sending this email is not pluggable, as s... | It seems that my edit to your answer was declined, so here you go.
All that was missing was the `$priority` and `$accepted_args` parameters for the `add_action()` calls, and the the fixed code below should accomplish what you require.
```
remove_action( 'add_option_new_admin_email', 'update_option_new_admin_email' );... |
180,153 | <p>I am trying to implement an archive for a custom post type:</p>
<pre><code>http://mywebsite:8888/about-us/client-news/2015/03/
</code></pre>
<p>The problem is that it keeps serving me a 404 page and I cannot work out what page template its failing to find. I have tried turning on debug and a number of other steps<... | [
{
"answer_id": 180170,
"author": "Fiaz Husyn",
"author_id": 62739,
"author_profile": "https://wordpress.stackexchange.com/users/62739",
"pm_score": 0,
"selected": false,
"text": "<p>Try visiting : </p>\n\n<pre><code>http://mywebsite:8888/about-us/news/2015/03/\n</code></pre>\n\n<p>You ar... | 2015/03/04 | [
"https://wordpress.stackexchange.com/questions/180153",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68565/"
] | I am trying to implement an archive for a custom post type:
```
http://mywebsite:8888/about-us/client-news/2015/03/
```
The problem is that it keeps serving me a 404 page and I cannot work out what page template its failing to find. I have tried turning on debug and a number of other steps
The registration:
```
fu... | I have managed to resolve this by adding in a custom rewrite into the functions file:
```
// Add custom rewrite rules to handle things like years in custom post archives
function add_rewrite_rules($aRules) {
$aNewRules = array(
'news/([0-9]{4})/([0-9]{2})/page/?([0-9]{1,})/?$' => 'index.php?post_type=clien... |
180,221 | <p>I am trying to create a Menu that shows a maximum of 5 items. If there are more items it should wrap them into another <code><ul></code> Element to create a dropdown.</p>
<p>5 Items or less:</p>
<p><img src="https://i.imgur.com/FGvn84z.png" alt="Dropdown"></p>
<p>6 Items or more</p>
<p><img src="https://i.... | [
{
"answer_id": 180248,
"author": "mjakic",
"author_id": 67333,
"author_profile": "https://wordpress.stackexchange.com/users/67333",
"pm_score": 3,
"selected": false,
"text": "<p>You can use <code>wp_nav_menu_items</code> filter. It accepts menu output and arguments which hold menu attrib... | 2015/03/05 | [
"https://wordpress.stackexchange.com/questions/180221",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68011/"
] | I am trying to create a Menu that shows a maximum of 5 items. If there are more items it should wrap them into another `<ul>` Element to create a dropdown.
5 Items or less:

6 Items or more

I know this kind of functionality co... | Using a custom Walker, the `start_el()` method has access to `$depth` param: when it is `0` the elemnt is a top one, and we can use this info to maintain an internal counter.
When the counter reach a limit, we can use `DOMDocument` to get from full HTML output just the last element added, wrap it in a submenu and add ... |
180,227 | <p>So, I have this post title that has a certain length (say 15 words).</p>
<p>When the browser width is reduced, the overflown words are placed to a next line by pushing everything down.</p>
<p>However, is there a way to replace the overflown words with "..." so that there is no pushing down on the other contents?</... | [
{
"answer_id": 180248,
"author": "mjakic",
"author_id": 67333,
"author_profile": "https://wordpress.stackexchange.com/users/67333",
"pm_score": 3,
"selected": false,
"text": "<p>You can use <code>wp_nav_menu_items</code> filter. It accepts menu output and arguments which hold menu attrib... | 2015/03/05 | [
"https://wordpress.stackexchange.com/questions/180227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67604/"
] | So, I have this post title that has a certain length (say 15 words).
When the browser width is reduced, the overflown words are placed to a next line by pushing everything down.
However, is there a way to replace the overflown words with "..." so that there is no pushing down on the other contents?
Thanks! | Using a custom Walker, the `start_el()` method has access to `$depth` param: when it is `0` the elemnt is a top one, and we can use this info to maintain an internal counter.
When the counter reach a limit, we can use `DOMDocument` to get from full HTML output just the last element added, wrap it in a submenu and add ... |
180,240 | <p>I am wondering if this could be done if i want something like this. Look at my code please.</p>
<p>Here the code goes:</p>
<pre><code><?php _e('Search result for','NCC'); ?>
<?php /* Search Count */
$allsearch = &new WP_Query("s=$s&showposts=-1");
$key = wp_specialchars($s, 1);
$co... | [
{
"answer_id": 180242,
"author": "tutankhamun",
"author_id": 68544,
"author_profile": "https://wordpress.stackexchange.com/users/68544",
"pm_score": 0,
"selected": false,
"text": "<p>You may use <code>_n</code> function instead of <code>_e</code>.</p>\n\n<p>Read this: <a href=\"http://co... | 2015/03/05 | [
"https://wordpress.stackexchange.com/questions/180240",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23036/"
] | I am wondering if this could be done if i want something like this. Look at my code please.
Here the code goes:
```
<?php _e('Search result for','NCC'); ?>
<?php /* Search Count */
$allsearch = &new WP_Query("s=$s&showposts=-1");
$key = wp_specialchars($s, 1);
$count = $allsearch->post_count;
_e(... | `$found_posts` holds the amount of posts found by a certain query. You can use this logic to display your links
Example:
```
if ( $allsearch->found_posts <= 1 ) {
//Dispaly company
} else {
// Disply companies
}
```
Just a note on grammar, it should be `0 companies` `1 company` and `x amount of companies` a... |
180,295 | <p>I'm using the <code>avatar_defaults</code> filter hook to filter the default avatar list. For example:</p>
<pre><code>function my_avatar_defaults( $avatar_defaults ) {
$avatar_defaults['http://example.com/foo.png'] = __( 'Foo' );
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'my_avatar_defaults'... | [
{
"answer_id": 180296,
"author": "butlerblog",
"author_id": 38603,
"author_profile": "https://wordpress.stackexchange.com/users/38603",
"pm_score": 1,
"selected": true,
"text": "<p>You are doing it correctly.</p>\n\n<p>The call to gravatar.com passes the location of your custom image so ... | 2015/03/05 | [
"https://wordpress.stackexchange.com/questions/180295",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22599/"
] | I'm using the `avatar_defaults` filter hook to filter the default avatar list. For example:
```
function my_avatar_defaults( $avatar_defaults ) {
$avatar_defaults['http://example.com/foo.png'] = __( 'Foo' );
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'my_avatar_defaults' );
```
This works beca... | You are doing it correctly.
The call to gravatar.com passes the location of your custom image so that WP can load it. Take a look at the query string in the src, you'll see your image location. That's how it works. |
180,297 | <p>In our <code>archive.php</code> we show all the items which match our selected category. This works absolutely fine.</p>
<p>Then we improved it by adding (just before the loop) a sort and upping the posts per page from the default 10, like so:</p>
<pre><code>$posts = query_posts($query_string . '&orderby=title... | [
{
"answer_id": 180370,
"author": "mjakic",
"author_id": 67333,
"author_profile": "https://wordpress.stackexchange.com/users/67333",
"pm_score": 0,
"selected": false,
"text": "<p>There is ability to sort by more than one column. See <a href=\"http://codex.wordpress.org/Class_Reference/WP_... | 2015/03/05 | [
"https://wordpress.stackexchange.com/questions/180297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/875/"
] | In our `archive.php` we show all the items which match our selected category. This works absolutely fine.
Then we improved it by adding (just before the loop) a sort and upping the posts per page from the default 10, like so:
```
$posts = query_posts($query_string . '&orderby=title&order=asc&posts_per_page=99');
``... | If you're altering the main query, always use `pre_get_posts` to alter query parameters *before* the query is run and before the template is loaded. This will be the most efficient and will not break pagination. As of v4, `orderby` accepts an array of arguments, which gives you the ability to have different `order` for... |
180,347 | <p>I've been trying to integrate the <a href="http://owlgraphic.com/owlcarousel/#how-to" rel="nofollow noreferrer">owl.carousel</a> into my theme but can't get it to work. The instructions on the page are not for WordPress so I need help with how to properly enqueue the required files and calling (initializing) the car... | [
{
"answer_id": 219898,
"author": "steamfunk",
"author_id": 67512,
"author_profile": "https://wordpress.stackexchange.com/users/67512",
"pm_score": -1,
"selected": false,
"text": "<p>you do not have to enqueue both the owl.carousel.js and the owl.carousel.min.js just the min will do. also... | 2015/03/06 | [
"https://wordpress.stackexchange.com/questions/180347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26413/"
] | I've been trying to integrate the [owl.carousel](http://owlgraphic.com/owlcarousel/#how-to) into my theme but can't get it to work. The instructions on the page are not for WordPress so I need help with how to properly enqueue the required files and calling (initializing) the carousel.
I have added the following files... | You're reusing handles for the script and the styles. These need to be unique values (see [WP Codex Reference](https://developer.wordpress.org/reference/functions/wp_enqueue_script/))
It should look something like this:
```
wp_enqueue_script( 'owlcarousel', get_template_directory_uri() . '/inc/owl/owl.carousel.min.js... |
180,353 | <p>im try something with the upload_dir filter</p>
<p>I check the current CPT with this function </p>
<pre><code> function get_current_post_type() {
global $post, $typenow, $current_screen;
//we have a post so we can just get the post type from that
if ( $post && $post->post_type ) {
... | [
{
"answer_id": 180355,
"author": "Dave Ross",
"author_id": 3851,
"author_profile": "https://wordpress.stackexchange.com/users/3851",
"pm_score": 2,
"selected": false,
"text": "<p>In this code:</p>\n\n<pre><code>if ( $currentCPT = 'rsg_download' ) {\n</code></pre>\n\n<p>you're assigning t... | 2015/03/06 | [
"https://wordpress.stackexchange.com/questions/180353",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68663/"
] | im try something with the upload\_dir filter
I check the current CPT with this function
```
function get_current_post_type() {
global $post, $typenow, $current_screen;
//we have a post so we can just get the post type from that
if ( $post && $post->post_type ) {
return $post->post_type;
... | I found! this will only change the upload dir when upload in the "rsg\_download" CPT
```
add_filter( 'wp_handle_upload_prefilter', 'rsg_pre_upload' );
function rsg_pre_upload( $file ) {
add_filter( 'upload_dir', 'rsg_custom_upload_dir' );
return $file;
}
function rsg_custom_upload_dir( $param ) {
$id = $_... |
180,363 | <p>I'm optimizing a WordPress site. For this, I have created a function that remove the old sticky posts. This function doesn't work correctly in some cases. Sometimes all sticky's are removed (so no sticky is set). Is there anyone who could see what this causes?</p>
<pre><code>add_action( 'publish_post', 'wf_clean_st... | [
{
"answer_id": 180355,
"author": "Dave Ross",
"author_id": 3851,
"author_profile": "https://wordpress.stackexchange.com/users/3851",
"pm_score": 2,
"selected": false,
"text": "<p>In this code:</p>\n\n<pre><code>if ( $currentCPT = 'rsg_download' ) {\n</code></pre>\n\n<p>you're assigning t... | 2015/03/06 | [
"https://wordpress.stackexchange.com/questions/180363",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68668/"
] | I'm optimizing a WordPress site. For this, I have created a function that remove the old sticky posts. This function doesn't work correctly in some cases. Sometimes all sticky's are removed (so no sticky is set). Is there anyone who could see what this causes?
```
add_action( 'publish_post', 'wf_clean_sticky', 10, 2);... | I found! this will only change the upload dir when upload in the "rsg\_download" CPT
```
add_filter( 'wp_handle_upload_prefilter', 'rsg_pre_upload' );
function rsg_pre_upload( $file ) {
add_filter( 'upload_dir', 'rsg_custom_upload_dir' );
return $file;
}
function rsg_custom_upload_dir( $param ) {
$id = $_... |
180,385 | <p>I have PHP code as </p>
<pre><code>$message = str_replace("{eventlinkURL}",$eventlinkURL,$message);
</code></pre>
<p>I want to set color to the <code>$eventlinkURL</code> variable. I tried using <code><font></code> </p>
<pre><code>echo "<font style='background:red'> <font color ='red'>
$mess... | [
{
"answer_id": 180391,
"author": "Ituk",
"author_id": 68680,
"author_profile": "https://wordpress.stackexchange.com/users/68680",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li><p>do not use <code><font></code> html tag, it is old and i'm not even sure if can work in modern b... | 2015/03/06 | [
"https://wordpress.stackexchange.com/questions/180385",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68679/"
] | I have PHP code as
```
$message = str_replace("{eventlinkURL}",$eventlinkURL,$message);
```
I want to set color to the `$eventlinkURL` variable. I tried using `<font>`
```
echo "<font style='background:red'> <font color ='red'>
$message = str_replace('{eventlinkURL}',$eventlinkURL,$message); />";
```
but n... | 1. do not use `<font>` html tag, it is old and i'm not even sure if can work in modern browsers. instead use `<span>` (for inline text) or `<p>` (for paragraph).
2. php and html can work together but there's an appropriate way to write it.
generally speaking, html code is wrapped with double quotes `"html"` and php wit... |
180,397 | <p>I don't know how to do it, but I have a few js code blocks in my sites header like the StatCounter tracking code, facebook like button js code, etc.</p>
<p>Now the thing is that I want to combine all the external js code blocks into one file so that I can add it either in the header or footer section. Can any one g... | [
{
"answer_id": 180391,
"author": "Ituk",
"author_id": 68680,
"author_profile": "https://wordpress.stackexchange.com/users/68680",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li><p>do not use <code><font></code> html tag, it is old and i'm not even sure if can work in modern b... | 2015/03/06 | [
"https://wordpress.stackexchange.com/questions/180397",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68685/"
] | I don't know how to do it, but I have a few js code blocks in my sites header like the StatCounter tracking code, facebook like button js code, etc.
Now the thing is that I want to combine all the external js code blocks into one file so that I can add it either in the header or footer section. Can any one guide me on... | 1. do not use `<font>` html tag, it is old and i'm not even sure if can work in modern browsers. instead use `<span>` (for inline text) or `<p>` (for paragraph).
2. php and html can work together but there's an appropriate way to write it.
generally speaking, html code is wrapped with double quotes `"html"` and php wit... |
180,411 | <p>I am building a plugin which loads a form into a table cell when clicked. </p>
<p>Here is the AJAX:</p>
<pre><code> public static function cp_libhours_ajax(){
?>
<script>
jQuery(document).ready(function(){
jQuery('.libhours-row a').click(function(e){
e.preventDefault(); //don't ... | [
{
"answer_id": 180422,
"author": "Ituk",
"author_id": 68680,
"author_profile": "https://wordpress.stackexchange.com/users/68680",
"pm_score": 0,
"selected": false,
"text": "<p>try to add <code>return false;</code> after the ajax call. like this:</p>\n\n<pre><code> jQuery.post(ajaxurl, d... | 2015/03/06 | [
"https://wordpress.stackexchange.com/questions/180411",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68200/"
] | I am building a plugin which loads a form into a table cell when clicked.
Here is the AJAX:
```
public static function cp_libhours_ajax(){
?>
<script>
jQuery(document).ready(function(){
jQuery('.libhours-row a').click(function(e){
e.preventDefault(); //don't let the link click through
... | This happens because you specify in your ajax request a different url than you use in the form.
```
Query.post(ajaxurl, data, function(response) {
```
you don't show it in the code snippet but`ajaxurl` is usually set to be the `{site url}\wp-admin\admin-ajax.php`. |
180,417 | <p>I'm using a <code>wp_query</code> to find custom posts that have a specified numeric value inside of a custom field. That custom field's value is an array of numbers (IDs of selected posts using Advanced Custom Field's Relationship field). </p>
<p>So I am trying to find all posts that have the specified value insid... | [
{
"answer_id": 180434,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 1,
"selected": false,
"text": "<p>First of all, your <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameter... | 2015/03/06 | [
"https://wordpress.stackexchange.com/questions/180417",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34273/"
] | I'm using a `wp_query` to find custom posts that have a specified numeric value inside of a custom field. That custom field's value is an array of numbers (IDs of selected posts using Advanced Custom Field's Relationship field).
So I am trying to find all posts that have the specified value inside of that field's arr... | I solved it using some of Pieter Goosen's code, and taking a closer look at the field's value in SQL. It was saving the information in a strange manner that required me to wrap the value in quotation marks to return the correct posts.
Here's the working code:
```
foreach ($selectedAuthors as $myAuthor){
echo '<hr... |
180,437 | <p>I've been trying to figure out this problem for a while now:</p>
<pre><code><article class="post">
<div class="entry-header">
<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
</div> <!-- end entry-he... | [
{
"answer_id": 180434,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 1,
"selected": false,
"text": "<p>First of all, your <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameter... | 2015/03/07 | [
"https://wordpress.stackexchange.com/questions/180437",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38796/"
] | I've been trying to figure out this problem for a while now:
```
<article class="post">
<div class="entry-header">
<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
</div> <!-- end entry-header -->
<div class="entry-content">
<?php the_content(); ... | I solved it using some of Pieter Goosen's code, and taking a closer look at the field's value in SQL. It was saving the information in a strange manner that required me to wrap the value in quotation marks to return the correct posts.
Here's the working code:
```
foreach ($selectedAuthors as $myAuthor){
echo '<hr... |
180,450 | <p>I have a custom field that contains links in them and I want to auto add nofollow to those links in that custom field only. How can I do this?</p>
<p>Example custom field value:</p>
<pre><code><a href="http://www.uploadable.ch/file/PnvbZ2k8B4ku/[Raizel]_Medaka_Box_01v2_(BD_720p_AAC)_(1A92BFA4).mkv">[Raizel]_... | [
{
"answer_id": 180452,
"author": "Ituk",
"author_id": 68680,
"author_profile": "https://wordpress.stackexchange.com/users/68680",
"pm_score": 2,
"selected": true,
"text": "<p>This is something you cannot change in the field it self, but in the template file. \nCopy and paste here the tem... | 2015/03/07 | [
"https://wordpress.stackexchange.com/questions/180450",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17971/"
] | I have a custom field that contains links in them and I want to auto add nofollow to those links in that custom field only. How can I do this?
Example custom field value:
```
<a href="http://www.uploadable.ch/file/PnvbZ2k8B4ku/[Raizel]_Medaka_Box_01v2_(BD_720p_AAC)_(1A92BFA4).mkv">[Raizel]_Medaka_Box_01v2_(BD_720p_AA... | This is something you cannot change in the field it self, but in the template file.
Copy and paste here the template file where this option is outputted.
Another way will be to add a javascript snippet to you `head`, if you have such option in you template.
Comment here and we'll see what the best solution is.
Upd... |
180,496 | <p>I'm trying to get <code>WP_Query</code> to display ALL posts in an array but only ones with status published are showing:</p>
<pre><code>global $wp_query;
$ids = array(130, 132);
$args = array(
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit'),
// 'pos... | [
{
"answer_id": 291420,
"author": "Jignesh Patel",
"author_id": 111556,
"author_profile": "https://wordpress.stackexchange.com/users/111556",
"pm_score": 0,
"selected": false,
"text": "<p>Please try like this:</p>\n\n<pre><code><?php\n\nglobal $wp_query;\n\n$ids = array(130,132);\n$a... | 2015/03/07 | [
"https://wordpress.stackexchange.com/questions/180496",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18726/"
] | I'm trying to get `WP_Query` to display ALL posts in an array but only ones with status published are showing:
```
global $wp_query;
$ids = array(130, 132);
$args = array(
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit'),
// 'post_status' => 'any', // same ... | You can just `'post_status' => 'any'`.
Here is the completed code.
```
global $wp_query;
$ids = array(130,132);
$args = array(
'post_status' => 'any',
// 'post_status' => 'any', // same output
'post__in' => $ids,
'post_type' => 'alpha'
);
$q = new WP_Qu... |
180,517 | <p>I am working on a child theme of the WordPress Twenty Ten theme. I have several pages in WordPress (About page, Testimonials page, Contact page, etc.). I want to only echo the page content (the actual about/testimonials/contact page written content and images BUT NOT the page title). I know I can echo just the page ... | [
{
"answer_id": 180520,
"author": "Jason Murray",
"author_id": 68194,
"author_profile": "https://wordpress.stackexchange.com/users/68194",
"pm_score": 0,
"selected": false,
"text": "<pre><code>the_content();\n</code></pre>\n\n<p>I think this is what you're looking for?</p>\n"
},
{
... | 2015/03/08 | [
"https://wordpress.stackexchange.com/questions/180517",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25121/"
] | I am working on a child theme of the WordPress Twenty Ten theme. I have several pages in WordPress (About page, Testimonials page, Contact page, etc.). I want to only echo the page content (the actual about/testimonials/contact page written content and images BUT NOT the page title). I know I can echo just the page tit... | You can make use of `the_page_content()` **outside** the loop to display only the content of the page where `the_page_content()` is supported by the following function
```
function the_page_content() {
global $post;
$content = '';
if ( is_page() ) {
$content .= apply_filters( 'the_content', $post-... |
180,545 | <p>UPDATE: I'm going to update this one up at the top, because the solution I've found was with a differing filter hook. I'm going to look again at reply_link-specific hooks now that I better understand how to use them, but the solution to the main problem turned out to be easy once I found the right one: 'thread_comme... | [
{
"answer_id": 180520,
"author": "Jason Murray",
"author_id": 68194,
"author_profile": "https://wordpress.stackexchange.com/users/68194",
"pm_score": 0,
"selected": false,
"text": "<pre><code>the_content();\n</code></pre>\n\n<p>I think this is what you're looking for?</p>\n"
},
{
... | 2015/03/08 | [
"https://wordpress.stackexchange.com/questions/180545",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35923/"
] | UPDATE: I'm going to update this one up at the top, because the solution I've found was with a differing filter hook. I'm going to look again at reply\_link-specific hooks now that I better understand how to use them, but the solution to the main problem turned out to be easy once I found the right one: 'thread\_commen... | You can make use of `the_page_content()` **outside** the loop to display only the content of the page where `the_page_content()` is supported by the following function
```
function the_page_content() {
global $post;
$content = '';
if ( is_page() ) {
$content .= apply_filters( 'the_content', $post-... |
180,576 | <p>I want to display in page the latest post content from a category.</p>
<p>For example, the category <code>foo</code> has the following posts:</p>
<ul>
<li><ol>
<li>Hello World</li>
</ol></li>
<li><ol start="2">
<li>Hello Mars</li>
</ol></li>
<li><ol start="3">
<li>Foo bar</li>
</ol></li>
</ul>
<p>Considering <em>... | [
{
"answer_id": 180577,
"author": "Jorge Y. C. Rodriguez",
"author_id": 35073,
"author_profile": "https://wordpress.stackexchange.com/users/35073",
"pm_score": -1,
"selected": false,
"text": "<p>You can do something like this:::</p>\n\n<pre><code> $args = array(\n 'post_type' =>... | 2015/03/09 | [
"https://wordpress.stackexchange.com/questions/180576",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44849/"
] | I want to display in page the latest post content from a category.
For example, the category `foo` has the following posts:
* 1. Hello World
* 2. Hello Mars
* 3. Foo bar
Considering *Foo Bar* the latest article from *foo* category, its content should be rendered in a page:
```
<title>
<content>
```
Where `<title>... | You can make use of `WP_Query` to call the lastest post from the category and display it. Have a look at the [category parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters). By default, `WP_Query` uses `post` as the post type and orders post by post date, so we can exclude that from the q... |
180,589 | <p>I have a custom post type <code>product</code>. Visitors can search <code>products</code> with many filters. They can set the <code>color</code>, the <code>size</code>, the <code>price</code>, etc. The details of the product are stored with <em>Advanced Custom Fields (ACF)</em>.</p>
<p>My solution was a <code>WP_Qu... | [
{
"answer_id": 180591,
"author": "LeMike",
"author_id": 42974,
"author_profile": "https://wordpress.stackexchange.com/users/42974",
"pm_score": 3,
"selected": false,
"text": "<p>You might need a 180° solution here ;)\nThink about the problem once more and try this:</p>\n\n<blockquote>\n ... | 2015/03/09 | [
"https://wordpress.stackexchange.com/questions/180589",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65647/"
] | I have a custom post type `product`. Visitors can search `products` with many filters. They can set the `color`, the `size`, the `price`, etc. The details of the product are stored with *Advanced Custom Fields (ACF)*.
My solution was a `WP_Query` with `meta_queries`. All `WP_Meta_Queries` are in `AND`-relations.
My p... | You might need a 180° solution here ;)
Think about the problem once more and try this:
>
> As a visitor I can filter by color and size.
>
>
>
So your solution might be:
```
...
JOIN ... (A)
... (B)
... (C)
WHERE (A.meta_key = 'color' AND A.meta_value = 'red')
OR (B.meta_key = 'color' AND B.meta_value = 'blue')
.... |
180,590 | <p>Currently I am using WooCommerce for WordPress and trying to add custom fields for Variations Product. After did some researches, I found some code and tried to modify it.</p>
<p>This is my full code : <a href="https://gist.github.com/alphadc/da163cc95cfd1cede34a" rel="nofollow">https://gist.github.com/alphadc/da16... | [
{
"answer_id": 180967,
"author": "Irwan",
"author_id": 58082,
"author_profile": "https://wordpress.stackexchange.com/users/58082",
"pm_score": 4,
"selected": true,
"text": "<p>Okay, based on answers on link above (where I got the old code and there are people that help to answered), I pu... | 2015/03/09 | [
"https://wordpress.stackexchange.com/questions/180590",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58082/"
] | Currently I am using WooCommerce for WordPress and trying to add custom fields for Variations Product. After did some researches, I found some code and tried to modify it.
This is my full code : <https://gist.github.com/alphadc/da163cc95cfd1cede34a>
```
add_action( 'woocommerce_product_after_variable_attributes', 'va... | Okay, based on answers on link above (where I got the old code and there are people that help to answered), I put the modification code for my website. I tried it and it's working like charm.
Change:
```
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );
```
Into :
```
add_act... |
180,593 | <p>I am using <code><?php wp_get_attachment_thumb_url( $attachment_id ); ?></code> to get the url of a thumbnail for a post in Wordpress. However I would like to retrieve the URL of a specific size image. So for example when displaying the post thunmbnail normally you can specify a size, like: <code><?php the_... | [
{
"answer_id": 180967,
"author": "Irwan",
"author_id": 58082,
"author_profile": "https://wordpress.stackexchange.com/users/58082",
"pm_score": 4,
"selected": true,
"text": "<p>Okay, based on answers on link above (where I got the old code and there are people that help to answered), I pu... | 2015/03/09 | [
"https://wordpress.stackexchange.com/questions/180593",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47334/"
] | I am using `<?php wp_get_attachment_thumb_url( $attachment_id ); ?>` to get the url of a thumbnail for a post in Wordpress. However I would like to retrieve the URL of a specific size image. So for example when displaying the post thunmbnail normally you can specify a size, like: `<?php the_post_thumbnail( $size, $attr... | Okay, based on answers on link above (where I got the old code and there are people that help to answered), I put the modification code for my website. I tried it and it's working like charm.
Change:
```
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );
```
Into :
```
add_act... |
180,671 | <p>i created a custom post type and also some taxonomy to be able to perform sorting on the display list.</p>
<p>It is all working well on my local testing installation but as soon as i put on the production website (where there is some other plugins etc installed compared to my local), then the sorting is not working... | [
{
"answer_id": 180967,
"author": "Irwan",
"author_id": 58082,
"author_profile": "https://wordpress.stackexchange.com/users/58082",
"pm_score": 4,
"selected": true,
"text": "<p>Okay, based on answers on link above (where I got the old code and there are people that help to answered), I pu... | 2015/03/10 | [
"https://wordpress.stackexchange.com/questions/180671",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68814/"
] | i created a custom post type and also some taxonomy to be able to perform sorting on the display list.
It is all working well on my local testing installation but as soon as i put on the production website (where there is some other plugins etc installed compared to my local), then the sorting is not working anymore, ... | Okay, based on answers on link above (where I got the old code and there are people that help to answered), I put the modification code for my website. I tried it and it's working like charm.
Change:
```
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );
```
Into :
```
add_act... |
180,678 | <p>My client is using these two plugins:
- All in One Buttons
- Genesis Design Palette</p>
<p>If you check this example page <a href="http://bsc.mustor.com/testing-buttons/" rel="nofollow">http://bsc.mustor.com/testing-buttons/</a> you will see that time text on the button is maroon and red (hover). It is supposed to ... | [
{
"answer_id": 180690,
"author": "jimihenrik",
"author_id": 64625,
"author_profile": "https://wordpress.stackexchange.com/users/64625",
"pm_score": 1,
"selected": false,
"text": "<p>On the definition of the aio-orange button in the all-in-one-buttons/css/display.css?ver=4.1.1 add !import... | 2015/03/10 | [
"https://wordpress.stackexchange.com/questions/180678",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64780/"
] | My client is using these two plugins:
- All in One Buttons
- Genesis Design Palette
If you check this example page <http://bsc.mustor.com/testing-buttons/> you will see that time text on the button is maroon and red (hover). It is supposed to be white.
The style sheet inserted by Genesis Design Palette is overriding ... | On the definition of the aio-orange button in the all-in-one-buttons/css/display.css?ver=4.1.1 add !important after the #FFF.
The color is overwritten because you load the AIO styles first and later some other style that overrides button styles or what not. With !important you can tell the browser to use that one even... |
180,727 | <p>I am developing a game, and I am planning that, I will have partners, so they can run a game like mine.</p>
<p>For this, I developed a plugin, with some classes, and functions, to handle the game requests.</p>
<p>Because, this plugin is totally unusable for all the wordpress users, I want to send to my partners th... | [
{
"answer_id": 180729,
"author": "Ben Cole",
"author_id": 32532,
"author_profile": "https://wordpress.stackexchange.com/users/32532",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, it is possible to host your own plugin and have the plugin check for updates from your server. You need... | 2015/03/10 | [
"https://wordpress.stackexchange.com/questions/180727",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68847/"
] | I am developing a game, and I am planning that, I will have partners, so they can run a game like mine.
For this, I developed a plugin, with some classes, and functions, to handle the game requests.
Because, this plugin is totally unusable for all the wordpress users, I want to send to my partners this plugin in an e... | All Credit to the following post goes to [Abid](http://tutsplus.com/authors/abid-omar) [Omar](https://github.com/omarabid). The full tutorial can be found on Tuts+: [A Guide to the WordPress HTTP API: Automatic Plugin Updates](http://code.tutsplus.com/tutorials/a-guide-to-the-wordpress-http-api-automatic-plugin-updates... |
180,762 | <p>Ok, I've got this simple code for a simple plugin which prepends post titles with the word TESTING.. I'm really unclear how the parameter works here. I understand how parameters work in PHP, but nothing has been passed inside this parameter for WordPress to know the variable is the title.. if that makes sense?? Don'... | [
{
"answer_id": 180768,
"author": "Sean Grant",
"author_id": 67105,
"author_profile": "https://wordpress.stackexchange.com/users/67105",
"pm_score": 2,
"selected": true,
"text": "<p>Let's see if we can break it down so it's easy to understand.</p>\n\n<p>You have a PHP function named 'cm_t... | 2015/03/10 | [
"https://wordpress.stackexchange.com/questions/180762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68865/"
] | Ok, I've got this simple code for a simple plugin which prepends post titles with the word TESTING.. I'm really unclear how the parameter works here. I understand how parameters work in PHP, but nothing has been passed inside this parameter for WordPress to know the variable is the title.. if that makes sense?? Don't g... | Let's see if we can break it down so it's easy to understand.
You have a PHP function named 'cm\_title':
```
function cm_title($text) {
return 'TESTING ' . $text;
}
```
It only does 1 thing. It takes what it is given, '$text', and returns that $text with the words 'Testing ' prepended to it.
How does Word... |
180,838 | <p>I am trying to use MAMP's built in Xip.io functionality to view a WordPress multisite installation on a local network. I have this working no problem with a WordPress single installation but am struggling with multisite. Just wondered if anyone knew what needed changing in the wp-config file to get this working usin... | [
{
"answer_id": 180768,
"author": "Sean Grant",
"author_id": 67105,
"author_profile": "https://wordpress.stackexchange.com/users/67105",
"pm_score": 2,
"selected": true,
"text": "<p>Let's see if we can break it down so it's easy to understand.</p>\n\n<p>You have a PHP function named 'cm_t... | 2015/03/11 | [
"https://wordpress.stackexchange.com/questions/180838",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23406/"
] | I am trying to use MAMP's built in Xip.io functionality to view a WordPress multisite installation on a local network. I have this working no problem with a WordPress single installation but am struggling with multisite. Just wondered if anyone knew what needed changing in the wp-config file to get this working using m... | Let's see if we can break it down so it's easy to understand.
You have a PHP function named 'cm\_title':
```
function cm_title($text) {
return 'TESTING ' . $text;
}
```
It only does 1 thing. It takes what it is given, '$text', and returns that $text with the words 'Testing ' prepended to it.
How does Word... |
180,852 | <p>I am working in Wordpress, and I would like to make certain elements disappear once a user logs in. How can I do this?</p>
<p>I have social icons on my page that I positioned to the center of my menu bar at the top of my website.
those icons are generated by a plugin</p>
<p>that is what i want to disappear </p>
... | [
{
"answer_id": 180853,
"author": "Pixelsmith",
"author_id": 66368,
"author_profile": "https://wordpress.stackexchange.com/users/66368",
"pm_score": 1,
"selected": false,
"text": "<p>You'll want to use a PHP if statement in combination with <a href=\"http://codex.wordpress.org/Function_Re... | 2015/03/11 | [
"https://wordpress.stackexchange.com/questions/180852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65468/"
] | I am working in Wordpress, and I would like to make certain elements disappear once a user logs in. How can I do this?
I have social icons on my page that I positioned to the center of my menu bar at the top of my website.
those icons are generated by a plugin
that is what i want to disappear
<https://hughesjobs.n... | You'll want to use a PHP if statement in combination with [`is_user_logged_in`](http://codex.wordpress.org/Function_Reference/is_user_logged_in)
If you're editing your header try this:
```
<?php if (!is_user_logged_in()) { ?>
// Your social media icons code goes here
<?php } ?>
```
The exclamation point before `is_... |
180,887 | <p>After hours of searching and trying different functions, I've finally successfully removed the /author/ from all of our users profile URLs. So its just /username/</p>
<p>However, when new users register their profile URL's all give 404's. I can fix this by going into the permalinks screen and clicking save but we r... | [
{
"answer_id": 180897,
"author": "Dave Ross",
"author_id": 3851,
"author_profile": "https://wordpress.stackexchange.com/users/3851",
"pm_score": 0,
"selected": false,
"text": "<p><code>author_rewrite_rules</code> is only going to be invoked when WordPress needs to regenerate the rewrite ... | 2015/03/11 | [
"https://wordpress.stackexchange.com/questions/180887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18085/"
] | After hours of searching and trying different functions, I've finally successfully removed the /author/ from all of our users profile URLs. So its just /username/
However, when new users register their profile URL's all give 404's. I can fix this by going into the permalinks screen and clicking save but we register lo... | You are just doing it wrong. Adding a per user rewrite rule will just bloat the rewrite "table" and slow down the URL parsing process. You need to come up with a generic rewrite rule which will work for all users, or write an alternative url parsing using the 'do\_parse\_request filter.
Your core problem is that your ... |
180,964 | <p>I tried to use get_page_link('page-id') and get_permalink('page-id') but the error below occurred.</p>
<blockquote>
<p><strong>Fatal error:</strong> Call to a member function get_page_permastruct() on null in ...</p>
</blockquote>
<p>How can I get a page url knowing only its ID?</p>
| [
{
"answer_id": 180965,
"author": "SeventhSteel",
"author_id": 17276,
"author_profile": "https://wordpress.stackexchange.com/users/17276",
"pm_score": 4,
"selected": true,
"text": "<p>You're probably getting that error because WordPress doesn't have the $wp_rewrite global loaded yet for s... | 2015/03/12 | [
"https://wordpress.stackexchange.com/questions/180964",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68961/"
] | I tried to use get\_page\_link('page-id') and get\_permalink('page-id') but the error below occurred.
>
> **Fatal error:** Call to a member function get\_page\_permastruct() on null in ...
>
>
>
How can I get a page url knowing only its ID? | You're probably getting that error because WordPress doesn't have the $wp\_rewrite global loaded yet for some reason. Either something deactivated it, or you're trying to run those functions before WordPress has a chance to load it.
If you're trying to do this in a plugin or in your theme's functions.php file, make su... |
180,994 | <p>I'm creating a complex site with a product catalog with two custom taxonomies. They are Brands and Types.</p>
<p>Brands
- Canon
- Toshiba
- HP</p>
<p>Types
- Printers
- Scanners
- Multifunction</p>
<p>I need a page that finds all products that are any combination of one brand and one type. The brand is the more i... | [
{
"answer_id": 181003,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": true,
"text": "<p>This rewrite rule should work (assuming \"brand\" and \"type\" are the taxonomy registered names):</p>\n\n<pre... | 2015/03/12 | [
"https://wordpress.stackexchange.com/questions/180994",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24566/"
] | I'm creating a complex site with a product catalog with two custom taxonomies. They are Brands and Types.
Brands
- Canon
- Toshiba
- HP
Types
- Printers
- Scanners
- Multifunction
I need a page that finds all products that are any combination of one brand and one type. The brand is the more important of the two, so ... | This rewrite rule should work (assuming "brand" and "type" are the taxonomy registered names):
```
function custom_rewrite_rules() {
add_rewrite_rule('^brand/(.*)/type/(.*)?', 'index.php?brand=$matches[1]&type=$matches[2]', 'top');
}
add_action('init', 'custom_rewrite_rules');
```
Remember to flush the rewirte r... |
181,000 | <p>Is there a specific method to get attachment/image info in JS?
I have an attachment id and before I use any </p>
<pre><code>add_action("wp_ajax_get_image_info", "get_image_info");
</code></pre>
<p>I would like to see if there is a native method for doing this trough JS only. </p>
| [
{
"answer_id": 181018,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Jetpack has a JSON API that allows you to query pretty much everything in a given install. <a href=\"http://jetpa... | 2015/03/12 | [
"https://wordpress.stackexchange.com/questions/181000",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67176/"
] | Is there a specific method to get attachment/image info in JS?
I have an attachment id and before I use any
```
add_action("wp_ajax_get_image_info", "get_image_info");
```
I would like to see if there is a native method for doing this trough JS only. | Long story short, you can get info about an attachment by using `wp.media.attachment()` function. This will give you complete data as long as this attachment is already loaded by another script or an `wp.media()` popup.
If the data is not yet loaded, you can load it using `.fetch()` method on attachment, which works ... |
181,012 | <p>I've registered an <code>employers</code> post type with several associated taxonomies and want to all associated pages (single, term archives, post type archive page) only viewable by logged-in users.</p>
<p>I've played around with the <code>capabilities</code> argument for <code>register_post_type()</code> and lo... | [
{
"answer_id": 181017,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I may be misreading what you want, but you can do this with current_user_can() in your template.</p>\n\n<pre><cod... | 2015/03/12 | [
"https://wordpress.stackexchange.com/questions/181012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9844/"
] | I've registered an `employers` post type with several associated taxonomies and want to all associated pages (single, term archives, post type archive page) only viewable by logged-in users.
I've played around with the `capabilities` argument for `register_post_type()` and looked at the `map_meta_cap` filter, but just... | I've faced similar situations (say a client wants to see how a custom post type and/or taxonomy behaves before they're ready for the general public to see it). In those cases I'll use something like the following code snippet, added either to the plugin file (assuming I've built the CPT/taxonomy as a plugin) or directl... |
181,070 | <p>How can I add an input field to the admin section Users -> Add New?</p>
<p>I want to add a field for a phone number, but don't want a plugin to do that.</p>
| [
{
"answer_id": 181071,
"author": "Bird87 ZA",
"author_id": 59212,
"author_profile": "https://wordpress.stackexchange.com/users/59212",
"pm_score": 3,
"selected": true,
"text": "<p>Okay found the answer by poking around the code</p>\n\n<p>A field can be added by doing the following:</p>\n... | 2015/03/13 | [
"https://wordpress.stackexchange.com/questions/181070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59212/"
] | How can I add an input field to the admin section Users -> Add New?
I want to add a field for a phone number, but don't want a plugin to do that. | Okay found the answer by poking around the code
A field can be added by doing the following:
```
add_action('user_new_form','myplugin_add_field');
function myplugin_add_field() {
// code to add field
}
``` |
181,073 | <p>I'm trying to add the following hook into my functions.php file. The CSS style shows up when I view the source code but it also show the php code for the random background image generator. How can I get the php in that line to work within the hook?</p>
<p>Thanks</p>
<pre><code>add_action('wp_head','hook_css');
fun... | [
{
"answer_id": 181071,
"author": "Bird87 ZA",
"author_id": 59212,
"author_profile": "https://wordpress.stackexchange.com/users/59212",
"pm_score": 3,
"selected": true,
"text": "<p>Okay found the answer by poking around the code</p>\n\n<p>A field can be added by doing the following:</p>\n... | 2015/03/13 | [
"https://wordpress.stackexchange.com/questions/181073",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6787/"
] | I'm trying to add the following hook into my functions.php file. The CSS style shows up when I view the source code but it also show the php code for the random background image generator. How can I get the php in that line to work within the hook?
Thanks
```
add_action('wp_head','hook_css');
function hook_css()
{
... | Okay found the answer by poking around the code
A field can be added by doing the following:
```
add_action('user_new_form','myplugin_add_field');
function myplugin_add_field() {
// code to add field
}
``` |
181,086 | <p>for example, i had all ftp content (wordpress instalation php files) backup, and hacker got that backup file and looked into all php files(including config.php and etc) ... can he somehow access my wordpress site?<br>
remote database is disabled..</p>
| [
{
"answer_id": 181071,
"author": "Bird87 ZA",
"author_id": 59212,
"author_profile": "https://wordpress.stackexchange.com/users/59212",
"pm_score": 3,
"selected": true,
"text": "<p>Okay found the answer by poking around the code</p>\n\n<p>A field can be added by doing the following:</p>\n... | 2015/03/13 | [
"https://wordpress.stackexchange.com/questions/181086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33667/"
] | for example, i had all ftp content (wordpress instalation php files) backup, and hacker got that backup file and looked into all php files(including config.php and etc) ... can he somehow access my wordpress site?
remote database is disabled.. | Okay found the answer by poking around the code
A field can be added by doing the following:
```
add_action('user_new_form','myplugin_add_field');
function myplugin_add_field() {
// code to add field
}
``` |
181,108 | <p>I'm having trouble implementing a concurrent login check.</p>
<p>The site needs to prevent more than 5 concurrent sessions for any particular user at one time. </p>
<p><strong>Example:</strong>
User Matt can have 5 active sessions. </p>
<blockquote>
<p>If user Matt tries to login with a 6th session, it will rem... | [
{
"answer_id": 205107,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 4,
"selected": false,
"text": "<p>This question made me really interested. Took about 5 hours of my Saturday to create the full solution :) </p>\n\... | 2015/03/13 | [
"https://wordpress.stackexchange.com/questions/181108",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69034/"
] | I'm having trouble implementing a concurrent login check.
The site needs to prevent more than 5 concurrent sessions for any particular user at one time.
**Example:**
User Matt can have 5 active sessions.
>
> If user Matt tries to login with a 6th session, it will remove the session which logged in first & had no ... | This question made me really interested. Took about 5 hours of my Saturday to create the full solution :)
Plugin Limit Login Sessions
---------------------------
It doesn't provide a settings page yet, so all options are currently hard coded. The plugin implements the following (according to OP):
1. A user can have... |
181,111 | <p>Sometimes there's no way around creating a custom query, but when I do and then loop through it, I often want to use <code>get_template_part()</code> within the custom query loop to pull in a template I already know will fit my needs. Sometimes that template is 99.9% perfect and only needs some conditionals added fo... | [
{
"answer_id": 181120,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>First, <strong>don't use <code>is_main_query()</code> function</strong> (method is ok). It tells something absolute... | 2015/03/13 | [
"https://wordpress.stackexchange.com/questions/181111",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28957/"
] | Sometimes there's no way around creating a custom query, but when I do and then loop through it, I often want to use `get_template_part()` within the custom query loop to pull in a template I already know will fit my needs. Sometimes that template is 99.9% perfect and only needs some conditionals added for it to behave... | Thanks to Rarst's guidance I put together a quick solution that seems to do the trick even though it seems a bit hacky.
---
Solution:
**`page.php`**
--------------
```
<?php
$two_posts = new WP_Query(array(
'nopaging' => true,
'post_per_page' => -1,
'post_type' => 'post',
'post__in... |
181,122 | <p>I've been browsing through similar questions and have yet to get this functionality to work.
I'm tracking the progress a user makes an embedded vimeo video and insert data or update data.</p>
<p>JS on the post page:</p>
<pre><code> $.ajax({
type: 'POST',
dataType: 'json',
url: ajaxu... | [
{
"answer_id": 181137,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not entirely sure you want to call exit at the end of that function, since exit terminates all further PHP ex... | 2015/03/13 | [
"https://wordpress.stackexchange.com/questions/181122",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69034/"
] | I've been browsing through similar questions and have yet to get this functionality to work.
I'm tracking the progress a user makes an embedded vimeo video and insert data or update data.
JS on the post page:
```
$.ajax({
type: 'POST',
dataType: 'json',
url: ajaxurl,
data: {
... | I'm not entirely sure you want to call exit at the end of that function, since exit terminates all further PHP execution. This is likely the cause of your troubles.
<http://php.net/manual/en/function.exit.php>
That said, you can always test for the result of your queries by setting a variable to be the result, and th... |
181,134 | <p>I have just set up a post/parent relationship between a post type "episodes" and a post type "cartoon-series."</p>
<p>I used this bit of code to add in the meta box to assign the parent from another post type:</p>
<pre><code>add_action('admin_menu', function() {
remove_meta_box('pageparentdiv', 'episodes', 'no... | [
{
"answer_id": 181202,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": -1,
"selected": false,
"text": "<p>You will need to write your own URL parsing code for that as wordpress needs to know the type of the pos... | 2015/03/13 | [
"https://wordpress.stackexchange.com/questions/181134",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68905/"
] | I have just set up a post/parent relationship between a post type "episodes" and a post type "cartoon-series."
I used this bit of code to add in the meta box to assign the parent from another post type:
```
add_action('admin_menu', function() {
remove_meta_box('pageparentdiv', 'episodes', 'normal');
});
add_actio... | Finally I've found a working solution. The cartoon-series can be registered as you did but episodes custom post types can not be hirarchical (I think WordPress expects parent content be the same type as child content if the relationship is set using `post_parent` in `wp_posts` database table).
When registering episode... |
181,142 | <p>I have a post type <code>gtre</code> and metadata <code>price</code>.</p>
<p>The 'price' metadata I get using <code>get_post_meta($post->ID, 'key', true)["price"];</code></p>
<p>So I don´t know how exactly should I write the args for <code>WP_Query</code> constructor, so I can get the posts in order by the '<co... | [
{
"answer_id": 181144,
"author": "Brad Elsmore",
"author_id": 69036,
"author_profile": "https://wordpress.stackexchange.com/users/69036",
"pm_score": 1,
"selected": false,
"text": "<p>I have achieved this in the past by using the following method.</p>\n\n<pre><code>$paged = (get_query_va... | 2015/03/14 | [
"https://wordpress.stackexchange.com/questions/181142",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69044/"
] | I have a post type `gtre` and metadata `price`.
The 'price' metadata I get using `get_post_meta($post->ID, 'key', true)["price"];`
So I don´t know how exactly should I write the args for `WP_Query` constructor, so I can get the posts in order by the '`price`' meta data. I mean I want the query to ordered by '`price`'... | I have achieved this in the past by using the following method.
```
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'gtre',
'posts_per_page' => 6,
'paged' => $paged,
'meta_key' => 'price',
'orderby' => 'meta_value_num',
... |
181,153 | <p>How do I redirect this page URL, <code>http://localhost/wordpress_rnd/?page_id=2</code>, to the home URL, <code>http://localhost/wordpress_rnd/</code>, without using any plugins?</p>
| [
{
"answer_id": 181159,
"author": "cristian.raiber",
"author_id": 52524,
"author_profile": "https://wordpress.stackexchange.com/users/52524",
"pm_score": -1,
"selected": false,
"text": "<p>Locate page.php (assuming you've created it already). After this line <code><?php get_header(); ?... | 2015/03/14 | [
"https://wordpress.stackexchange.com/questions/181153",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51547/"
] | How do I redirect this page URL, `http://localhost/wordpress_rnd/?page_id=2`, to the home URL, `http://localhost/wordpress_rnd/`, without using any plugins? | The correct way to do this is using the [`template_redirect`](https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect) hook by adding a function to your `functions.php`:
```
function redirect_to_home() {
if(!is_admin() && is_page('2')) {
wp_redirect(home_url());
exit();
}
}
add_action('te... |
181,160 | <p>I'm trying to set up a woocommerce custom product type so that its as minimal as possible - no options I don't specifically designate. </p>
<p>Still, despite the declaration below, the custom product meta box still shows "shipping" shipping options. </p>
<p>How do I get rid of the shipping options? And on that not... | [
{
"answer_id": 181166,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 4,
"selected": true,
"text": "<p>Looking further into the WooCommerce source, they fortunately, provide a filter named <code>woocommerce_product_d... | 2015/03/14 | [
"https://wordpress.stackexchange.com/questions/181160",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57524/"
] | I'm trying to set up a woocommerce custom product type so that its as minimal as possible - no options I don't specifically designate.
Still, despite the declaration below, the custom product meta box still shows "shipping" shipping options.
How do I get rid of the shipping options? And on that note, any other that... | Looking further into the WooCommerce source, they fortunately, provide a filter named `woocommerce_product_data_tabs` which will allow you to conditional unset tabs.
I've provided an example below:
```
add_filter('woocommerce_product_data_tabs', function($tabs) {
/**
* The available tab array keys are:
... |
181,182 | <p>I have a category called <code>feature</code> which I use to have a feature post in the homepage. The problem is I don't want the category name <code>feature</code> to appear in this posts, but I want the other categories to show up.</p>
<p>How could I do that?</p>
| [
{
"answer_id": 181186,
"author": "Rahman Sharif",
"author_id": 24483,
"author_profile": "https://wordpress.stackexchange.com/users/24483",
"pm_score": 3,
"selected": true,
"text": "<p>To achieve this we need to use <code>get_the_category</code> <a href=\"http://codex.wordpress.org/Functi... | 2015/03/14 | [
"https://wordpress.stackexchange.com/questions/181182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24483/"
] | I have a category called `feature` which I use to have a feature post in the homepage. The problem is I don't want the category name `feature` to appear in this posts, but I want the other categories to show up.
How could I do that? | To achieve this we need to use `get_the_category` [here](http://codex.wordpress.org/Function_Reference/get_the_category).
I am going to use this code in several places, so it is more efficient to create a function
```
function exclude_cats($excludedcats = array()){
$categories = get_the_category();
$separato... |
181,185 | <p>I am new to wordpress & I am using a paid theme on my site <a href="http://www.freelancepulp.com" rel="nofollow">www.freelancepulp.com</a></p>
<p>I want to know how I can identify if a plugin is good suit for my theme or not? I had to remove all the plugins on my site because it crashed the theme & I was no... | [
{
"answer_id": 181186,
"author": "Rahman Sharif",
"author_id": 24483,
"author_profile": "https://wordpress.stackexchange.com/users/24483",
"pm_score": 3,
"selected": true,
"text": "<p>To achieve this we need to use <code>get_the_category</code> <a href=\"http://codex.wordpress.org/Functi... | 2015/03/14 | [
"https://wordpress.stackexchange.com/questions/181185",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69060/"
] | I am new to wordpress & I am using a paid theme on my site [www.freelancepulp.com](http://www.freelancepulp.com)
I want to know how I can identify if a plugin is good suit for my theme or not? I had to remove all the plugins on my site because it crashed the theme & I was not able to go into Admin panel last night....... | To achieve this we need to use `get_the_category` [here](http://codex.wordpress.org/Function_Reference/get_the_category).
I am going to use this code in several places, so it is more efficient to create a function
```
function exclude_cats($excludedcats = array()){
$categories = get_the_category();
$separato... |
181,203 | <p>I'm making shortcode and I'm stuck here. Here is code:</p>
<pre><code>add_shortcode('service-shortcode', 'service_shortcode');
function service_shortcode($atts)
{
extract( shortcode_atts( array(
'title' => 'Service One',
'icon' => 'fa-briefcase'
), $atts ));
$return_string = '';
$return_string ... | [
{
"answer_id": 181186,
"author": "Rahman Sharif",
"author_id": 24483,
"author_profile": "https://wordpress.stackexchange.com/users/24483",
"pm_score": 3,
"selected": true,
"text": "<p>To achieve this we need to use <code>get_the_category</code> <a href=\"http://codex.wordpress.org/Functi... | 2015/03/14 | [
"https://wordpress.stackexchange.com/questions/181203",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68179/"
] | I'm making shortcode and I'm stuck here. Here is code:
```
add_shortcode('service-shortcode', 'service_shortcode');
function service_shortcode($atts)
{
extract( shortcode_atts( array(
'title' => 'Service One',
'icon' => 'fa-briefcase'
), $atts ));
$return_string = '';
$return_string .= '<div class="serv... | To achieve this we need to use `get_the_category` [here](http://codex.wordpress.org/Function_Reference/get_the_category).
I am going to use this code in several places, so it is more efficient to create a function
```
function exclude_cats($excludedcats = array()){
$categories = get_the_category();
$separato... |
181,219 | <p>I'm trying to understand the difference between <a href="http://codex.wordpress.org/Function_Reference/get_site_option">get_site_option()</a> and <a href="http://codex.wordpress.org/Function_Reference/get_blog_option">get_blog_option()</a>.</p>
<p>Are <em>blog</em> and <em>site</em> two different things? Apologies ... | [
{
"answer_id": 181229,
"author": "kingkool68",
"author_id": 2744,
"author_profile": "https://wordpress.stackexchange.com/users/2744",
"pm_score": 3,
"selected": false,
"text": "<p><code>get_site_option()</code> - Gets a network wide option. This option is usually added in the Network Adm... | 2015/03/14 | [
"https://wordpress.stackexchange.com/questions/181219",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22599/"
] | I'm trying to understand the difference between [get\_site\_option()](http://codex.wordpress.org/Function_Reference/get_site_option) and [get\_blog\_option()](http://codex.wordpress.org/Function_Reference/get_blog_option).
Are *blog* and *site* two different things? Apologies if this question seems basic, but when ref... | [**`get_option()`**](https://developer.wordpress.org/reference/functions/get_option/) returns an option for the *current* blog.
In single site installation, the current blog is the only blog. So get `get_option()` returns the option for it.
---
[**`get_site_option()`**](https://developer.wordpress.org/reference/func... |
181,256 | <p>I have a basic custom query in WordPRess that loads all the users as shown in the following.</p>
<p><code>SELECT DISTINCT users.* FROM " . $wpdb->users . " as users</code></p>
<p>How do I modify it so that I can load users separately from each blog in multisite network? </p>
<p>Please let me know</p>
<p>Thanks</... | [
{
"answer_id": 181491,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Let me repeat what the comments are urging: Find a way to do this with the built in objects in WordPress.</p>\n\n... | 2015/03/15 | [
"https://wordpress.stackexchange.com/questions/181256",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48874/"
] | I have a basic custom query in WordPRess that loads all the users as shown in the following.
`SELECT DISTINCT users.* FROM " . $wpdb->users . " as users`
How do I modify it so that I can load users separately from each blog in multisite network?
Please let me know
Thanks | In following to my comments on the question the follow examples for a solution.
Default Function
----------------
WordPress have the function `get_users` to get all users for each site, works on single or multisite area. But to get all users from each site in Multisite network is the switch to each site important. Th... |
181,275 | <p>Consider this scenario: </p>
<p>I enqueued some scripts in my custom theme. Then I set off to building a plugin that I want to be used only with that one theme. I want to enqueue other scripts in my plugin that depend on scripts enqueued in the theme. The standard way of declaring script dependencies in wordpress i... | [
{
"answer_id": 181284,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": true,
"text": "<p>The simple answer is, \"No\". Although <code>admin_enqueue_scripts</code> and <code>wp_enqueue_scripts</... | 2015/03/15 | [
"https://wordpress.stackexchange.com/questions/181275",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60985/"
] | Consider this scenario:
I enqueued some scripts in my custom theme. Then I set off to building a plugin that I want to be used only with that one theme. I want to enqueue other scripts in my plugin that depend on scripts enqueued in the theme. The standard way of declaring script dependencies in wordpress is passing ... | The simple answer is, "No". Although `admin_enqueue_scripts` and `wp_enqueue_scripts` hooks does exactly the same thing, the do their work in separate places which do not have any reference to the other.
* `wp_enqueue_scripts` runs on the public side or front end
* `admin_enqueue_scripts` As the name suggests, it runs... |
181,291 | <p>I have category_id=3 and have 10 post in category_id=3 with post_id= 1=>10</p>
<p>How to show list post category_id=3 with no post_id=1,3,5 value as </p>
<pre><code>query_posts('cat=3& -p=1,3,5 &showposts=30
</code></pre>
| [
{
"answer_id": 181292,
"author": "grandcoder",
"author_id": 69121,
"author_profile": "https://wordpress.stackexchange.com/users/69121",
"pm_score": 2,
"selected": true,
"text": "<p>If you are trying to omit posts 1,3,5 from category 3 on your blog, you can use the following code</p>\n\n<... | 2015/03/16 | [
"https://wordpress.stackexchange.com/questions/181291",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65359/"
] | I have category\_id=3 and have 10 post in category\_id=3 with post\_id= 1=>10
How to show list post category\_id=3 with no post\_id=1,3,5 value as
```
query_posts('cat=3& -p=1,3,5 &showposts=30
``` | If you are trying to omit posts 1,3,5 from category 3 on your blog, you can use the following code
```
$query = new WP_Query( array('cat' => 3, 'post_type' => 'post', 'post__not_in' => array(1,3,5) ) );
```
The query results will not show posts with ids 1,3,5 of category 3. |
181,297 | <p>So, where is the searchresult page sidebar located?</p>
<p>For example, in the searchresult page, there is "A" sidebar.</p>
<p>However, I want to change it to "B" sidebar.</p>
<p>I looked at <code>search.php</code> but could not understand where the sidebar was coming from.</p>
| [
{
"answer_id": 181298,
"author": "grandcoder",
"author_id": 69121,
"author_profile": "https://wordpress.stackexchange.com/users/69121",
"pm_score": 1,
"selected": true,
"text": "<p>Your search.php may contain the following code</p>\n\n<pre><code><?php get_sidebar(); ?>\n</code></pr... | 2015/03/16 | [
"https://wordpress.stackexchange.com/questions/181297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67604/"
] | So, where is the searchresult page sidebar located?
For example, in the searchresult page, there is "A" sidebar.
However, I want to change it to "B" sidebar.
I looked at `search.php` but could not understand where the sidebar was coming from. | Your search.php may contain the following code
```
<?php get_sidebar(); ?>
```
If a name ($name) is specified as an argument then a specialized sidebar sidebar-{name}.php will be included. If sidebar-{name}.php does not exist, then it will fallback to loading sidebar.php.
If the theme contains no sidebar.php file t... |
181,301 | <p>I am building a wordpress website with drop down menu (sub menu).</p>
<p><img src="https://i.stack.imgur.com/4F667.png" alt="enter image description here"></p>
<p>To achieve this here I am using wordpress <strong>walker</strong> class. This is the code which I am using in my <strong>functions.php</strong></p>
<pr... | [
{
"answer_id": 181305,
"author": "ucon89",
"author_id": 44538,
"author_profile": "https://wordpress.stackexchange.com/users/44538",
"pm_score": 0,
"selected": false,
"text": "<p>@raunak how about use jQuery <code>jQuery(\" ul li .menu-item\").removeClass( \"current\" );</code> for adding... | 2015/03/16 | [
"https://wordpress.stackexchange.com/questions/181301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62377/"
] | I am building a wordpress website with drop down menu (sub menu).

To achieve this here I am using wordpress **walker** class. This is the code which I am using in my **functions.php**
```
class CSS_Menu_Maker_Walker extends Walker {
var $db_fiel... | Use following code as jQuery:
```
jQuery('#nav li').removeClass('current');
jQuery('#nav>li.current-menu-item').addClass('current');
jQuery('.has-children li.current-menu-item').closest('.has-children').addClass('current');
```
See jsfiddle (current item red color). When you click "Single Blog" menu item your html s... |
181,326 | <p>Speaking about backoffice here.</p>
<p>I usually add columns and filters to the backoffice for certain custom post types. No problem here. BUt what if I would simply like to change something on the content of the default columns? For example, how to change the color of the post titles?
And say, only some titles on ... | [
{
"answer_id": 181330,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>CSS is the answer. If you look at the HTML code of each row (<code><tr></code>), you will see that it h... | 2015/03/16 | [
"https://wordpress.stackexchange.com/questions/181326",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10381/"
] | Speaking about backoffice here.
I usually add columns and filters to the backoffice for certain custom post types. No problem here. BUt what if I would simply like to change something on the content of the default columns? For example, how to change the color of the post titles?
And say, only some titles on a list, fo... | CSS is the answer. If you look at the HTML code of each row (`<tr>`), you will see that it has classes that include post ID, post status, post tags, categories, and so on. So, you can easily apply CSS rules based on that classes and based on post tags.
For example, this is a row in one of my site:
```
<tr id="post-24... |
181,342 | <p>I'm renting a server from <a href="http://digitalocean.com/" rel="nofollow noreferrer">DigitalOcean</a> on which I'm running Wordpress inside apache on port 8079. DigitalOcean also only allows one to connect via SFTP. Currently the client I use to do that is <a href="http://panic.com/transmit/" rel="nofollow norefer... | [
{
"answer_id": 181330,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>CSS is the answer. If you look at the HTML code of each row (<code><tr></code>), you will see that it h... | 2015/03/16 | [
"https://wordpress.stackexchange.com/questions/181342",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69150/"
] | I'm renting a server from [DigitalOcean](http://digitalocean.com/) on which I'm running Wordpress inside apache on port 8079. DigitalOcean also only allows one to connect via SFTP. Currently the client I use to do that is [Transmit](http://panic.com/transmit/) . My details for that is like follow:
![enter image descri... | CSS is the answer. If you look at the HTML code of each row (`<tr>`), you will see that it has classes that include post ID, post status, post tags, categories, and so on. So, you can easily apply CSS rules based on that classes and based on post tags.
For example, this is a row in one of my site:
```
<tr id="post-24... |
181,354 | <p>I am trying to use ajax in wordpress
I have two comboboxes in single-meetings.php
the second combobox values are based on selection from the first one</p>
<p>here is my <code>single-meetings.php</code></p>
<pre><code><form action="#" name="form" id="form" method="post">
<div id="check-in-date-wrap">
&l... | [
{
"answer_id": 181330,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>CSS is the answer. If you look at the HTML code of each row (<code><tr></code>), you will see that it h... | 2015/03/16 | [
"https://wordpress.stackexchange.com/questions/181354",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68426/"
] | I am trying to use ajax in wordpress
I have two comboboxes in single-meetings.php
the second combobox values are based on selection from the first one
here is my `single-meetings.php`
```
<form action="#" name="form" id="form" method="post">
<div id="check-in-date-wrap">
<select name="search_category" id="check-in-d... | CSS is the answer. If you look at the HTML code of each row (`<tr>`), you will see that it has classes that include post ID, post status, post tags, categories, and so on. So, you can easily apply CSS rules based on that classes and based on post tags.
For example, this is a row in one of my site:
```
<tr id="post-24... |
181,376 | <p>I am trying to pull images as attachments from a particular post (custom post),</p>
<p>...and I'm using the example within WordPress codex <a href="http://codex.wordpress.org/Function_Reference/wp_get_attachment_image#Display_all_images_as_a_list" rel="nofollow">codex example to display all images as a list</a></p>... | [
{
"answer_id": 181330,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>CSS is the answer. If you look at the HTML code of each row (<code><tr></code>), you will see that it h... | 2015/03/16 | [
"https://wordpress.stackexchange.com/questions/181376",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54520/"
] | I am trying to pull images as attachments from a particular post (custom post),
...and I'm using the example within WordPress codex [codex example to display all images as a list](http://codex.wordpress.org/Function_Reference/wp_get_attachment_image#Display_all_images_as_a_list)
...except the images in that post keep... | CSS is the answer. If you look at the HTML code of each row (`<tr>`), you will see that it has classes that include post ID, post status, post tags, categories, and so on. So, you can easily apply CSS rules based on that classes and based on post tags.
For example, this is a row in one of my site:
```
<tr id="post-24... |
181,381 | <p>I have the following query but it is still returning results which include posts which have a meta value of 'deal'.</p>
<p>Any Clues on what am i missing in this </p>
<pre><code> $args = array(
'post_type' => POST_TYPE,
'meta_key' => 'is_hot',
'meta_value' => '1',
'meta_compare' => '... | [
{
"answer_id": 181384,
"author": "grandcoder",
"author_id": 69121,
"author_profile": "https://wordpress.stackexchange.com/users/69121",
"pm_score": 1,
"selected": false,
"text": "<p><code>meta_compare</code> possible values are </p>\n\n<blockquote>\n <p>'!=', '>', '>=', '<', or ='. D... | 2015/03/17 | [
"https://wordpress.stackexchange.com/questions/181381",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52047/"
] | I have the following query but it is still returning results which include posts which have a meta value of 'deal'.
Any Clues on what am i missing in this
```
$args = array(
'post_type' => POST_TYPE,
'meta_key' => 'is_hot',
'meta_value' => '1',
'meta_compare' => '=',
'posts_per_page' => 20,
... | You can not query for multiple meta fields using `meta_key` and `meta_value` parameters, you have to use `meta_query` parameter. Using multiple `meta_key` and `meta_value` parameters will use only the first found pair, that is why in your code the condition about "offer\_type NOT LIKE deal" is ignored.
So, the correct... |
181,386 | <p>My primary website on a multisite network was created with the <code>www</code> prefix (like <code>www.example.com</code>).</p>
<p>If I try to access pages without the <code>www</code> prefix (like <code>example.com/page-name/</code> instead of <code>www.example.com/page-name/</code>, I am redirected to the homepag... | [
{
"answer_id": 181401,
"author": "Shreyo Gi",
"author_id": 65741,
"author_profile": "https://wordpress.stackexchange.com/users/65741",
"pm_score": 0,
"selected": false,
"text": "<p>check your <code>.htaccess</code> for </p>\n\n<p><code><IfModule mod_rewrite.c>\nRewriteEngine On\nRe... | 2015/03/17 | [
"https://wordpress.stackexchange.com/questions/181386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23036/"
] | My primary website on a multisite network was created with the `www` prefix (like `www.example.com`).
If I try to access pages without the `www` prefix (like `example.com/page-name/` instead of `www.example.com/page-name/`, I am redirected to the homepage (`www.example.com`). I would like to change this so I am redire... | There is currently a bug in the functionality that handles the `NOBLOGREDIRECT` constant, which causes 404 errors on the main site to be redirected to the value of the constant. Apparently this is the expected behaviour for sub-directory networks (`example.com/subsite`), but should not take place on subdomain networks ... |
181,394 | <p>I an creating a custom plugin that used shortcodes.. then it will have a feature that will upload files and stores it in <code>wp-content/uploads/</code> directory.. but it seems I got an error..</p>
<pre><code>Warning: move_uploaded_file(http://mysitecom/wp-content/uploads/myfiles/1991117- DriverLiscence.jpg): fai... | [
{
"answer_id": 181395,
"author": "grandcoder",
"author_id": 69121,
"author_profile": "https://wordpress.stackexchange.com/users/69121",
"pm_score": 0,
"selected": false,
"text": "<p>You cannot move a file over HTTP, instead you need to move it using local path.</p>\n\n<pre><code>(e.g. /h... | 2015/03/17 | [
"https://wordpress.stackexchange.com/questions/181394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68933/"
] | I an creating a custom plugin that used shortcodes.. then it will have a feature that will upload files and stores it in `wp-content/uploads/` directory.. but it seems I got an error..
```
Warning: move_uploaded_file(http://mysitecom/wp-content/uploads/myfiles/1991117- DriverLiscence.jpg): failed to open stream: HTTP ... | Use Wordpress defult media uploader and get uploaded link in jquery response it is quit easy
```
<label for="upload_image">
<input id="upload_image" type="text" size="36" name="ad_image" value="http://" />
<input id="upload_image_button" class="button" type="button" value="Upload Image" />
<br />Enter a ... |
181,452 | <p>I am working with redux framework and need to save theme option values to a file right before it is saved in DB.
Is there a way to intercept</p>
<pre><code>update_option()
</code></pre>
<p>right before it saves data in DB?</p>
| [
{
"answer_id": 181455,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>There is a filter exactly for that: <code>pre_update_option_{option_name}</code>. If the is option is, for ex... | 2015/03/17 | [
"https://wordpress.stackexchange.com/questions/181452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67176/"
] | I am working with redux framework and need to save theme option values to a file right before it is saved in DB.
Is there a way to intercept
```
update_option()
```
right before it saves data in DB? | You might be better off using the `update_option_` action instead. This will allow you to write to your file after the option has been updated (as apposed to before). If another plugin hooks into pre\_update\_option\_ and alters the value after your plugin has saved it then you will have saved an incorrect value.
I wo... |
181,454 | <p>I have a working Lightbox (colorbox) solution for my wordpress images. However I would like to add a custom title based on the image caption and photographer name to the lightbox image. </p>
<p>This works perfectly when adding a title attribute to the image link.</p>
<p>However, how do I add the image caption to t... | [
{
"answer_id": 181455,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>There is a filter exactly for that: <code>pre_update_option_{option_name}</code>. If the is option is, for ex... | 2015/03/17 | [
"https://wordpress.stackexchange.com/questions/181454",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65287/"
] | I have a working Lightbox (colorbox) solution for my wordpress images. However I would like to add a custom title based on the image caption and photographer name to the lightbox image.
This works perfectly when adding a title attribute to the image link.
However, how do I add the image caption to the image link.
... | You might be better off using the `update_option_` action instead. This will allow you to write to your file after the option has been updated (as apposed to before). If another plugin hooks into pre\_update\_option\_ and alters the value after your plugin has saved it then you will have saved an incorrect value.
I wo... |
181,496 | <p>My function lets users delete their uploaded images in the front-end. However, they're only deleted in the Media Library. That means that they're still in wp-content/uploads/.</p>
<pre><code>public static function removePhoto($ID, $attachment) {
if(isset(self::$data['user']['photos'][$attachment])) {
unset(sel... | [
{
"answer_id": 181518,
"author": "DiverseAndRemote.com",
"author_id": 23690,
"author_profile": "https://wordpress.stackexchange.com/users/23690",
"pm_score": 0,
"selected": false,
"text": "<p>You need to provide <a href=\"http://codex.wordpress.org/Function_Reference/wp_delete_attachment... | 2015/03/17 | [
"https://wordpress.stackexchange.com/questions/181496",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45127/"
] | My function lets users delete their uploaded images in the front-end. However, they're only deleted in the Media Library. That means that they're still in wp-content/uploads/.
```
public static function removePhoto($ID, $attachment) {
if(isset(self::$data['user']['photos'][$attachment])) {
unset(self::$data['use... | For future reference, if your attachment gets deleted but not your files
There is a filter `wp_delete_file`, check if this filter is hooked on somewhere, if it returns `null` your file won't be deleted but the attachment will
For me it was due to the WPML plugin, they duplicate attachments and then checks that all th... |
181,509 | <p>I would like to remove index.php from my permalink.
I am using Codeigniter website.
I have passed the requirements to use pretty permalink:<BR>
<strong>-PHP Version 5.4.27 Codeigniter <BR>
-IIS 7.5<BR>
-URL Rewrite 2.0<BR>
-Server API: FAST CGI<BR></strong></p>
<p>Before, I have removed index.php from codeigniter. ... | [
{
"answer_id": 220810,
"author": "xyonme",
"author_id": 69220,
"author_profile": "https://wordpress.stackexchange.com/users/69220",
"pm_score": 2,
"selected": false,
"text": "<p>After struggling for a while in the web.config structure. I found out we need to clear the rule before to add ... | 2015/03/18 | [
"https://wordpress.stackexchange.com/questions/181509",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69220/"
] | I would like to remove index.php from my permalink.
I am using Codeigniter website.
I have passed the requirements to use pretty permalink:
**-PHP Version 5.4.27 Codeigniter
-IIS 7.5
-URL Rewrite 2.0
-Server API: FAST CGI**
Before, I have removed index.php from codeigniter.
I wonder if wordpress webconfi... | After struggling for a while in the web.config structure. I found out we need to clear the rule before to add another rule. Just add tag `</clear>`
```
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear/>
<rule name="wordpress" patternSyntax="Wildcard">
... |
181,529 | <p>simple question, how to get all tags of a custom post type by id? post_type=product. </p>
<p>i have tried with <a href="http://codex.wordpress.org/Function_Reference/wp_get_post_tags" rel="nofollow">http://codex.wordpress.org/Function_Reference/wp_get_post_tags</a> in my post loop and the print_r returning me nothi... | [
{
"answer_id": 207497,
"author": "Ahmad",
"author_id": 82951,
"author_profile": "https://wordpress.stackexchange.com/users/82951",
"pm_score": -1,
"selected": false,
"text": "<pre><code>global $post;\n$tags = wp_get_post_tags( $post->ID );\nif ( $tags ) {\n foreach ( $tags as $tag ... | 2015/03/18 | [
"https://wordpress.stackexchange.com/questions/181529",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69017/"
] | simple question, how to get all tags of a custom post type by id? post\_type=product.
i have tried with <http://codex.wordpress.org/Function_Reference/wp_get_post_tags> in my post loop and the print\_r returning me nothing.
hence i tried this,
```
$term_list = wp_get_post_terms($post->ID, 'product_tag', array("fiel... | Loop approach: usually archive-{custom\_post}.php file.
**FIRST**:
*custom\_post\_plural* Stands for a group of custom posts of certain type.
Example of custom\_post\_plural: **products**
*custom\_post\_singular* Stands for an individual custom post type.
Example of custom\_post\_singular: **product**
**SECOND**:... |