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
139,072
<p>I am building a website for a client of mine who would like the ability to make minor layout changes themselves. Because of this I am coding some of the layout directly into pages using the text editor. The problem I am facing is dynamically including an image from the template directory into the posts/pages.</p> <...
[ { "answer_id": 139101, "author": "Monkey Puzzle", "author_id": 48568, "author_profile": "https://wordpress.stackexchange.com/users/48568", "pm_score": 0, "selected": false, "text": "<p>It's not super clear to me what you are trying to do (and why)... but you know you can change the Media...
2014/03/24
[ "https://wordpress.stackexchange.com/questions/139072", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13286/" ]
I am building a website for a client of mine who would like the ability to make minor layout changes themselves. Because of this I am coding some of the layout directly into pages using the text editor. The problem I am facing is dynamically including an image from the template directory into the posts/pages. Normally...
I realize that this was posted about 7 months ago, but in case you're still looking for a solution to this, add this to your `functions.php` file: ``` /** * Add a shortcode for the current theme directory * @return string Current theme directory */ function yourtheme_get_theme_directory_uri() { return get_templ...
139,096
<p>Ok, so I've created a short code which echo's some of the output; the problem I discovered is that the values must be returned instead of echo'd. I'm having problems converting the shortcode to return the date instead..</p> <p>I've tried and it breaks my shortcode.. </p> <p>What would this shortcode code look like...
[ { "answer_id": 139097, "author": "Shazzad", "author_id": 42967, "author_profile": "https://wordpress.stackexchange.com/users/42967", "pm_score": 0, "selected": false, "text": "<p>The easiest way is to use buffering. You might have already used <a href=\"http://php.net/ob_start\" rel=\"no...
2014/03/25
[ "https://wordpress.stackexchange.com/questions/139096", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31784/" ]
Ok, so I've created a short code which echo's some of the output; the problem I discovered is that the values must be returned instead of echo'd. I'm having problems converting the shortcode to return the date instead.. I've tried and it breaks my shortcode.. What would this shortcode code look like if it returned t...
Just define a variable, and concat all html as string and return it. ``` <?php function services_shortcode( $atts ) { // Attributes extract( shortcode_atts( array( 'slug' => '', ), $atts ) ); $html=''; if ( isset( $slug ) ) { $args = array( 'post_type' => 'cbd_services', 'n...
139,120
<p>This is a business site with product images.</p> <p>I have a multisite installation with 3 languages in 3 directories which will later be mapped to completely separate domains by the host when it's finished.</p> <p>The media (EDIT: in one of the sites) currently consists almost completely of large images (EDIT: to...
[ { "answer_id": 139097, "author": "Shazzad", "author_id": 42967, "author_profile": "https://wordpress.stackexchange.com/users/42967", "pm_score": 0, "selected": false, "text": "<p>The easiest way is to use buffering. You might have already used <a href=\"http://php.net/ob_start\" rel=\"no...
2014/03/25
[ "https://wordpress.stackexchange.com/questions/139120", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24829/" ]
This is a business site with product images. I have a multisite installation with 3 languages in 3 directories which will later be mapped to completely separate domains by the host when it's finished. The media (EDIT: in one of the sites) currently consists almost completely of large images (EDIT: total 1.8GB) that a...
Just define a variable, and concat all html as string and return it. ``` <?php function services_shortcode( $atts ) { // Attributes extract( shortcode_atts( array( 'slug' => '', ), $atts ) ); $html=''; if ( isset( $slug ) ) { $args = array( 'post_type' => 'cbd_services', 'n...
139,128
<p>In recent versions <code>WP_UnitTestCase</code> has included a <code>$factory</code> property. </p> <p>For example:</p> <pre><code>$post = $this-&gt;factory-&gt;post-&gt;create(); </code></pre> <p>Where can I find documentation on this useful feature?</p>
[ { "answer_id": 139130, "author": "djb", "author_id": 7905, "author_profile": "https://wordpress.stackexchange.com/users/7905", "pm_score": 2, "selected": false, "text": "<p>The source code at </p>\n\n<p><a href=\"https://github.com/rnagle/wordpress-unit-tests/blob/master/includes/factory...
2014/03/25
[ "https://wordpress.stackexchange.com/questions/139128", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7905/" ]
In recent versions `WP_UnitTestCase` has included a `$factory` property. For example: ``` $post = $this->factory->post->create(); ``` Where can I find documentation on this useful feature?
As far as I know, there is no documentation for it at present. The [official source is here](https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/factory.php). I have also written a tutorial on unit testing WordPress plugins, [which gives some detail about this feature](http://codesymphony.co/writing-w...
139,131
<p>I have a Meteor app that I want to add Wordpress blogging platform to.</p> <p>There doesn't need to be any integration, just:</p> <p><a href="http://example.com/blog/" rel="nofollow">http://example.com/blog/</a></p> <p>Anything behind <code>blog/</code> belongs to WP.</p> <p>How would I go about doing this? Than...
[ { "answer_id": 139169, "author": "David Kryzaniak", "author_id": 31548, "author_profile": "https://wordpress.stackexchange.com/users/31548", "pm_score": 0, "selected": false, "text": "<p>This is going to be quite difficult since Meteor JS is running on Node.js and MongoDB. WordPress requ...
2014/03/25
[ "https://wordpress.stackexchange.com/questions/139131", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49559/" ]
I have a Meteor app that I want to add Wordpress blogging platform to. There doesn't need to be any integration, just: <http://example.com/blog/> Anything behind `blog/` belongs to WP. How would I go about doing this? Thanks in advance.
This question is probably beyond the scope of WPSE. But my solution would be to install PHP-FPM and run Node and PHP-FPM on different ports behind Nginx. Sample Nginx Config (will require tweaking) ``` location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forward...
139,132
<p>I installed WordPress in the subdiretory <code>/de</code> and activated multisite features. The main blog has the URL/path: <code>mysite.de/de</code></p> <p>Now I want to add a second site for the English language with the following url: <code>mysite.de/en</code></p> <p>But after I added the site, the subdirectory...
[ { "answer_id": 139134, "author": "Sam", "author_id": 37548, "author_profile": "https://wordpress.stackexchange.com/users/37548", "pm_score": 0, "selected": false, "text": "<p>It would be far easier to maintain the blog by using a good WordPress translation plugin. </p>\n\n<p>WPML (<a hre...
2014/03/25
[ "https://wordpress.stackexchange.com/questions/139132", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49454/" ]
I installed WordPress in the subdiretory `/de` and activated multisite features. The main blog has the URL/path: `mysite.de/de` Now I want to add a second site for the English language with the following url: `mysite.de/en` But after I added the site, the subdirectory for the English site was set as: `mysite.de/de/e...
Here's a proper multisite solution: **Install WordPress** directly on the root of your domain `mysite.de`. After that, setup a multisite and chose the **subdomain** option (Yes, subdomain! It's far more flexible and you can use it with subdirectories as well). WordPress will ask you to update `wp-config.php` and `.ht...
139,163
<p>How is it possible to add a custom button to the visual editor TinyMCE, <strong>Version 4</strong>?</p> <p>Currently I found <a href="https://wordpress.stackexchange.com/questions/138167/how-to-use-the-new-dashicons-for-custom-tinymce-buttons">this q&amp;a</a> with a little bit hints to the topic, but not a solutio...
[ { "answer_id": 139164, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 6, "selected": true, "text": "<p>The following small plugin creates a custom button inside line 1 of the WordPress TinyMCE Version 4, tested in WP ...
2014/03/25
[ "https://wordpress.stackexchange.com/questions/139163", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170/" ]
How is it possible to add a custom button to the visual editor TinyMCE, **Version 4**? Currently I found [this q&a](https://wordpress.stackexchange.com/questions/138167/how-to-use-the-new-dashicons-for-custom-tinymce-buttons) with a little bit hints to the topic, but not a solution or a how to. But I can't find a tuto...
The following small plugin creates a custom button inside line 1 of the WordPress TinyMCE Version 4, tested in WP Version 3.9-beta2. The plugin has `var_dump` included to understand the values. It's also possible to add the button to other lines of the visual editor, only a other hook, like for line 2: `mce_buttons_2`...
139,173
<p>I've added some custom fields to my search form, which will be used more frequently than the original text field (<code>&lt;input name="s" /&gt;</code>). However, the text field seems to be required to perform a search, and an empty value isn't enough.</p> <p>Valid: <code>http://www.example.com/?s=foobar&amp;max_pr...
[ { "answer_id": 139164, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 6, "selected": true, "text": "<p>The following small plugin creates a custom button inside line 1 of the WordPress TinyMCE Version 4, tested in WP ...
2014/03/25
[ "https://wordpress.stackexchange.com/questions/139173", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27246/" ]
I've added some custom fields to my search form, which will be used more frequently than the original text field (`<input name="s" />`). However, the text field seems to be required to perform a search, and an empty value isn't enough. Valid: `http://www.example.com/?s=foobar&max_price=500` Invalid: `http://www.examp...
The following small plugin creates a custom button inside line 1 of the WordPress TinyMCE Version 4, tested in WP Version 3.9-beta2. The plugin has `var_dump` included to understand the values. It's also possible to add the button to other lines of the visual editor, only a other hook, like for line 2: `mce_buttons_2`...
139,216
<p>In localhost this code works fine to display images from my media gallery but when my site goes live $images are empty although there are images in the media gallery.<br> Are there something I've missed out?</p> <pre><code>$images =&amp; get_children( 'post_type=attachment&amp;post_mime_type=image' ); if ( empty($...
[ { "answer_id": 139164, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 6, "selected": true, "text": "<p>The following small plugin creates a custom button inside line 1 of the WordPress TinyMCE Version 4, tested in WP ...
2014/03/16
[ "https://wordpress.stackexchange.com/questions/139216", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
In localhost this code works fine to display images from my media gallery but when my site goes live $images are empty although there are images in the media gallery. Are there something I've missed out? ``` $images =& get_children( 'post_type=attachment&post_mime_type=image' ); if ( empty($images) ) { echo "Th...
The following small plugin creates a custom button inside line 1 of the WordPress TinyMCE Version 4, tested in WP Version 3.9-beta2. The plugin has `var_dump` included to understand the values. It's also possible to add the button to other lines of the visual editor, only a other hook, like for line 2: `mce_buttons_2`...
139,221
<p>I have a custom post "review". It uses the same categories and tags from default posts, so they share "category" and "tag" taxonomies.</p> <p>But later I changed the "review" register to have their own taxonomies, "review-category", and "review-tag". Of course all tags and categories previously assigned on reviews ...
[ { "answer_id": 139241, "author": "Dharmang", "author_id": 49270, "author_profile": "https://wordpress.stackexchange.com/users/49270", "pm_score": 2, "selected": true, "text": "<p>You will need to join four tables to get categories of custom post type \"review\"</p>\n\n<ol>\n<li>wp_term_r...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139221", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31885/" ]
I have a custom post "review". It uses the same categories and tags from default posts, so they share "category" and "tag" taxonomies. But later I changed the "review" register to have their own taxonomies, "review-category", and "review-tag". Of course all tags and categories previously assigned on reviews was unbind...
You will need to join four tables to get categories of custom post type "review" 1. wp\_term\_relationships 2. wp\_posts 3. wp\_term\_taxonomy 4. wp\_terms by using following query you can get list of categories applied to your custom post type: ``` SELECT * FROM wp_term_relationships AS tr LEFT JOIN wp_posts AS p O...
139,230
<p>This is the shortcode I have come up with, according to a tutorial on Dig WP (<a href="http://digwp.com/2010/01/custom-query-shortcode/" rel="nofollow">http://digwp.com/2010/01/custom-query-shortcode/</a>) in order to display list of songs on specific albums.</p> <pre><code>[loop the_query="post_type=song&amp;album...
[ { "answer_id": 139241, "author": "Dharmang", "author_id": 49270, "author_profile": "https://wordpress.stackexchange.com/users/49270", "pm_score": 2, "selected": true, "text": "<p>You will need to join four tables to get categories of custom post type \"review\"</p>\n\n<ol>\n<li>wp_term_r...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139230", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21224/" ]
This is the shortcode I have come up with, according to a tutorial on Dig WP (<http://digwp.com/2010/01/custom-query-shortcode/>) in order to display list of songs on specific albums. ``` [loop the_query="post_type=song&albumtype=enc&order=ASC&showposts=-1"] ``` Above is an example, using a custom taxonomy in order ...
You will need to join four tables to get categories of custom post type "review" 1. wp\_term\_relationships 2. wp\_posts 3. wp\_term\_taxonomy 4. wp\_terms by using following query you can get list of categories applied to your custom post type: ``` SELECT * FROM wp_term_relationships AS tr LEFT JOIN wp_posts AS p O...
139,243
<p>I've got the following example code, which creates a custom field and adds to the attachment meta:</p> <pre><code>function be_attachment_field_credit( $form_fields, $post ) { $form_fields['be-photographer-name'] = array( 'label' =&gt; 'Photographer Name', 'input' =&gt; 'text', 'value' =&...
[ { "answer_id": 139273, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>\"Attachments\" aren't meta data. That is why you can't retrieve them with <code>get_post_meta()</code>. \"A...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139243", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33541/" ]
I've got the following example code, which creates a custom field and adds to the attachment meta: ``` function be_attachment_field_credit( $form_fields, $post ) { $form_fields['be-photographer-name'] = array( 'label' => 'Photographer Name', 'input' => 'text', 'value' => get_post_meta( $pos...
"Attachments" aren't meta data. That is why you can't retrieve them with `get_post_meta()`. "Attachments" are a post type that is attached to the parent post. You need to [pull the attachment posts that have you post set as parent](http://codex.wordpress.org/Function_Reference/get_children), and then use those `ID`s to...
139,245
<p>Today i setup wordpress with nginx. The problem, i cant figure out, is that some pages will be served as expected and some other will be served as download. If i download them, the content is the sama as index.php in wordpress root folder. I tried to find some differences between the "normal" pages and the other def...
[ { "answer_id": 256276, "author": "Mike Rouse", "author_id": 72917, "author_profile": "https://wordpress.stackexchange.com/users/72917", "pm_score": 1, "selected": false, "text": "<p>In my case the fix was:</p>\n\n<ol>\n<li>Purge cache in Cloudflare</li>\n<li>Clear cache in Google Chrome<...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139245", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49498/" ]
Today i setup wordpress with nginx. The problem, i cant figure out, is that some pages will be served as expected and some other will be served as download. If i download them, the content is the sama as index.php in wordpress root folder. I tried to find some differences between the "normal" pages and the other defect...
In my case the fix was: 1. Purge cache in Cloudflare 2. Clear cache in Google Chrome
139,261
<p>So I have 4 widgets which is in large-3 columns, when they're not active I place a placeholder as user guide so the user would know where to put what.</p> <p>I did manage to work out the is_active but it turns out to be a long code, I was wondering if there is a way to shorten it.</p> <p>Widgets from available-cou...
[ { "answer_id": 139266, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p><code>is_active_sidebar</code> has a single value, whether it is the sideabar id or name. If you have m...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139261", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49506/" ]
So I have 4 widgets which is in large-3 columns, when they're not active I place a placeholder as user guide so the user would know where to put what. I did manage to work out the is\_active but it turns out to be a long code, I was wondering if there is a way to shorten it. Widgets from available-course-list-1 to -4...
`is_active_sidebar` has a single value, whether it is the sideabar id or name. If you have more than one sidebar, you should repeat `is_active_sidebar`, each one with a specific sidebar id or name. You would do something like this ``` <?php if ( is_active_sidebar( 'available-course-list-1' ) && is_active_sidebar( 'a...
139,265
<p>if I just type something to provoke a 404 Error on my Wordpress installation, Wordpress doesn't load its own 404.php file, but the Apache server's own 404 error message gets displayed. </p> <h2>What is wrong with my Wordpress installation? Do I need to edit the Apache server's config file and redirect to the Wordpr...
[ { "answer_id": 139268, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 3, "selected": false, "text": "<p>WordPress will only handle 404's if pretty permalinks are enabled - go to Settings > Permalinks and choose...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139265", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49507/" ]
if I just type something to provoke a 404 Error on my Wordpress installation, Wordpress doesn't load its own 404.php file, but the Apache server's own 404 error message gets displayed. What is wrong with my Wordpress installation? Do I need to edit the Apache server's config file and redirect to the Wordpress 404.php...
Things are working the way they are supposed to, and possibly the only way they *can* work. Let me explain. Without an Apache module called [`mod_rewrite`](http://httpd.apache.org/docs/current/mod/mod_rewrite.html) (or the equivalent Nginx or IIS component) requests to PHP pages have to go to an actual filesystem file...
139,269
<p>I am trying to change the checkboxes for the terms on the backend to radiobuttons. I found this topic: <a href="https://wordpress.stackexchange.com/questions/7456/altering-the-appearance-of-custom-taxonomy-inputs">Altering the appearance of custom taxonomy inputs</a> however wich helped me doing this. However, this ...
[ { "answer_id": 139277, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 5, "selected": true, "text": "<blockquote>\n <p>However, this will turn ALL terms checkboxes to radio buttons.</p>\n</blockquote>\n\n<p>Not...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139269", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34616/" ]
I am trying to change the checkboxes for the terms on the backend to radiobuttons. I found this topic: [Altering the appearance of custom taxonomy inputs](https://wordpress.stackexchange.com/questions/7456/altering-the-appearance-of-custom-taxonomy-inputs) however wich helped me doing this. However, this will turn ALL ...
> > However, this will turn ALL terms checkboxes to radio buttons. > > > Not only that, it'll turn *any* checkbox in a meta box - not ideal! Instead, let's specifically target the `wp_terms_checklist()` function, which is used to generate the list of checkboxes across the admin (including quick edit). ``` /** *...
139,289
<p>I have been stuck on a particular problem for a while now and have yet to find a way around it. I have custom widgets and for each widget I have added the ability to filter posts based on category AND/OR tags (this functionality works). I am now trying to expand on that by including in each widget a custom field whe...
[ { "answer_id": 139420, "author": "engelen", "author_id": 40403, "author_profile": "https://wordpress.stackexchange.com/users/40403", "pm_score": 3, "selected": true, "text": "<p>The <code>cat</code>-parameter is not overwritten by <code>tax_query</code>. Instead, it is added to <code>tax...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139289", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49947/" ]
I have been stuck on a particular problem for a while now and have yet to find a way around it. I have custom widgets and for each widget I have added the ability to filter posts based on category AND/OR tags (this functionality works). I am now trying to expand on that by including in each widget a custom field where ...
The `cat`-parameter is not overwritten by `tax_query`. Instead, it is added to `tax_query`. Thus, using `'cat' => -5`, the following array is appended to `tax_query`: ``` ( [taxonomy] => category [terms] => Array ( [0] => 5 ) [include_children] => 1 [field] => term_id [...
139,293
<p>Hi i'm trying to change the home page, because i'd like to have a slider and down only one category of article. </p> <p>you can look at the page on line: <a href="http://goaboa.it/home-2014/" rel="nofollow">http://goaboa.it/home-2014/</a></p> <p>I cannot see anything articles in the homepage... </p> <p>Can you he...
[ { "answer_id": 139345, "author": "unifiedac", "author_id": 48278, "author_profile": "https://wordpress.stackexchange.com/users/48278", "pm_score": 0, "selected": false, "text": "<p>If you only want to include posts from a specific category in the loop, you may need to alter the query by ...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139293", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49520/" ]
Hi i'm trying to change the home page, because i'd like to have a slider and down only one category of article. you can look at the page on line: <http://goaboa.it/home-2014/> I cannot see anything articles in the homepage... Can you help me to change correctly the code, to show only category with ID 17, called "h...
Use [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts#Exclude_categories_on_your_main_page) to modify the query before it is executed: ``` function include_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '17' ); } } add...
139,297
<p>Im trying to pull in content from the 'sub pages' onto the homepage, I used the below to pull in content from the 'child pages' but unsure how to do this for the 'sub pages'</p> <p>Does anyone know how this could be done?</p> <p>-Parent page (4)</p> <p>--Child page</p> <p>-----sub page</p> <p>--Child page</p> ...
[ { "answer_id": 139299, "author": "Ravinder Kumar", "author_id": 29439, "author_profile": "https://wordpress.stackexchange.com/users/29439", "pm_score": 1, "selected": false, "text": "<p>you can use this function <a href=\"https://codex.wordpress.org/Function_Reference/get_post_ancestors\...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37852/" ]
Im trying to pull in content from the 'sub pages' onto the homepage, I used the below to pull in content from the 'child pages' but unsure how to do this for the 'sub pages' Does anyone know how this could be done? -Parent page (4) --Child page -----sub page --Child page -----sub page ``` <ul> <?php $chi...
It sounds like you may be looking for [`wp_list_pages()`](http://codex.wordpress.org/Function_Reference/wp_list_pages): ``` $args = array( 'child_of' => $post->ID ); wp_list_pages( $args ); ``` With the appropriate arguments I am almost certain that you can do what you need with that function.
139,302
<p>On a multisite/network install, all of a sudden my password recovery URL has a problem:</p> <pre><code> http//my.domain.com/wp-login.php?action=lostpassword </code></pre> <p>Note the lack of a colon following the 'http'.</p> <p>A grep of the database and codebase does not reveal any culprits (although it must be ...
[ { "answer_id": 139317, "author": "Shawn H", "author_id": 32680, "author_profile": "https://wordpress.stackexchange.com/users/32680", "pm_score": 1, "selected": false, "text": "<p>It is possible that the home url for your site is being overridden in your wp-config.php file, I would make s...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139302", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19216/" ]
On a multisite/network install, all of a sudden my password recovery URL has a problem: ``` http//my.domain.com/wp-login.php?action=lostpassword ``` Note the lack of a colon following the 'http'. A grep of the database and codebase does not reveal any culprits (although it must be in there somewhere). Any idea wha...
The solution was in the multisite settings in the `wp_site` table. The `domain` field entry was set (probably manually during a change of domain names) to `"http://my.domain.com"`. It should not have included the protocol, but just be a bare domain. Wordpress adds another `"http://"` to the start of the domain, and t...
139,303
<p>I've made some researches on google but can't get the right answer.</p> <p>I need to get my wordpress loops outside a domain using php file.</p> <p>For example: I have a website hosted with <strong>www.mysite.com</strong> using wordpress. And an other one is <strong>www.secondwebsite.com</strong> using only php.</...
[ { "answer_id": 139306, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 1, "selected": false, "text": "<p>You mean:\n<code>&lt;?php\ninclude \"http://www.sample.com/wp-load.php\";</code></p>\n\n<p>This setting is disabl...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139303", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25811/" ]
I've made some researches on google but can't get the right answer. I need to get my wordpress loops outside a domain using php file. For example: I have a website hosted with **www.mysite.com** using wordpress. And an other one is **www.secondwebsite.com** using only php. I would love to use something like the wp-l...
You mean: `<?php include "http://www.sample.com/wp-load.php";` This setting is disabled/not allowed by default in most web servers (php.ini) so you can not use the include to include the files from a remote address for security reasons. If you still want to allow inclusion of remote files, the directive `allow_url_in...
139,324
<p>I am trying to remove <strong>Your email address will not be published.</strong> line from comment form in twentythirteen and twentyfourteen default themes.</p> <p>I have tried this:</p> <pre><code>function alter_comment_form_fields($fields){ unset($fields['comment_notes_before']); return $fields; } add_filter('co...
[ { "answer_id": 139306, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 1, "selected": false, "text": "<p>You mean:\n<code>&lt;?php\ninclude \"http://www.sample.com/wp-load.php\";</code></p>\n\n<p>This setting is disabl...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139324", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49531/" ]
I am trying to remove **Your email address will not be published.** line from comment form in twentythirteen and twentyfourteen default themes. I have tried this: ``` function alter_comment_form_fields($fields){ unset($fields['comment_notes_before']); return $fields; } add_filter('comment_form_default_fields','alter_...
You mean: `<?php include "http://www.sample.com/wp-load.php";` This setting is disabled/not allowed by default in most web servers (php.ini) so you can not use the include to include the files from a remote address for security reasons. If you still want to allow inclusion of remote files, the directive `allow_url_in...
139,325
<p>I read <a href="https://wordpress.stackexchange.com/questions/38319/how-to-add-defer-defer-tag-in-plugin-javascripts/38335#38335">How to add defer=&quot;defer&quot; tag in plugin javascripts?</a> and the code @toscho posted works good to defer certain js files or deferring ALL js files by commenting out the contact-...
[ { "answer_id": 158074, "author": "Gixty", "author_id": 14128, "author_profile": "https://wordpress.stackexchange.com/users/14128", "pm_score": 1, "selected": false, "text": "<p>I am using this code, i Hope it helps you.</p>\n\n<pre><code>function defer_parsing_of_js ( $url ) {\n if ( ...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139325", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49532/" ]
I read [How to add defer="defer" tag in plugin javascripts?](https://wordpress.stackexchange.com/questions/38319/how-to-add-defer-defer-tag-in-plugin-javascripts/38335#38335) and the code @toscho posted works good to defer certain js files or deferring ALL js files by commenting out the contact-form-7 line, but I need ...
I supposed that you are trying to set defer for every JS exclude jquery.min and jquery.ui.core.min. Based on that I have made some changes into your code and this will set defer for all JS exclude given example files jquery.min and jquery.ui.core.min. ``` function add_defer_to_cf7( $url ) { //If not js file OR j...
139,329
<p>I'm using <code>get_avatar()</code> to output images of my users.</p> <p>Ref: <a href="https://codex.wordpress.org/Function_Reference/get_avatar" rel="nofollow">https://codex.wordpress.org/Function_Reference/get_avatar</a></p> <p>The optional size parameter lets me specify a size. However, this makes a square avat...
[ { "answer_id": 139337, "author": "Kumar", "author_id": 32466, "author_profile": "https://wordpress.stackexchange.com/users/32466", "pm_score": 0, "selected": false, "text": "<p>Ref: <a href=\"https://en.gravatar.com/site/implement/images/\" rel=\"nofollow\">Gravatar Images</a>, Gravatar ...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139329", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22599/" ]
I'm using `get_avatar()` to output images of my users. Ref: <https://codex.wordpress.org/Function_Reference/get_avatar> The optional size parameter lets me specify a size. However, this makes a square avatar. How can I output an avatar that is rectangle. Something like width 300px and height 150px?
As far as I know the get\_avatar() function only allows for square values. That doesn't mean you couldn't use styling to display a rectangular avatar. Essentially you would use styling to "shave off" 150px from the width. So, let's assume that your theme file produces a 300 x 300 pixel avatar for the post author usin...
139,330
<p>for a website I need to place facebook and twitter share buttons on the footer section of each article on the blog page (where are listed all the articles).</p> <p>I tested many social plugin and was able to have this result only using ShareThis. (I've tested without luck also Sharebar, Sociable and Social likes).<...
[ { "answer_id": 139335, "author": "unifiedac", "author_id": 48278, "author_profile": "https://wordpress.stackexchange.com/users/48278", "pm_score": 2, "selected": false, "text": "<p>As far as I know, you should be able to include the following code in your theme file somewhere. You would ...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139330", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9477/" ]
for a website I need to place facebook and twitter share buttons on the footer section of each article on the blog page (where are listed all the articles). I tested many social plugin and was able to have this result only using ShareThis. (I've tested without luck also Sharebar, Sociable and Social likes). Unfortuna...
Here is a solution that uses genericons. The original code was derived from [this question](https://wordpress.stackexchange.com/questions/98392/list-repeating-share-links) I asked, and answered by toscho, so credit goes to him for the original code that lead to the code in this answer. Check it out [here](https://wordp...
139,344
<p>Trying to figure out how to hide TinyMCE Controls (<em>forcolor</em> mainly) in WordPress 3.9 beta 2.</p> <p>The code that was working in 3.8.1 was </p> <pre><code> $init['theme_advanced_disable'] = 'forecolor'; </code></pre> <p>but theme_advanced_disable no longer seems to work. I can define the whole bar with <...
[ { "answer_id": 139352, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 1, "selected": false, "text": "<p>I'm not sure if there is an official way to do this in TinyMCE 4.0 or not, I can't find any references in t...
2014/03/26
[ "https://wordpress.stackexchange.com/questions/139344", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49539/" ]
Trying to figure out how to hide TinyMCE Controls (*forcolor* mainly) in WordPress 3.9 beta 2. The code that was working in 3.8.1 was ``` $init['theme_advanced_disable'] = 'forecolor'; ``` but theme\_advanced\_disable no longer seems to work. I can define the whole bar with ``` $init['toolbar1'] = '...';' ```...
I'm not sure if there is an official way to do this in TinyMCE 4.0 or not, I can't find any references in their docs or on WordPress - below is a PHP method you could use to do this: ``` function myformatTinyMCE($in) { $del_buttons = array('bold', 'italic', 'strikethrough'); $temp = explode(',', $in['toolbar1'...
139,393
<p>Is there a way to remove the yoast-seo-plugin's bulk title and description editor menu from the non-admins. It is an awesome feature but I would like my users to keep off from it. I am using the very latest versions of wp and the plugin.</p> <p><img src="https://i.stack.imgur.com/8rqsB.png" alt="enter image descrip...
[ { "answer_id": 139396, "author": "engelen", "author_id": 40403, "author_profile": "https://wordpress.stackexchange.com/users/40403", "pm_score": 2, "selected": true, "text": "<p>Yoast SEO uses capabilities (<a href=\"https://codex.wordpress.org/Roles_and_Capabilities\" rel=\"nofollow\">W...
2014/03/27
[ "https://wordpress.stackexchange.com/questions/139393", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25508/" ]
Is there a way to remove the yoast-seo-plugin's bulk title and description editor menu from the non-admins. It is an awesome feature but I would like my users to keep off from it. I am using the very latest versions of wp and the plugin. ![enter image description here](https://i.stack.imgur.com/8rqsB.png) --- I am t...
Yoast SEO uses capabilities ([WordPress docs on roles and capabilities](https://codex.wordpress.org/Roles_and_Capabilities)) to determine whether users are allowed to bulk edit tiles and descriptions. The name of the capability used for this is `wpseo_bulk_edit`. By default, Yoast SEO adds this capability to the admin...
139,403
<p>Why if I register a custom post type by <code>add_action( 'init', 'custom_post_type' )</code> hook it doesn't show in returned array by <code>get_post_types</code> function? Example:</p> <pre><code>function test(){ $args = array( 'public' =&gt; true, 'publicly_queryable' =&gt; t...
[ { "answer_id": 139408, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 1, "selected": false, "text": "<p>In your code, you are executing <code>get_post_types()</code> before the post type is registered. Try, for ex...
2014/03/27
[ "https://wordpress.stackexchange.com/questions/139403", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47607/" ]
Why if I register a custom post type by `add_action( 'init', 'custom_post_type' )` hook it doesn't show in returned array by `get_post_types` function? Example: ``` function test(){ $args = array( 'public' => true, 'publicly_queryable' => true, 'show_ui' => true...
Because you calling get\_post\_types() in functions.php that is excuted before 'init' action. Look this picture <http://www.rarst.net/images/wordpress_core_load.png> if you add an echo inside function test ``` function test(){ $args = array( 'public' => true, 'publicly_queryable' => tru...
139,425
<p>When a contributor uploads an image to a post, the default image size option is set to Medium. How can I change it to Large or Full?</p>
[ { "answer_id": 139428, "author": "engelen", "author_id": 40403, "author_profile": "https://wordpress.stackexchange.com/users/40403", "pm_score": 2, "selected": true, "text": "<p>The default image size for inserting images is stored in the options table in <code>image_default_size</code>....
2014/03/27
[ "https://wordpress.stackexchange.com/questions/139425", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37529/" ]
When a contributor uploads an image to a post, the default image size option is set to Medium. How can I change it to Large or Full?
The default image size for inserting images is stored in the options table in `image_default_size`. You can change the default image size by updating the option: ``` update_option( 'image_default_size', 'large' ); ``` Role-dependent default image size --------------------------------- To change the default image si...
139,427
<p>I would like to display a text depends of my custom taxonomy category, like:</p> <p>if <em>custom post type category</em> is <em>X</em>, then echo <em>Text Y</em>.</p> <p>I've tried this, but its not working:</p> <pre><code>global $post; if (($post-&gt;post_type == 'myposttype') &amp;&amp; is_category('slug-name...
[ { "answer_id": 139457, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": -1, "selected": false, "text": "<p>The conditional <code>is_*</code> functions work on query, not on current post. In other words they tell you thing...
2014/03/27
[ "https://wordpress.stackexchange.com/questions/139427", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43780/" ]
I would like to display a text depends of my custom taxonomy category, like: if *custom post type category* is *X*, then echo *Text Y*. I've tried this, but its not working: ``` global $post; if (($post->post_type == 'myposttype') && is_category('slug-name-of-cat')) { echo 'My text' } ``` any ideias?
`is_category()` does not work on custom taxonomy archive pages. The correct conditional tag here is [`is_tax()`](https://codex.wordpress.org/Function_Reference/is_tax) which takes the name of the taxonomy as first parameter and a string|int|array of term name/s, slug/s or ID/s as second parameter. So your whole condit...
139,436
<p>I'm trying to install the SEO by Yoast plugin.</p> <p>My WordPress is host on DigitalOcean (previously host on OVH) and is located in /var/www/. When I check inside /var/www/wp-content/plugins/, there is no wordpress-seo folder.</p> <p>In my dashboard, when I install the plugin, WordPress displays:</p> <pre><code...
[ { "answer_id": 139457, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": -1, "selected": false, "text": "<p>The conditional <code>is_*</code> functions work on query, not on current post. In other words they tell you thing...
2014/03/27
[ "https://wordpress.stackexchange.com/questions/139436", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49585/" ]
I'm trying to install the SEO by Yoast plugin. My WordPress is host on DigitalOcean (previously host on OVH) and is located in /var/www/. When I check inside /var/www/wp-content/plugins/, there is no wordpress-seo folder. In my dashboard, when I install the plugin, WordPress displays: ``` Installing the plugin… Dest...
`is_category()` does not work on custom taxonomy archive pages. The correct conditional tag here is [`is_tax()`](https://codex.wordpress.org/Function_Reference/is_tax) which takes the name of the taxonomy as first parameter and a string|int|array of term name/s, slug/s or ID/s as second parameter. So your whole condit...
139,440
<p>After completing the WordPress reset password procedure I try to login with the new password but I get an error saying:</p> <pre><code>'Authorization Required. This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or yo...
[ { "answer_id": 139449, "author": "Sam", "author_id": 37548, "author_profile": "https://wordpress.stackexchange.com/users/37548", "pm_score": 3, "selected": true, "text": "<p>This could be down to a number of reasons:</p>\n\n<p>a) The browser you're having problems with is saving the old ...
2014/03/27
[ "https://wordpress.stackexchange.com/questions/139440", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23550/" ]
After completing the WordPress reset password procedure I try to login with the new password but I get an error saying: ``` 'Authorization Required. This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doe...
This could be down to a number of reasons: a) The browser you're having problems with is saving the old password and refusing access. This is why the other browser works when logging in with the new password. Try and reset the saved password to see if this solves the issue. b) Your hosting provider has implemented an...
139,443
<p>First of all, my problem is very similar to this one: <a href="https://stackoverflow.com/questions/10629245/wordpress-menu-disappears-when-query-query-varsmeta-key-is-set">https://stackoverflow.com/questions/10629245/wordpress-menu-disappears-when-query-query-varsmeta-key-is-set</a> However, the answer accepted for ...
[ { "answer_id": 139445, "author": "patrickzdb", "author_id": 20327, "author_profile": "https://wordpress.stackexchange.com/users/20327", "pm_score": -1, "selected": false, "text": "<p>I was able to get this working by using the if statement at the top of the archive template instead of in...
2014/03/27
[ "https://wordpress.stackexchange.com/questions/139443", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20327/" ]
First of all, my problem is very similar to this one: <https://stackoverflow.com/questions/10629245/wordpress-menu-disappears-when-query-query-varsmeta-key-is-set> However, the answer accepted for this question does not help me for some reason. I am using the following code in my functions.php file to filter posts bas...
I was having the exact same problem on an archive page of a custom post type with a needless extra query; for pagination reasons. Searching for the same solution I found this post on Stack Overflow <https://stackoverflow.com/questions/21303743/new-wp-query-or-pre-get-posts-to-view-all-posts-for-custom-post-type> I had...
139,453
<p>I have a page with two sections, each uses a different <code>WP_Query()</code> to pull in <code>events</code>, which are a custom post type. Each <code>WP_Query()</code> queries a <code>meta_key</code> for the event date so that Section 1 only displays upcoming <code>events</code> and Section 2 displays past <code>e...
[ { "answer_id": 139469, "author": "cfx", "author_id": 28957, "author_profile": "https://wordpress.stackexchange.com/users/28957", "pm_score": 4, "selected": true, "text": "<p>I managed to get this working using nothing but WordPress filters, thanks to @Milo's hint.</p>\n\n<p>Just note tha...
2014/03/27
[ "https://wordpress.stackexchange.com/questions/139453", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28957/" ]
I have a page with two sections, each uses a different `WP_Query()` to pull in `events`, which are a custom post type. Each `WP_Query()` queries a `meta_key` for the event date so that Section 1 only displays upcoming `events` and Section 2 displays past `events`. The upcoming `events` in Section 1 display all relevan...
I managed to get this working using nothing but WordPress filters, thanks to @Milo's hint. Just note that these are pretty specific to my case but you shouldn't have a problem modifying them for your own use. I am using Advanced Custom Fields with a Date Picker field called `date` and Prev/Next links only point to eve...
139,454
<p>I am trying to change some of the settings that get loaded with MediaElement.js. I can't seem to find a filter or hook to alter the settings that are loaded. The only way I was able to customize the settings is by opening up the core MediaElement.js file and changing the settings there.</p> <p>Obviously this is les...
[ { "answer_id": 142891, "author": "Emyr Thomas", "author_id": 5620, "author_profile": "https://wordpress.stackexchange.com/users/5620", "pm_score": 4, "selected": true, "text": "<p>Copy <code>wp-includes/js/mediaelement/wp-mediaelement.js</code> into your theme or plugin and make your mod...
2014/03/27
[ "https://wordpress.stackexchange.com/questions/139454", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43000/" ]
I am trying to change some of the settings that get loaded with MediaElement.js. I can't seem to find a filter or hook to alter the settings that are loaded. The only way I was able to customize the settings is by opening up the core MediaElement.js file and changing the settings there. Obviously this is less than ide...
Copy `wp-includes/js/mediaelement/wp-mediaelement.js` into your theme or plugin and make your modifications there. For example, I added some settings to force the use of native video controls on iOS & Android devices, like so: ``` (function ($) { // add mime-type aliases to MediaElement plugin support ...
139,465
<p>Any time I create a new site on my multisite install, I get an infinite loop redirect when navigating to that site's admin. I'm using the default htaccess supplied by WP for my subdirectory install. Here's what I have:</p> <pre><code>RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # add a trailing sl...
[ { "answer_id": 142891, "author": "Emyr Thomas", "author_id": 5620, "author_profile": "https://wordpress.stackexchange.com/users/5620", "pm_score": 4, "selected": true, "text": "<p>Copy <code>wp-includes/js/mediaelement/wp-mediaelement.js</code> into your theme or plugin and make your mod...
2014/03/27
[ "https://wordpress.stackexchange.com/questions/139465", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49597/" ]
Any time I create a new site on my multisite install, I get an infinite loop redirect when navigating to that site's admin. I'm using the default htaccess supplied by WP for my subdirectory install. Here's what I have: ``` RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-adm...
Copy `wp-includes/js/mediaelement/wp-mediaelement.js` into your theme or plugin and make your modifications there. For example, I added some settings to force the use of native video controls on iOS & Android devices, like so: ``` (function ($) { // add mime-type aliases to MediaElement plugin support ...
139,477
<p>Check this code:<br></p> <pre><code>function slide_group() { register_taxonomy('Group', 'slides', array( 'hierarchical' =&gt; true /*visualizza come le categorie*/, 'label' =&gt; 'Group', 'query_var' =&gt; true, 'rewrite' =&gt; true));} add_action('init', 'slid...
[ { "answer_id": 139478, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>You want to define a potentially huge number of different shortcodes with the <strong>same</strong> shortcod...
2014/03/28
[ "https://wordpress.stackexchange.com/questions/139477", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47959/" ]
Check this code: ``` function slide_group() { register_taxonomy('Group', 'slides', array( 'hierarchical' => true /*visualizza come le categorie*/, 'label' => 'Group', 'query_var' => true, 'rewrite' => true));} add_action('init', 'slide_group', 0); function squa...
You want to define a potentially huge number of different shortcodes with the **same** shortcode callback? Why don't you define a *single* shortcode, with a term attribute? For example ``` [sc term="london"] ``` *ps:* I think your problem lies in the `$tax_term->name` part, which could be a string like *City of L...
139,483
<p>I'm sure I'm making a dumb mistake, but I don't for the life of me know what it might be.</p> <p>I recently converted one of my larger plugins to utilize I18n (my first time doing so for any of my plugins). The correct function calls are evidently being used since WP was able to generate a complete <code>POT</code>...
[ { "answer_id": 139488, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 0, "selected": false, "text": "<p>Dan, why don't you move your function outside of your <code>class</code> and just register your languag...
2014/03/28
[ "https://wordpress.stackexchange.com/questions/139483", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15299/" ]
I'm sure I'm making a dumb mistake, but I don't for the life of me know what it might be. I recently converted one of my larger plugins to utilize I18n (my first time doing so for any of my plugins). The correct function calls are evidently being used since WP was able to generate a complete `POT` file through the adm...
The problem I was encountering was a result of not realizing that the 3rd parameter for [`load_plugin_textdomain`](https://codex.wordpress.org/Function_Reference/load_plugin_textdomain) should be a **relative** path to the language directory from [`WP_PLUGIN_DIR`](https://codex.wordpress.org/Determining_Plugin_and_Cont...
139,511
<p>I am trying to find out how I can control how an excerpt is displayed using PHP. How do I get it to render the html spacing within the post instead of just showing one big paragraph.Hope that makes sense. </p> <p>Let me give you an example.</p> <p>So my client has syndicated post and at the top of each post he wan...
[ { "answer_id": 139512, "author": "engelen", "author_id": 40403, "author_profile": "https://wordpress.stackexchange.com/users/40403", "pm_score": 0, "selected": false, "text": "<p>The function <a href=\"https://codex.wordpress.org/Function_Reference/wpautop\" rel=\"nofollow\">wpautop</a> ...
2014/03/28
[ "https://wordpress.stackexchange.com/questions/139511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49617/" ]
I am trying to find out how I can control how an excerpt is displayed using PHP. How do I get it to render the html spacing within the post instead of just showing one big paragraph.Hope that makes sense. Let me give you an example. So my client has syndicated post and at the top of each post he wants to include a h...
The excerpt stips all html tags, a feature that frustrates many. I have written a custom excerpt that stops the excerpt from stipping any html tags. It also breaks the excerpt after the sentence after the set amount of words. If you need to cut the excerpt at exact words, you will just need to modify my code. You will...
139,516
<p>I am using wp_query to get uploaded medias. Everything is working fine, but wp_query will return the medias with no post attached. This is not what I wanted. How can I exclude the unattached media from the wp_query? </p> <p>This is my query arguments look like:</p> <pre><code> $args = array( 'post_type' =&gt; '...
[ { "answer_id": 139517, "author": "Chetan", "author_id": 49618, "author_profile": "https://wordpress.stackexchange.com/users/49618", "pm_score": 0, "selected": false, "text": "<pre><code>&lt;?php if ( $post-&gt;post_type == **'post type name'** &amp;&amp; $post-&gt;post_status == 'publish...
2014/03/28
[ "https://wordpress.stackexchange.com/questions/139516", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14728/" ]
I am using wp\_query to get uploaded medias. Everything is working fine, but wp\_query will return the medias with no post attached. This is not what I wanted. How can I exclude the unattached media from the wp\_query? This is my query arguments look like: ``` $args = array( 'post_type' => 'attachment', 'post_s...
All media (somewhat incorrectly) in the `$wpdb->posts` table will be "attachments" whether actually attached or not. "Attachments" that are actually attached will have a `post_parent` other than 0, so what you need are all of the attachments that have a 0 in the `post_parent` column, if I understand you. ``` $args = ...
139,527
<p>I'm trying to do the following:</p> <p>I have a Main-Blog and dozens of subblogs. I want all the subblogs to use the same theme (or child-theme, not sure yet) but have the same navigationitems of the mainblog on all subblogs? The same for the footer.</p> <p>How'd I do that?</p> <p>This is my Main-Blog and Landing...
[ { "answer_id": 139686, "author": "JPollock", "author_id": 25300, "author_profile": "https://wordpress.stackexchange.com/users/25300", "pm_score": 2, "selected": false, "text": "<p>What I would do is create a parent theme that is used on one site and a child theme of that theme for all ot...
2014/03/28
[ "https://wordpress.stackexchange.com/questions/139527", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
I'm trying to do the following: I have a Main-Blog and dozens of subblogs. I want all the subblogs to use the same theme (or child-theme, not sure yet) but have the same navigationitems of the mainblog on all subblogs? The same for the footer. How'd I do that? This is my Main-Blog and Landing-Page > > ![enter imag...
You could use the `switch_to_blog()` function > > Switches the active blog until the user calls the > restore\_current\_blog() function. This function is useful if you need > to pull posts, or other information, from other blogs, you can then > switch back after using restore\_current\_blog(). Using this function ...
139,552
<p>I would like to list the specified pages with my shortcode, but the problems are with the '$' charachters.</p> <pre><code>function get_page_func( $atts ) { extract(shortcode_atts( array( 'title' =&gt; '' ), $atts ) ); $page = get_page_by_title($title); $the_query...
[ { "answer_id": 139554, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Your ampersand is getting encoded, try:</p>\n\n<pre><code>get_page_by_title( html_entity_decode( $title ) );\n</cod...
2014/03/28
[ "https://wordpress.stackexchange.com/questions/139552", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38284/" ]
I would like to list the specified pages with my shortcode, but the problems are with the '$' charachters. ``` function get_page_func( $atts ) { extract(shortcode_atts( array( 'title' => '' ), $atts ) ); $page = get_page_by_title($title); $the_query = new WP_Query( ...
Your ampersand is getting encoded, try: ``` get_page_by_title( html_entity_decode( $title ) ); ```
139,562
<p>I have few hundred products on woocommerce without images. I am planning to upload images in future. Images have same name as the SKU of product (+.jpg). </p> <p>Is there a way I could write a script that adds this image as product image and featured image of the SKU = name of this image(-.jpg)?</p>
[ { "answer_id": 139902, "author": "codearachnid", "author_id": 28798, "author_profile": "https://wordpress.stackexchange.com/users/28798", "pm_score": 1, "selected": false, "text": "<p>Based on your comment to your question, you might take a look at <a href=\"http://www.wpallimport.com\" ...
2014/03/28
[ "https://wordpress.stackexchange.com/questions/139562", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19719/" ]
I have few hundred products on woocommerce without images. I am planning to upload images in future. Images have same name as the SKU of product (+.jpg). Is there a way I could write a script that adds this image as product image and featured image of the SKU = name of this image(-.jpg)?
You don't need a plugin, if your images names **really** match with product SKUs and you use media uploader to upload the file, you can use **a single function** hooked in [`add_attachment`](https://codex.wordpress.org/Plugin_API/Action_Reference/add_attachment) and you are done. Once it require some work, I'd avoid t...
139,571
<p>I'm trying to display 5 related posts in the loop, those related posts being posts that share the same taxonomy value. e.g. I have a custom taxonomy set up called <code>venues</code> thus each post has a <code>venue</code> taxonomy value assigned to it, so in each post I want to display 5 others posts that share the...
[ { "answer_id": 139574, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 3, "selected": true, "text": "<p>Totally untested and I'm not 100% sure I understand your question, but this should (in theory) get 5 post...
2014/03/29
[ "https://wordpress.stackexchange.com/questions/139571", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28065/" ]
I'm trying to display 5 related posts in the loop, those related posts being posts that share the same taxonomy value. e.g. I have a custom taxonomy set up called `venues` thus each post has a `venue` taxonomy value assigned to it, so in each post I want to display 5 others posts that share the same taxonomy value (i.e...
Totally untested and I'm not 100% sure I understand your question, but this should (in theory) get 5 posts that share any of the same venues as the current post. I would probably suggest adding some Transients to this so that you aren't constantly running queries. If it doesn't work, I suspect the syntax of my tax qu...
139,575
<p>How to get widget options?</p> <p>I've tried like this, like seen in the other question "Using widget options outside of the widget":</p> <pre><code>$w=get_option('widget_wp_mywidget'); $one=$w[2]["myval"]; $two=$w[2]["myotherval"]; </code></pre> <p>But I am not quite sure why this [2] is dynamic and i ca...
[ { "answer_id": 139611, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>Widget data is stored in the options table as a two dimensional array. All data for the same type of widget i...
2014/03/29
[ "https://wordpress.stackexchange.com/questions/139575", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48382/" ]
How to get widget options? I've tried like this, like seen in the other question "Using widget options outside of the widget": ``` $w=get_option('widget_wp_mywidget'); $one=$w[2]["myval"]; $two=$w[2]["myotherval"]; ``` But I am not quite sure why this [2] is dynamic and i can't rely on it, so how to get exa...
Widget data is stored in the options table as a two dimensional array. All data for the same type of widget is stored under the same option key. The key of the outer array is a kind of widget "index"-- the identifier for the particular instance of the widget. The inner arrays contain the individual widget data. Like so...
139,614
<p>I tried this way to display NO of post:</p> <pre><code>&lt;?php $news_2 = new WP_Query( array ('post_type'=&gt; 'jobs','posts_per_page'=&gt; '10' , 'meta_key' =&gt; 'status_for_jobs','meta_value' =&gt; '1') ); if ( $news_2-&gt;have_posts() ) { while ( $news_2-&gt;have_posts() ) { $news_2-&gt;the_post(); $cou...
[ { "answer_id": 139618, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 2, "selected": false, "text": "<p>You don't need to count the posts to show something different if no posts are found. You can just use th...
2014/03/29
[ "https://wordpress.stackexchange.com/questions/139614", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49575/" ]
I tried this way to display NO of post: ``` <?php $news_2 = new WP_Query( array ('post_type'=> 'jobs','posts_per_page'=> '10' , 'meta_key' => 'status_for_jobs','meta_value' => '1') ); if ( $news_2->have_posts() ) { while ( $news_2->have_posts() ) { $news_2->the_post(); $count = $news_2->post_count; ?> <...
Some additional information, no need to count the posts again, because [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query) already did that for you. To clarify this, some information from the Class Reference of `WP_Query` as found in the »Properties« section: > > **$post\_count** > > The number of ...
139,624
<p>I'm building a members website with WordPress Multisite. Is it possible to restrict how many images are being generated depending on the selected template? </p> <p>I have tried the following lines of code to generate certain images on the gallery template:</p> <pre><code>// Generate on all uploads add_theme_suppor...
[ { "answer_id": 139626, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 5, "selected": true, "text": "<p>This has always been a bugbear for me - the lack of on-demand image sizing, and the subsequent number of fi...
2014/03/29
[ "https://wordpress.stackexchange.com/questions/139624", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37548/" ]
I'm building a members website with WordPress Multisite. Is it possible to restrict how many images are being generated depending on the selected template? I have tried the following lines of code to generate certain images on the gallery template: ``` // Generate on all uploads add_theme_support('post-thumbnails');...
This has always been a bugbear for me - the lack of on-demand image sizing, and the subsequent number of files you can end up with if you have lots of sizes! I can see the logic behind your efforts - the trouble is, `add_image_size` only truly comes into play at point-of-upload. As such, `is_page_template(..)` will al...
139,639
<p>Wordpress let me create custom tag templates, i have lots of tags, and i want to display the post tagged with some tags with a template, and the post tagged with other tags with another template. <img src="https://i.stack.imgur.com/C7kUo.png" alt="enter image description here"></p> <p>As this image shows the templa...
[ { "answer_id": 139641, "author": "Mehdi Namvar", "author_id": 49606, "author_profile": "https://wordpress.stackexchange.com/users/49606", "pm_score": 2, "selected": false, "text": "<p>You can use <strong>tag.php</strong> for the great number of tags and use <strong>tag-{slug}.php</strong...
2014/03/29
[ "https://wordpress.stackexchange.com/questions/139639", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43681/" ]
Wordpress let me create custom tag templates, i have lots of tags, and i want to display the post tagged with some tags with a template, and the post tagged with other tags with another template. ![enter image description here](https://i.stack.imgur.com/C7kUo.png) As this image shows the template hierarchy let me crea...
Here's an example that "abuses" the tag description field to store a template name for the tag. We use the `tag_template` filter to get the tag description if it exists and include a template file with the description as part of the name. You could extend this to whitelist specific template names so typos don't result ...
139,660
<p>I am developing a plugin using <a href="https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate" rel="noreferrer">Tom McFarlin's Boilerplate</a> repository as a template, which utilizes OOP practices. I've been trying to figure out exactly why I'm unable to correctly submit my settings. I've tried setting the ac...
[ { "answer_id": 140071, "author": "Stephen M. Harris", "author_id": 11957, "author_profile": "https://wordpress.stackexchange.com/users/11957", "pm_score": 5, "selected": true, "text": "<h1>\"Error: Options Page Not Found\" Bug</h1>\n\n<p>This is a <a href=\"https://codex.wordpress.org/Fu...
2014/03/30
[ "https://wordpress.stackexchange.com/questions/139660", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49643/" ]
I am developing a plugin using [Tom McFarlin's Boilerplate](https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate) repository as a template, which utilizes OOP practices. I've been trying to figure out exactly why I'm unable to correctly submit my settings. I've tried setting the action attribute to an empty stri...
"Error: Options Page Not Found" Bug =================================== This is a [known issue](https://codex.wordpress.org/Function_Reference/register_setting#Notes) in the WP Settings API. There was [a ticket](https://core.trac.wordpress.org/ticket/7277) opened years ago, and it was marked as solved -- but the bug p...
139,663
<p>This seems fairly straight forward, but I cannot find a definite guide on how to add the taxonomy description field to the quick edit box.</p> <p>I've followed several tutorials on adding fields to the custom quick edit box, but the core fields (name, description and slug) do not follow the same guidelines as addin...
[ { "answer_id": 139713, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 5, "selected": true, "text": "<p>Normally to add fields to the quick edit field, we should use <code>'quick_edit_custom_box'</code> action hook...
2014/03/30
[ "https://wordpress.stackexchange.com/questions/139663", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28389/" ]
This seems fairly straight forward, but I cannot find a definite guide on how to add the taxonomy description field to the quick edit box. I've followed several tutorials on adding fields to the custom quick edit box, but the core fields (name, description and slug) do not follow the same guidelines as adding custom f...
Normally to add fields to the quick edit field, we should use `'quick_edit_custom_box'` action hook that is triggered only for custom columns, because core columns are explicitly excluded ([see code](https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-admin/includes/class-wp-terms-list-table.php#L355)). If we ad...
139,670
<p>I have a list of products, and I want to be able to click a link and get to a page with more information about the product, which I can do using <code>$_GET</code> like so:</p> <pre><code>$s .= '&lt;p&gt;&lt;a href='.get_site_url().'/wp-content/plugins/real-wp-shop/test.php?info='.$value-&gt;id.'&gt;Details&lt;/a&...
[ { "answer_id": 139674, "author": "TomC", "author_id": 36980, "author_profile": "https://wordpress.stackexchange.com/users/36980", "pm_score": 0, "selected": false, "text": "<p>Yes you can. You can create a page template to use and in that use the following:</p>\n\n<pre><code>if (isset($_...
2014/03/30
[ "https://wordpress.stackexchange.com/questions/139670", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37281/" ]
I have a list of products, and I want to be able to click a link and get to a page with more information about the product, which I can do using `$_GET` like so: ``` $s .= '<p><a href='.get_site_url().'/wp-content/plugins/real-wp-shop/test.php?info='.$value->id.'>Details</a></p>'; ``` And then in `test.php` I have: ...
You can use the [`template_include`](http://codex.wordpress.org/Plugin_API/Filter_Reference/template_include) filter to load a template file from your theme: ``` add_filter( 'template_include', 'my_page_template', 99 ); function my_page_template( $template ) { if ( isset( $_GET['info'] ) && $_GET['info'] == 'som...
139,691
<p>I need to add sponsor images, thumbnails, in the footer of a Wordpress website. I'd like the possibility to just upload images through the native Wordpress media gallery and then having a way to select those pictures. Is there a way to do this? A way to mark some uploaded pictures so that I can select them for the f...
[ { "answer_id": 139674, "author": "TomC", "author_id": 36980, "author_profile": "https://wordpress.stackexchange.com/users/36980", "pm_score": 0, "selected": false, "text": "<p>Yes you can. You can create a page template to use and in that use the following:</p>\n\n<pre><code>if (isset($_...
2014/03/30
[ "https://wordpress.stackexchange.com/questions/139691", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13206/" ]
I need to add sponsor images, thumbnails, in the footer of a Wordpress website. I'd like the possibility to just upload images through the native Wordpress media gallery and then having a way to select those pictures. Is there a way to do this? A way to mark some uploaded pictures so that I can select them for the foot...
You can use the [`template_include`](http://codex.wordpress.org/Plugin_API/Filter_Reference/template_include) filter to load a template file from your theme: ``` add_filter( 'template_include', 'my_page_template', 99 ); function my_page_template( $template ) { if ( isset( $_GET['info'] ) && $_GET['info'] == 'som...
139,692
<p>I'm testing the function <code>wp_list_filter()</code>, basically I want to know if post_type has some specific feature before making stuffs.</p> <p>So I end up with this:</p> <pre><code>public static function get_post_types_with_support( $feature ) { global $_wp_post_type_features; $post_types = wp_list_fil...
[ { "answer_id": 139717, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>Post types are registered on <code>wp_loaded</code> or <code>init</code> – after plugins and the theme are loaded.</p...
2014/03/30
[ "https://wordpress.stackexchange.com/questions/139692", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31376/" ]
I'm testing the function `wp_list_filter()`, basically I want to know if post\_type has some specific feature before making stuffs. So I end up with this: ``` public static function get_post_types_with_support( $feature ) { global $_wp_post_type_features; $post_types = wp_list_filter( $_wp_post_type_features, a...
As I noted on a comment and @toscho wrote in his answer, your code works if used after `wp_loaded` hook. The reason why it works for core post types if used on earlier hooks is WordPress register core post types 2 times: first time just after `'mu_plugins_loaded'` hook and then again on 'init' hook ([reference](https:/...
139,694
<p>While switching between text editor mode or updating post fontawesome icon vanishes.Please do not refer to use any plugin.I think i tag is stripped by editor,how can I overcome this? My code in editor text mode</p> <pre><code>&lt;span&gt;&lt;i class="fa fa-user"&gt;&lt;/i&gt;&lt;/span&gt; </code></pre> <p>or</p> ...
[ { "answer_id": 139729, "author": "ashraf", "author_id": 30937, "author_profile": "https://wordpress.stackexchange.com/users/30937", "pm_score": 3, "selected": true, "text": "<p>I think you should first enable i tags.Then you should enable class id or span whatever you like.To do so add t...
2014/03/30
[ "https://wordpress.stackexchange.com/questions/139694", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48294/" ]
While switching between text editor mode or updating post fontawesome icon vanishes.Please do not refer to use any plugin.I think i tag is stripped by editor,how can I overcome this? My code in editor text mode ``` <span><i class="fa fa-user"></i></span> ``` or ``` <i class="fa fa-user"></i> ``` As long as I am i...
I think you should first enable i tags.Then you should enable class id or span whatever you like.To do so add this code. ``` function add_mce_markup( $initArray ) { $ext = 'i[id|name|class|style]'; if ( isset( $initArray['extended_valid_elements'] ) ) { $initArray['extended_valid_elements'] .= ',' . $e...
139,696
<p>I've created a custom post type called 'product'. I want to add a page link to 'products' in the menu, but I don't have that option.</p> <p>I would like to know if there is a way of displaying it the same way as if it were like a category... a page that shows all the 'products' like if they were posts, and that I ...
[ { "answer_id": 139729, "author": "ashraf", "author_id": 30937, "author_profile": "https://wordpress.stackexchange.com/users/30937", "pm_score": 3, "selected": true, "text": "<p>I think you should first enable i tags.Then you should enable class id or span whatever you like.To do so add t...
2014/03/30
[ "https://wordpress.stackexchange.com/questions/139696", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34993/" ]
I've created a custom post type called 'product'. I want to add a page link to 'products' in the menu, but I don't have that option. I would like to know if there is a way of displaying it the same way as if it were like a category... a page that shows all the 'products' like if they were posts, and that I could add t...
I think you should first enable i tags.Then you should enable class id or span whatever you like.To do so add this code. ``` function add_mce_markup( $initArray ) { $ext = 'i[id|name|class|style]'; if ( isset( $initArray['extended_valid_elements'] ) ) { $initArray['extended_valid_elements'] .= ',' . $e...
139,700
<p>I've seen many other related questions, but all of them are resolved with just adding the name format at the top of the plugin main PHP file, and/or manually downloading and extracting the plugin, but none of those answers worked for me.</p> <p>I'm talking about the <a href="https://github.com/jonkemp/wordpress-use...
[ { "answer_id": 139709, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 4, "selected": true, "text": "<p>If the plugin headers are correct, then the only option that comes to my mind is that the owner and permissio...
2014/03/30
[ "https://wordpress.stackexchange.com/questions/139700", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36778/" ]
I've seen many other related questions, but all of them are resolved with just adding the name format at the top of the plugin main PHP file, and/or manually downloading and extracting the plugin, but none of those answers worked for me. I'm talking about the [Wordpress Users Plugin](https://github.com/jonkemp/wordpre...
If the plugin headers are correct, then the only option that comes to my mind is that the owner and permissions of the plugin file or its directory (if it is in one) are incorrect and WordPress cannot read the plugin file. Other than simply being logically important, [if you check the source you can see that the Core s...
139,720
<p>I'm working on a client website where the framework requires a specific plugin version to work properly.</p> <p>With the follow lines of code in my <strong>functions.php</strong> file, it stops the plugin from updating itself and displaying an update message to the admin user:</p> <pre><code>// Disable Cherry Plug...
[ { "answer_id": 139724, "author": "Oturia", "author_id": 48943, "author_profile": "https://wordpress.stackexchange.com/users/48943", "pm_score": 3, "selected": true, "text": "<p>I know this is kind of a backwards way of doing it, but I suppose if you disable the possibility to upgrade the...
2014/03/30
[ "https://wordpress.stackexchange.com/questions/139720", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28275/" ]
I'm working on a client website where the framework requires a specific plugin version to work properly. With the follow lines of code in my **functions.php** file, it stops the plugin from updating itself and displaying an update message to the admin user: ``` // Disable Cherry Plugin Updates function filter_plugin_...
I know this is kind of a backwards way of doing it, but I suppose if you disable the possibility to upgrade the plugin, then you don't need to worry about the plugin being overwritten. > > Change the plugin version number (in the plugins main file comment header) to something ridiculously high so it won't recommend a...
139,788
<p>I'm creating a website for a restaurant, I have working code that does what I want. Displays a map. Under the map, I've a form with two inputs. The first input allows someone to specify where they want directions from and the second input is already filled out, it's set as the location of the restaurant. On submit, ...
[ { "answer_id": 139791, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 3, "selected": true, "text": "<p>You have to either</p>\n\n<p>1) take all the whitespace out of the scripts and iframes so WordPress does not ...
2014/03/31
[ "https://wordpress.stackexchange.com/questions/139788", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49724/" ]
I'm creating a website for a restaurant, I have working code that does what I want. Displays a map. Under the map, I've a form with two inputs. The first input allows someone to specify where they want directions from and the second input is already filled out, it's set as the location of the restaurant. On submit, the...
You have to either 1) take all the whitespace out of the scripts and iframes so WordPress does not add `<p>` tags and then the JS and iframe links will work, or 2) disable `autop` in the post editor for all posts/pages (see <http://codex.wordpress.org/Function_Reference/wpautop> ) so WP doesn't add paragraph breaks, ...
139,810
<p>I have several pages with a parent. So, $post->post_parent should be different than 0, right? </p> <pre><code>echo $post-&gt;post_parent; </code></pre> <p>Is returning 0. </p> <p>Thing is, this is only happening in one post category. Do I need to declare that a page has a parent elsewhere? I do it from within the...
[ { "answer_id": 140200, "author": "Margaret", "author_id": 43394, "author_profile": "https://wordpress.stackexchange.com/users/43394", "pm_score": 1, "selected": false, "text": "<p>Try echoing <code>serialized($post);</code> to make sure you're looking at the right page(s). It should retu...
2014/03/31
[ "https://wordpress.stackexchange.com/questions/139810", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31120/" ]
I have several pages with a parent. So, $post->post\_parent should be different than 0, right? ``` echo $post->post_parent; ``` Is returning 0. Thing is, this is only happening in one post category. Do I need to declare that a page has a parent elsewhere? I do it from within the edit page form of that page. Than...
Try echoing `serialized($post);` to make sure you're looking at the right page(s). It should return the post\_parent so the problem may be either in the call you're making to get `$post`, or double-check that the set of pages did save with a parent page. Easiest way of doing that is call up "All Pages" and they'll be...
139,851
<p>I hidden some pages using <code>'parse_query'</code> hook, but the count for 'Published' pages didn't changed... Where I should hook to change it?</p> <p><img src="https://i.stack.imgur.com/dM7GU.jpg" alt="Update the page status count in admin"></p> <p>My code so far: </p> <pre><code>$query-&gt;query_vars['post__...
[ { "answer_id": 139859, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p>The post count uses the <a href=\"http://codex.wordpress.org/Function_Reference/wp_count_posts\" rel=\"nof...
2014/04/01
[ "https://wordpress.stackexchange.com/questions/139851", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11896/" ]
I hidden some pages using `'parse_query'` hook, but the count for 'Published' pages didn't changed... Where I should hook to change it? ![Update the page status count in admin](https://i.stack.imgur.com/dM7GU.jpg) My code so far: ``` $query->query_vars['post__not_in'] = array(4); ```
Yes, the count for pages in various statuses that you see above the list table is obtained running [`wp_count_posts`](http://codex.wordpress.org/Function_Reference/wp_count_posts) but the pages in the table are obtained running a `WP_Query` and the 2 things are completely **unrelated**. If you want to also modify the ...
139,880
<p>I have a custom query that goes looks like this:</p> <pre><code> $temp = $wp_query; $wp_query = null; $args = array('posts_per_page' =&gt; 5, 'post_type' =&gt; 'gallery', 'post_status' =&gt; 'published', 'paged' =&gt; $paged); $wp_query = new WP_Query($args); if($wp_query-&gt;...
[ { "answer_id": 139865, "author": "Ravi Patel", "author_id": 35477, "author_profile": "https://wordpress.stackexchange.com/users/35477", "pm_score": 1, "selected": false, "text": "<p>1) create one template page on your page-templates dir in landingpage.php with this code</p>\n\n<pre><code...
2014/04/01
[ "https://wordpress.stackexchange.com/questions/139880", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38585/" ]
I have a custom query that goes looks like this: ``` $temp = $wp_query; $wp_query = null; $args = array('posts_per_page' => 5, 'post_type' => 'gallery', 'post_status' => 'published', 'paged' => $paged); $wp_query = new WP_Query($args); if($wp_query->have_posts()): wh...
After some research I came to conclusion that this splash screen will destroy the website SEO and the usability, so I have decided not to add this kind of page.
139,899
<p>I have created a custom meta box which I have pasted in functions.php (minus the <code>&lt;?php</code> call of course)</p> <p>I have two fields in this meta box, one is labeled 'Primary Title' and the other is labeled 'Secondary Title'.</p> <p>How do I call data from each of these boxes <em>individually</em> so th...
[ { "answer_id": 139906, "author": "Eduard Coumans", "author_id": 49769, "author_profile": "https://wordpress.stackexchange.com/users/49769", "pm_score": 4, "selected": true, "text": "<p>Meta boxes are saving data at each post (<code>$post_id</code>)</p>\n\n<pre><code>$value = get_post_met...
2014/04/01
[ "https://wordpress.stackexchange.com/questions/139899", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
I have created a custom meta box which I have pasted in functions.php (minus the `<?php` call of course) I have two fields in this meta box, one is labeled 'Primary Title' and the other is labeled 'Secondary Title'. How do I call data from each of these boxes *individually* so that I can insert them into the template...
Meta boxes are saving data at each post (`$post_id`) ``` $value = get_post_meta($post_id, 'name', true); ``` name = 'dbt\_text' or 'dbt\_text1' so ``` $value = get_post_meta($post_id, 'dbt_text', true); $value1 = get_post_meta($post_id, 'dbt_text1', true); ``` ~ [more info on get\_post\_meta](http://codex.wordp...
139,900
<p>I have customised index.php to display 6 posts: </p> <pre><code>&lt;?php // Get header get_header(); ?&gt; &lt;div id="primary"&gt; &lt;?php // Begin paginate and loop $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query-&gt;query('showposts=6'.'&amp;paged='.$paged); if ($wp_que...
[ { "answer_id": 139906, "author": "Eduard Coumans", "author_id": 49769, "author_profile": "https://wordpress.stackexchange.com/users/49769", "pm_score": 4, "selected": true, "text": "<p>Meta boxes are saving data at each post (<code>$post_id</code>)</p>\n\n<pre><code>$value = get_post_met...
2014/04/01
[ "https://wordpress.stackexchange.com/questions/139900", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37548/" ]
I have customised index.php to display 6 posts: ``` <?php // Get header get_header(); ?> <div id="primary"> <?php // Begin paginate and loop $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query('showposts=6'.'&paged='.$paged); if ($wp_query->have_posts()) : while ( have_pos...
Meta boxes are saving data at each post (`$post_id`) ``` $value = get_post_meta($post_id, 'name', true); ``` name = 'dbt\_text' or 'dbt\_text1' so ``` $value = get_post_meta($post_id, 'dbt_text', true); $value1 = get_post_meta($post_id, 'dbt_text1', true); ``` ~ [more info on get\_post\_meta](http://codex.wordp...
139,905
<p>I have a custom post type "people". For each person, I can enter the following custom fields: "address", "occupation" and "pictures".</p> <p>In the single-people.php I display the address and the occupation. In addition, this single template contains a gallery button - when the website user clicks on it I want to t...
[ { "answer_id": 139906, "author": "Eduard Coumans", "author_id": 49769, "author_profile": "https://wordpress.stackexchange.com/users/49769", "pm_score": 4, "selected": true, "text": "<p>Meta boxes are saving data at each post (<code>$post_id</code>)</p>\n\n<pre><code>$value = get_post_met...
2014/04/01
[ "https://wordpress.stackexchange.com/questions/139905", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48132/" ]
I have a custom post type "people". For each person, I can enter the following custom fields: "address", "occupation" and "pictures". In the single-people.php I display the address and the occupation. In addition, this single template contains a gallery button - when the website user clicks on it I want to takes the u...
Meta boxes are saving data at each post (`$post_id`) ``` $value = get_post_meta($post_id, 'name', true); ``` name = 'dbt\_text' or 'dbt\_text1' so ``` $value = get_post_meta($post_id, 'dbt_text', true); $value1 = get_post_meta($post_id, 'dbt_text1', true); ``` ~ [more info on get\_post\_meta](http://codex.wordp...
139,907
<p>I found a CAPTCHA script online for a self-made contact form on my site.</p> <p>In my theme folder I have a file called <code>captcha_code_file.php</code>:</p> <pre><code>&lt;?php /* * * this code is based on captcha code by Simon Jarvis * http://www.white-hat-web-design.co.uk/articles/php-captcha.php * * This p...
[ { "answer_id": 140271, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 3, "selected": true, "text": "<p>The definitive solution with session is.. do not use session.</p>\n\n<p>As example in your form, you can outpu...
2014/04/01
[ "https://wordpress.stackexchange.com/questions/139907", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
I found a CAPTCHA script online for a self-made contact form on my site. In my theme folder I have a file called `captcha_code_file.php`: ``` <?php /* * * this code is based on captcha code by Simon Jarvis * http://www.white-hat-web-design.co.uk/articles/php-captcha.php * * This program is free software; you can re...
The definitive solution with session is.. do not use session. As example in your form, you can output 3 fields: * an image field -> the captcha image * a text field -> to allow users to insert the characters * an hidden field -> contain the *solution* but encripted using `wp_create_nonce` In this way when the form i...
139,911
<p>I have a class which loads the image sliders on some add_action. There is a function/method "render_slider" which renders the sliders on the page based on the slider selected. The theme tries to get the image slider object before the sliders are loaded.</p> <p>I tried with init,plugins_loaded,to load the slider.<...
[ { "answer_id": 139925, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 1, "selected": false, "text": "<p><code>setup_theme</code> run on init theme, before <code>after_setup_theme</code>.</p>\n\n<p>The follow order on ...
2014/04/01
[ "https://wordpress.stackexchange.com/questions/139911", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29259/" ]
I have a class which loads the image sliders on some add\_action. There is a function/method "render\_slider" which renders the sliders on the page based on the slider selected. The theme tries to get the image slider object before the sliders are loaded. I tried with init,plugins\_loaded,to load the slider. But stil...
`setup_theme` run on init theme, before `after_setup_theme`. The follow order on frontend, was fired in my test: 1. load\_textdomain 2. plugins\_loaded 3. auth\_cookie\_valid 4. set\_current\_user 5. sanitize\_comment\_cookies 6. setup\_theme 7. after\_setup\_theme 8. init
139,930
<p>I just recently set up a local WordPress development environment and imported the content from the live site into it using WordPress' built-in export and import functionality.</p> <p>Unfortunately, this showed up in the header, and is making the local site extremely slow when working offline:</p> <pre><code>&lt;li...
[ { "answer_id": 139932, "author": "David Hunter", "author_id": 49779, "author_profile": "https://wordpress.stackexchange.com/users/49779", "pm_score": 2, "selected": false, "text": "<p>It could be a configuration setting stored outside the files, and in the database instead. Using phpMyAd...
2014/04/01
[ "https://wordpress.stackexchange.com/questions/139930", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43552/" ]
I just recently set up a local WordPress development environment and imported the content from the live site into it using WordPress' built-in export and import functionality. Unfortunately, this showed up in the header, and is making the local site extremely slow when working offline: ``` <link rel="stylesheet" id="...
There needs to be a way to turn this off, because this was terribly slow for me too. I did find this plugin will disable it: [Disable Google Fonts](http://wordpress.org/plugins/disable-google-fonts/)
139,951
<p>I'm a WordPress rookie. I've added a custom field to my "Category" taxonomy. The custom field is "custom_order" and its purpose is to hold a number so that my categories can be sorted and displayed in the order I choose.</p> <p>My problem is that I can't get them to sort; I can display the categories, and 'echo' ea...
[ { "answer_id": 139932, "author": "David Hunter", "author_id": 49779, "author_profile": "https://wordpress.stackexchange.com/users/49779", "pm_score": 2, "selected": false, "text": "<p>It could be a configuration setting stored outside the files, and in the database instead. Using phpMyAd...
2014/04/01
[ "https://wordpress.stackexchange.com/questions/139951", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49783/" ]
I'm a WordPress rookie. I've added a custom field to my "Category" taxonomy. The custom field is "custom\_order" and its purpose is to hold a number so that my categories can be sorted and displayed in the order I choose. My problem is that I can't get them to sort; I can display the categories, and 'echo' each catego...
There needs to be a way to turn this off, because this was terribly slow for me too. I did find this plugin will disable it: [Disable Google Fonts](http://wordpress.org/plugins/disable-google-fonts/)
139,953
<p>I'm trying to build a theme, I want to control the length of the post excerpts by doing something like this in functions.php:</p> <pre><code>function theme_excerpt_length( $length ) { return 45; } add_filter( 'excerpt_length', 'theme_excerpt_length', 999 ); </code></pre> <p>But it doesn't seem to have the desi...
[ { "answer_id": 139960, "author": "Oturia", "author_id": 48943, "author_profile": "https://wordpress.stackexchange.com/users/48943", "pm_score": 2, "selected": false, "text": "<p>This is the function I use for controlling excerpt/content lengths, especially in situations where the end use...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/139953", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49784/" ]
I'm trying to build a theme, I want to control the length of the post excerpts by doing something like this in functions.php: ``` function theme_excerpt_length( $length ) { return 45; } add_filter( 'excerpt_length', 'theme_excerpt_length', 999 ); ``` But it doesn't seem to have the desired effect of reducing len...
The are two quick ways to display custom excerpt lengths in your theme using `wp_trim_words`. Remember, if you use `the_excerpt()`, your excerpt length will always be a maximum of 55, never more. If you use `the_content()` on the other hand, you can specify an excerpt length of more than 55 words. Use the following to...
139,957
<p>I need to redirect the page based on the query vars in my plugin admin menu. I don't know where I can hook in to read the query vars or the GET vars order to decide if the page needs to be redirected.</p>
[ { "answer_id": 139966, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>You can check the <code>$current_screen</code> on the <a href=\"http://codex.wordpress.org/Plugin_API/Action_Refere...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/139957", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20014/" ]
I need to redirect the page based on the query vars in my plugin admin menu. I don't know where I can hook in to read the query vars or the GET vars order to decide if the page needs to be redirected.
You can check the `$current_screen` on the [`current_screen`](http://codex.wordpress.org/Plugin_API/Action_Reference/current_screen) action, and redirect after checking some GET conditions: ``` function wpd_current_screen( $current_screen ) { if ( 'toplevel_page_your_menu_item_id' == $current_screen->base ) { ...
139,967
<p>I have an option screen for my plugin, it's just a simple form.</p> <pre><code>&lt;div class="wrap"&gt; &lt;h2&gt;SoundCloud Podcast Importer Options&lt;/h2&gt; &lt;hr/&gt; &lt;h2&gt;Add a show&lt;/h2&gt; &lt;form method="post" action="../wp-content/plugins/SCImp-Pro/scimp_add_feed.php"&gt; ...
[ { "answer_id": 139969, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>Well first of all, it seems that what you're doing would be far easier, and more in line with WordPress best-pract...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/139967", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47881/" ]
I have an option screen for my plugin, it's just a simple form. ``` <div class="wrap"> <h2>SoundCloud Podcast Importer Options</h2> <hr/> <h2>Add a show</h2> <form method="post" action="../wp-content/plugins/SCImp-Pro/scimp_add_feed.php"> <p>Feed URL: <input type="text" name="scimp_feed_url...
You said your original code is working. I think you should try using wp\_redirect but you can't output any HTML/Headers for that. Untested, but try the following: Note: intentionally missed out the html/body tags... ``` <?php require_once('../../../wp-config.php'); require_once('../../../wp-load.php'); global $wpdb; ...
139,981
<p>Besides the urls of posts, pages and categories, I need my site's sitemap to include the urls of various pages that display data coming from an external source other than the WP database (Rails API).</p> <p>Is there a hook to which I can add a filter so that once Dynamic Sitemap Generation takes place, I can then a...
[ { "answer_id": 140224, "author": "Pietro", "author_id": 49410, "author_profile": "https://wordpress.stackexchange.com/users/49410", "pm_score": 2, "selected": false, "text": "<p>This is not a solution to my question but it helps me to solve my problem in Wordpress, and I want to share it...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/139981", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49410/" ]
Besides the urls of posts, pages and categories, I need my site's sitemap to include the urls of various pages that display data coming from an external source other than the WP database (Rails API). Is there a hook to which I can add a filter so that once Dynamic Sitemap Generation takes place, I can then append thes...
This is the [solution](http://wordpress.org/support/topic/dynamic-sitemap-generation-hook?replies=7) from Peter Baylies (Plugin Author) ``` add_filter( 'option_aioseop_options', 'itdge_sitemap_addl_pages' ); function itdge_sitemap_addl_pages( $option ) { if ( !empty( $option ) && !empty( $option['module...
139,982
<p>First of all, I'm not using WP JWPlayer Plugin. (And i don't want it. And thats the another story)</p> <hr> <p>Well in the Template file:</p> <pre><code>wp_register_script('myJW', get_bloginfo('template_url') . '/jwplayer.js'); wp_enqueue_script('myJW'); ?&gt; &lt;div id='myJWPlayer'&gt;&lt;/div&gt; &lt;script&g...
[ { "answer_id": 139984, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": true, "text": "<p>You need to properly enqueue your script. You should hook your script to the </p>\n\n<pre><code>function...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/139982", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35907/" ]
First of all, I'm not using WP JWPlayer Plugin. (And i don't want it. And thats the another story) --- Well in the Template file: ``` wp_register_script('myJW', get_bloginfo('template_url') . '/jwplayer.js'); wp_enqueue_script('myJW'); ?> <div id='myJWPlayer'></div> <script> jQuery(document).ready(function(){ j...
You need to properly enqueue your script. You should hook your script to the ``` function enqueue_custom_script() { wp_register_script('myJW', get_bloginfo('template_url') . '/jwplayer.js'); wp_enqueue_script('myJW'); } add_action( 'wp_enqueue_scripts', 'enqueue_custom_script' ); ```
139,998
<p>Is there a way to "remove the widget from available widgets" after you've activated it once on some area? The idea is to allow user to activate only one instance of it.</p>
[ { "answer_id": 143480, "author": "Douglas.Sesar", "author_id": 19945, "author_profile": "https://wordpress.stackexchange.com/users/19945", "pm_score": 1, "selected": false, "text": "<p>You can create a one-time-use widget with the following example found here: <a href=\"https://codex.wor...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/139998", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48382/" ]
Is there a way to "remove the widget from available widgets" after you've activated it once on some area? The idea is to allow user to activate only one instance of it.
You can create a one-time-use widget with the following example found here: [wp\_register\_sidebar\_widget](https://codex.wordpress.org/Function_Reference/wp_register_sidebar_widget) > > The following code will create a widget called "Your Widget" which will become available in the WordPress Administrative Panels. Th...
140,000
<p>On a single Post page I have a side bar displaying up to three other, related posts. How can I exclude both Sticky Posts and the Current post?</p> <p>I know how to exclude the Current post and how to exclude Sticky Posts by using post_not_in in a WP_Query, see code example below. But I guess you can not use post_no...
[ { "answer_id": 140003, "author": "Marc Dingena", "author_id": 28660, "author_profile": "https://wordpress.stackexchange.com/users/28660", "pm_score": 0, "selected": false, "text": "<p>You should add the current post's ID to the array of IDs of your sticky posts, and pass this single arra...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/140000", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40498/" ]
On a single Post page I have a side bar displaying up to three other, related posts. How can I exclude both Sticky Posts and the Current post? I know how to exclude the Current post and how to exclude Sticky Posts by using post\_not\_in in a WP\_Query, see code example below. But I guess you can not use post\_not\_in ...
Whenever an array of arguments is a function parameter in a WP core function it is parsed via [`wp_parse_args`](https://codex.wordpress.org/Function_Reference/wp_parse_args) and almost always [extracted](http://php.net/extract) into single variables. I.e. *no, you cannot use the same argument twice*. What you want ...
140,002
<p>Accidently, I have changed my wordpress address url from my dashboard. Now I am not able to sign in to get it changed. This is where I have installed wordpress - <a href="http://www.abc.com/folder" rel="nofollow">http://www.abc.com/folder</a>, but accidently, I changed the wordpress address URL to <a href="http://ww...
[ { "answer_id": 140006, "author": "Thyamarkos", "author_id": 49168, "author_profile": "https://wordpress.stackexchange.com/users/49168", "pm_score": 0, "selected": false, "text": "<p>I think the easiest way to handle this is to take the script from <a href=\"https://interconnectit.com/pro...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/140002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49802/" ]
Accidently, I have changed my wordpress address url from my dashboard. Now I am not able to sign in to get it changed. This is where I have installed wordpress - <http://www.abc.com/folder>, but accidently, I changed the wordpress address URL to <http://www.abc.com> Please help me...
By far the easiest fix is [to edit `wp-config.php`](http://codex.wordpress.org/Changing_The_Site_URL#Edit_wp-config.php) to define two constants. (s)FTP into your site, or use a host supplied file manager, and add: ``` define( 'WP_SITEURL', 'http://www.abc.com/folder' ); define( 'WP_HOME', 'http://www.abc.com/folde...
140,033
<p>I really hope that someone can help. I would like to load random posts on the homepage when a "LOAD NEW MESSAGE" button is clicked. </p> <p>We have 200 short messages loaded as posts in Wordpress. ON the homepage we would like people to be able to click a button to reload new messages - but without the page being r...
[ { "answer_id": 140037, "author": "user48752", "author_id": 48752, "author_profile": "https://wordpress.stackexchange.com/users/48752", "pm_score": 1, "selected": false, "text": "<p>This is just a similar example that would do something you have question about. Every time the user clicks ...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/140033", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20377/" ]
I really hope that someone can help. I would like to load random posts on the homepage when a "LOAD NEW MESSAGE" button is clicked. We have 200 short messages loaded as posts in Wordpress. ON the homepage we would like people to be able to click a button to reload new messages - but without the page being refreshed. ...
I've been playing with ajax for the past couple days - I like to go the hook route so first lets set up our ajax call: ``` $('#buttonID').click(function(){ $.ajax({ url: '/wp-admin/admin-ajax.php', type: 'GET', data: { 'action' : 'implement_ajax' }, dataType: 'ht...
140,035
<p>I'm trying to echo a form, when the user is logged in, I get this in the browser when I upload the code:</p> <p><code>syntax error, unexpected 'endwhile' (T_ENDWHILE) in</code></p> <p>My code:</p> <pre><code>&lt;?php /* Template Name: Customers */ get_header(); ?&gt; &lt;div id="primary" class="site-content...
[ { "answer_id": 140037, "author": "user48752", "author_id": 48752, "author_profile": "https://wordpress.stackexchange.com/users/48752", "pm_score": 1, "selected": false, "text": "<p>This is just a similar example that would do something you have question about. Every time the user clicks ...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/140035", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm trying to echo a form, when the user is logged in, I get this in the browser when I upload the code: `syntax error, unexpected 'endwhile' (T_ENDWHILE) in` My code: ``` <?php /* Template Name: Customers */ get_header(); ?> <div id="primary" class="site-content"> <div id="content" role="main"> ...
I've been playing with ajax for the past couple days - I like to go the hook route so first lets set up our ajax call: ``` $('#buttonID').click(function(){ $.ajax({ url: '/wp-admin/admin-ajax.php', type: 'GET', data: { 'action' : 'implement_ajax' }, dataType: 'ht...
140,051
<p>When using <code>wp_enqueue_script</code> in a plugin, I have always been told to use an <code>add_action</code> :</p> <pre><code>function add_my_css_and_my_js_files(){ wp_enqueue_script('jquery-validate-min', plugins_url('jquery_validate_min.js', __FILE__ ) } add_action('wp_enqueue_scripts', "add_my_css_a...
[ { "answer_id": 140053, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": true, "text": "<p>It is required, actually.</p>\n\n<p>There's no real difference between themes and plugins as such. Neither of them ...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/140051", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
When using `wp_enqueue_script` in a plugin, I have always been told to use an `add_action` : ``` function add_my_css_and_my_js_files(){ wp_enqueue_script('jquery-validate-min', plugins_url('jquery_validate_min.js', __FILE__ ) } add_action('wp_enqueue_scripts', "add_my_css_and_my_js_files"); ``` How come t...
It is required, actually. There's no real difference between themes and plugins as such. Neither of them should take actions on merely being loaded, they should use action hooks on functions to have things happen in the correct ordering.
140,052
<h2><strong>Overview:</strong></h2> <p>I was authoring a child-theme, and realized that functions.php was causing problems with the media-library and caused a "white-screen" to appear after editing a post. I fixed the issue by removing all content from my functions.php, but I don't know what was causing this.</p> <hr...
[ { "answer_id": 140054, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": false, "text": "<p>The first line is just an HTML comment outside the scope of PHP. It'll output with every response and crea...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/140052", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41479/" ]
**Overview:** ------------- I was authoring a child-theme, and realized that functions.php was causing problems with the media-library and caused a "white-screen" to appear after editing a post. I fixed the issue by removing all content from my functions.php, but I don't know what was causing this. --- Info: ----- ...
The first line is just an HTML comment outside the scope of PHP. It'll output with every response and creates all the kinds of headaches you're experiencing. Solution? Remove it, or make it a PHP comment: ``` <?php /* In a child theme, all of the functions of the parent theme are present, unless overridden here...
140,059
<p>I have a plugin which uses the <code>transition_post_status</code> hook, to fire a custom function on post update. But I don't know why its not working. Here is the code</p> <pre><code> add_action('transition_post_status', 'pmc_update_notification',10,3); function pmc_update_notification($new_status, $old_status, ...
[ { "answer_id": 140054, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": false, "text": "<p>The first line is just an HTML comment outside the scope of PHP. It'll output with every response and crea...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/140059", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49825/" ]
I have a plugin which uses the `transition_post_status` hook, to fire a custom function on post update. But I don't know why its not working. Here is the code ``` add_action('transition_post_status', 'pmc_update_notification',10,3); function pmc_update_notification($new_status, $old_status, $post) { echo 'function c...
The first line is just an HTML comment outside the scope of PHP. It'll output with every response and creates all the kinds of headaches you're experiencing. Solution? Remove it, or make it a PHP comment: ``` <?php /* In a child theme, all of the functions of the parent theme are present, unless overridden here...
140,086
<p>I asked this in stackovorflow under javascript and was informed not possible so I trying here</p> <p>I have a shortcode for a opt-in form and I want it to pop up when a image is clicked</p> <p>I tried the function in both the <code>Header Scripts</code> and my <code>functions.php</code> file.</p> <pre><code>&lt;i...
[ { "answer_id": 140087, "author": "Andrew Bartel", "author_id": 17879, "author_profile": "https://wordpress.stackexchange.com/users/17879", "pm_score": 3, "selected": true, "text": "<p>It's certainly possible but you're probably looking at doing an ajax request on the image click which in...
2014/04/02
[ "https://wordpress.stackexchange.com/questions/140086", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13698/" ]
I asked this in stackovorflow under javascript and was informed not possible so I trying here I have a shortcode for a opt-in form and I want it to pop up when a image is clicked I tried the function in both the `Header Scripts` and my `functions.php` file. ``` <img src="someimage.png" onclick="executeShortCode()" /...
It's certainly possible but you're probably looking at doing an ajax request on the image click which in turn executes the short code and returns the output. This involves three distinct steps, binding the ajax request to an action, executing the ajax request and handling the response, and actually writing the script t...
140,114
<p>I've got the following loop (this is on a <code>single</code> page, not the <code>index.php</code>):</p> <pre><code>$top_meta_cat_args = array( 'posts_per_page' =&gt; 9, 'post_type' =&gt; 'post', 'meta_key' =&gt; 'top-radio', 'meta_value' =&gt; 'top-yes', 'post_status' =&gt; 'publish', '...
[ { "answer_id": 140087, "author": "Andrew Bartel", "author_id": 17879, "author_profile": "https://wordpress.stackexchange.com/users/17879", "pm_score": 3, "selected": true, "text": "<p>It's certainly possible but you're probably looking at doing an ajax request on the image click which in...
2014/04/03
[ "https://wordpress.stackexchange.com/questions/140114", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33541/" ]
I've got the following loop (this is on a `single` page, not the `index.php`): ``` $top_meta_cat_args = array( 'posts_per_page' => 9, 'post_type' => 'post', 'meta_key' => 'top-radio', 'meta_value' => 'top-yes', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC' ); ``` ...
It's certainly possible but you're probably looking at doing an ajax request on the image click which in turn executes the short code and returns the output. This involves three distinct steps, binding the ajax request to an action, executing the ajax request and handling the response, and actually writing the script t...
140,154
<p>I have a function (it deals with using <code>preg_replace_callback</code>to replace Image URLs with URLs/paths to the uploads directory - lets call it <code>replaceImgUrls()</code>) which is then passed into <code>add_filter('the_content', 'replaceImgUrls')</code>. This works fine and stuff but on posts where I have...
[ { "answer_id": 140193, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>For posts is set up by loop (see <a href=\"http://queryposts.com/function/setup_postdata/\" rel=\"nofollow\"><code>...
2014/04/03
[ "https://wordpress.stackexchange.com/questions/140154", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27548/" ]
I have a function (it deals with using `preg_replace_callback`to replace Image URLs with URLs/paths to the uploads directory - lets call it `replaceImgUrls()`) which is then passed into `add_filter('the_content', 'replaceImgUrls')`. This works fine and stuff but on posts where I have added pagination (`<!--nextpage-->`...
Ok so I worked out what I had to do. @Rarst gave me some guidance which helped massively and I think his idea (in the comments of his question) would work but I haven't actually tested it. Anyway, I fixed it by adding a `$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;` variable in, and, having changed `...
140,157
<p>I have created a widget that creates forms. I am using the Twitter Bootstrap framework in order to style those forms. I have two instances of WP:</p> <ul> <li><p>One is using the Alterna theme, which uses Bootstrap too. The forms look great on that theme.</p></li> <li><p>The other one uses OptimizerPress, which do...
[ { "answer_id": 140193, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>For posts is set up by loop (see <a href=\"http://queryposts.com/function/setup_postdata/\" rel=\"nofollow\"><code>...
2014/04/03
[ "https://wordpress.stackexchange.com/questions/140157", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48558/" ]
I have created a widget that creates forms. I am using the Twitter Bootstrap framework in order to style those forms. I have two instances of WP: * One is using the Alterna theme, which uses Bootstrap too. The forms look great on that theme. * The other one uses OptimizerPress, which does not use Bootstrap. The proble...
Ok so I worked out what I had to do. @Rarst gave me some guidance which helped massively and I think his idea (in the comments of his question) would work but I haven't actually tested it. Anyway, I fixed it by adding a `$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;` variable in, and, having changed `...
140,162
<p>so I have this in my CSS ...</p> <pre><code> #mainnav li:after { content: url('images/nav-divider.png'); } </code></pre> <p>obviously I need to have it link to 'bloginfo('template_directory'); /images/nav-divider.png' instead but how do I link that correctly seeing as there is PHP in it?</p> <p>Thanks,</p> <p>J...
[ { "answer_id": 140163, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": 0, "selected": false, "text": "<p>You can just use a relative path. For example, if your stylesheet is in <code>/wp-content/themes/mytheme/...
2014/04/03
[ "https://wordpress.stackexchange.com/questions/140162", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49878/" ]
so I have this in my CSS ... ``` #mainnav li:after { content: url('images/nav-divider.png'); } ``` obviously I need to have it link to 'bloginfo('template\_directory'); /images/nav-divider.png' instead but how do I link that correctly seeing as there is PHP in it? Thanks, Josh
You can use [`wp_add_inline_style()`](https://codex.wordpress.org/Function_Reference/wp_add_inline_style). Let's assume you enqueue your css like so ``` add_action( 'wp_enqueue_scripts', 'add_my_style' ); function add_my_style() { wp_enqueue_script( 'my_style', get_template_directory_uri() . '/mystyle.css' ); } ...
140,171
<p>I'd like to remove auto formatting 'wpautop' from specific pages. Here is what I've got, but it doesn't appear to work:</p> <pre><code>if ( is_page ( 'services' ) ) { remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); }; </code></pre> <p>I am quite new to php, I have done some re...
[ { "answer_id": 140177, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 0, "selected": false, "text": "<p>Here's what I've found based off this <a href=\"https://stackoverflow.com/questions/7697465/wordpress-remov...
2014/04/03
[ "https://wordpress.stackexchange.com/questions/140171", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49881/" ]
I'd like to remove auto formatting 'wpautop' from specific pages. Here is what I've got, but it doesn't appear to work: ``` if ( is_page ( 'services' ) ) { remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); }; ``` I am quite new to php, I have done some research to see how to write...
You need to add your function in the `template_redirect` hook. You need to first wait for wordpress to finish loading pages before you can add your hook to remove `wpautop`, otherwise your hook will simply get run over. So your funtion will look like this ``` function pietergoosen_remove_wpautop() { if ( is_page ( 'se...
140,180
<p>How can I get the first post from a WP_Query result?</p> <pre><code>$connected = new WP_Query( array( // Arguments )); // This doesn't work.. echo $connected[0]-&gt;post_name; </code></pre>
[ { "answer_id": 140188, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 5, "selected": true, "text": "<p>If you poke through <code>WP_Query</code> the set of queried posts is saved into <code>posts</code> property and cur...
2014/04/03
[ "https://wordpress.stackexchange.com/questions/140180", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25834/" ]
How can I get the first post from a WP\_Query result? ``` $connected = new WP_Query( array( // Arguments )); // This doesn't work.. echo $connected[0]->post_name; ```
If you poke through `WP_Query` the set of queried posts is saved into `posts` property and current post gets assigned to `post` one (each time loop iterates). So you could do `$connected->posts[0]` if you need to just fetch that, but it might be more convenient to do `$connected->the_post();` then `$connected->post` i...
140,198
<p>I have a static default wordpress home page. As you know if you have a homepage on wordpress you can not set a permalink through the admin options, you can only set permalinks for non homepages. Does anyone know of a way that I can set a permalink for my homepage? So that when I visit my site at example.com, it auto...
[ { "answer_id": 140199, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 2, "selected": false, "text": "<p>I would set another page as the home page, add a custom template for the home page and put this in it:</p>\n...
2014/04/03
[ "https://wordpress.stackexchange.com/questions/140198", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49894/" ]
I have a static default wordpress home page. As you know if you have a homepage on wordpress you can not set a permalink through the admin options, you can only set permalinks for non homepages. Does anyone know of a way that I can set a permalink for my homepage? So that when I visit my site at example.com, it automat...
I would set another page as the home page, add a custom template for the home page and put this in it: ``` <?php wp_redirect( get_permalink( $id ), 301 ); exit; ?> ```
140,203
<p>My plugin uses a metabox to save post meta. I have three option in the metabox. Everything is saving/updating/deleting correctly except for this:</p> <pre><code>add_post_meta( $post_id, $meta_key_duration, $new_meta_value_duration, true ); </code></pre> <p>If I echo out the values right before this call:</p> <pre...
[ { "answer_id": 140208, "author": "SierraTR", "author_id": 49035, "author_profile": "https://wordpress.stackexchange.com/users/49035", "pm_score": 0, "selected": false, "text": "<p>According to the <a href=\"https://codex.wordpress.org/Roles_and_Capabilities\" rel=\"nofollow\">Codex: Role...
2014/04/03
[ "https://wordpress.stackexchange.com/questions/140203", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8278/" ]
My plugin uses a metabox to save post meta. I have three option in the metabox. Everything is saving/updating/deleting correctly except for this: ``` add_post_meta( $post_id, $meta_key_duration, $new_meta_value_duration, true ); ``` If I echo out the values right before this call: ``` echo $post_id.' '.$meta_key_du...
The ability to set comment status is tied to the "edit\_comment" capability, which is a meta-capability in WordPress. It maps to the "edit\_post" capability, which is another meta-capability that varies depending on whether a post is published or not. In the end, if a post is published, then edit\_comment ends up mapp...
140,221
<p>i have created a smart interface WP based which we use to manage clients..<br> it uses a lot of information and data each time a client is returned / viewed. </p> <p><strong>it is a locked interface and does not have traffic spikes</strong> </p> <p>in the past month i have seen major memory and CPU usage spikes ...
[ { "answer_id": 140208, "author": "SierraTR", "author_id": 49035, "author_profile": "https://wordpress.stackexchange.com/users/49035", "pm_score": 0, "selected": false, "text": "<p>According to the <a href=\"https://codex.wordpress.org/Roles_and_Capabilities\" rel=\"nofollow\">Codex: Role...
2014/04/04
[ "https://wordpress.stackexchange.com/questions/140221", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7990/" ]
i have created a smart interface WP based which we use to manage clients.. it uses a lot of information and data each time a client is returned / viewed. **it is a locked interface and does not have traffic spikes** in the past month i have seen major memory and CPU usage spikes so, i have installed the debug...
The ability to set comment status is tied to the "edit\_comment" capability, which is a meta-capability in WordPress. It maps to the "edit\_post" capability, which is another meta-capability that varies depending on whether a post is published or not. In the end, if a post is published, then edit\_comment ends up mapp...
140,240
<p>I currently have a custom post type named "blog". On registration, every user gets automatically a post "blog" linked with their user ID.</p> <p>This custom post type queries another post type named "articles". Those articles are written by the user and then showed in their "blog" custom post type.</p> <p>Now, I w...
[ { "answer_id": 140256, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 0, "selected": false, "text": "<p>I haven't tested this, but in my head it works perfectly! What we do is put add a <code>pre_get_posts</code...
2014/04/04
[ "https://wordpress.stackexchange.com/questions/140240", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49297/" ]
I currently have a custom post type named "blog". On registration, every user gets automatically a post "blog" linked with their user ID. This custom post type queries another post type named "articles". Those articles are written by the user and then showed in their "blog" custom post type. Now, I would like to show...
I finally found a workaround for this, here it goes : I used "get\_user" with a "has\_custom\_post\_type" function to query every user with at least one article written and then added the link to their blog CPT by adding "/blog/display\_name" in the href. Here goes the code ``` <?php $blog_url = get_bloginfo('home'...
140,243
<p>The WPML plugin filter's <code>home_url</code> in order to provide a link to the home page specific to the language you are viewing. (So if you are reading a Spanish page home_url() will point you to <code>http://example.com/es</code>). I need to disable for a site that will not have language-specific homepages. So ...
[ { "answer_id": 141467, "author": "Andrea Sciamanna", "author_id": 7291, "author_profile": "https://wordpress.stackexchange.com/users/7291", "pm_score": 0, "selected": false, "text": "<p>What about taking a different approach?</p>\n\n<p>Keep the filter and in WPML -> Languages, chose \"Us...
2014/04/04
[ "https://wordpress.stackexchange.com/questions/140243", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
The WPML plugin filter's `home_url` in order to provide a link to the home page specific to the language you are viewing. (So if you are reading a Spanish page home\_url() will point you to `http://example.com/es`). I need to disable for a site that will not have language-specific homepages. So I went digging into the ...
I found that it required removing 4 filters/actions to undo WPML's `home_url` modification. Since I didn't know what *else* this might break, I ended up changing my site's logo to use `site_url()` which in my case was the same, but not changed by WPML. ``` function disable_things(){ remove_filter( 'page_link', arr...
140,244
<p>I'm using a site-wide function to add css to the <code>&lt;head&gt;</code> of the page pull in featured images of various as a responsive page background. It works great across the rest of my site but fails on a page where I'm calling posts from a custom post type using <code>WP_Query</code>. I think this is because...
[ { "answer_id": 140252, "author": "snaper9", "author_id": 49916, "author_profile": "https://wordpress.stackexchange.com/users/49916", "pm_score": 0, "selected": false, "text": "<p>WP_Query does use $post. A full list of Methods and Properties can be found <a href=\"http://codex.wordpress....
2014/04/04
[ "https://wordpress.stackexchange.com/questions/140244", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36275/" ]
I'm using a site-wide function to add css to the `<head>` of the page pull in featured images of various as a responsive page background. It works great across the rest of my site but fails on a page where I'm calling posts from a custom post type using `WP_Query`. I think this is because `WP_Query` doesn't use the sta...
`$port_query->the_post();` should set the `$post` `global`. That isn't the problem. The problem is that the you are trying to use `$post` before your secondary Loop runs (99% sure). You've hooked the `bkg_featured_image()` function to `wp_head`. `wp_head` runs in the header of the document, which, unless you are care...
140,292
<p>Having a little problem with URL rewrites.</p> <p>Trying to get the following URL to display all the sermons in 2014</p> <pre><code>http://example.com/sermons/2014 </code></pre> <p>Currently it is looking for a sermon called 2014</p> <pre><code>function caffeine_rewite_rules(){ add_rewrite_rule("sermons/([0-...
[ { "answer_id": 140294, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": 2, "selected": false, "text": "<p>I believe this should handle it for you. Including monthly and daily. It also catches if you have defined...
2014/04/04
[ "https://wordpress.stackexchange.com/questions/140292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13843/" ]
Having a little problem with URL rewrites. Trying to get the following URL to display all the sermons in 2014 ``` http://example.com/sermons/2014 ``` Currently it is looking for a sermon called 2014 ``` function caffeine_rewite_rules(){ add_rewrite_rule("sermons/([0-9]{4})/?$", 'index.php post_type=ctc_sermon&...
I believe this should handle it for you. Including monthly and daily. It also catches if you have defined a different rewrite slug than your custom post type slug. ``` /* This function handles setting up Date archive rewrite rules for * ANY custom post type - You pass the CPT, and it will use the * re-written slug i...
140,307
<p>When I downloaded the latest version 3.8.1, inside <code>wp-include/js</code> there is a jQuery folder.</p> <p>Can I assume that WordPress will always include it, meaning I don't have to make my own call? E.g.</p> <pre><code>wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.mi...
[ { "answer_id": 140309, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 3, "selected": false, "text": "<p>You still need to enqueue it, but you do not need to register it, as it is registered automatically.</p>\n" ...
2014/04/04
[ "https://wordpress.stackexchange.com/questions/140307", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49622/" ]
When I downloaded the latest version 3.8.1, inside `wp-include/js` there is a jQuery folder. Can I assume that WordPress will always include it, meaning I don't have to make my own call? E.g. ``` wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', array(), null, false); w...
Yes, jQuery is part of WordPress core. But--it can become outdated, because jQuery updates can happen in between WP releases. The recent release of WordPress does use a very recent version of jQuery. By default, ``` wp_enqueue_script('jquery') ``` grabs jQuery from the core at /wp-includes/js/jquery/jquery.js. ...
140,322
<p>I am running the most recent version of WP-CLI on my mac. I do all WordPress development within Vagrant, but would like to run WP-CLI commands in the host machine. I have a domain alias from "dev.mysite.com" to the IP of my server so it can be accessed through my web browser through an HTTP request.</p> <p>When try...
[ { "answer_id": 140350, "author": "sanchothefat", "author_id": 1733, "author_profile": "https://wordpress.stackexchange.com/users/1733", "pm_score": 2, "selected": false, "text": "<p>Have you tried updating wp-config.php to change the database host?</p>\n\n<p>Alternatively why not use com...
2014/04/05
[ "https://wordpress.stackexchange.com/questions/140322", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/30778/" ]
I am running the most recent version of WP-CLI on my mac. I do all WordPress development within Vagrant, but would like to run WP-CLI commands in the host machine. I have a domain alias from "dev.mysite.com" to the IP of my server so it can be accessed through my web browser through an HTTP request. When trying to run...
Since the issue is probably DB configuration you could try adjusting it conditionally in `wp-config.php`: ``` if ( defined( 'WP_CLI' ) ) { define( 'DB_HOST', 'example.com' ); } else { define( 'DB_HOST', 'localhost' ); } ```
140,351
<p>I have registered three custom taxonomies. All three of these custom taxonomies are attached to my custom post type.</p> <p>There is only one taxonomy out of the three registered, that I would like not accessible what so ever on the frontend of the website.</p> <p>What is the best solution for this?</p> <p>I have...
[ { "answer_id": 140352, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": -1, "selected": false, "text": "<p>To guarantee that your taxonomy is never queried on the front end, you could strip it from all front end qu...
2014/04/05
[ "https://wordpress.stackexchange.com/questions/140351", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9579/" ]
I have registered three custom taxonomies. All three of these custom taxonomies are attached to my custom post type. There is only one taxonomy out of the three registered, that I would like not accessible what so ever on the frontend of the website. What is the best solution for this? I have been playing around wit...
s\_ha\_dum's answer didn't work for me, but this did: ``` /** * Completely disable term archives for this taxonomy. * @param string $taxonomy WordPress taxnomy name */ function kill_taxonomy_archive($taxonomy){ add_action('pre_get_posts', function($qry) { if (is_admin()) return; if (...
140,353
<p>I haven't done wordpress development in quite some time so it looks like some things have changed (naturally). I'm using codekit to compile my themes sass files and minify my scripts as well. It requires that all files have a specific output path, in other words I can't specify that the style.scss file should compil...
[ { "answer_id": 140355, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Create a theme's <code>style.css</code> as normal but <a href=\"http://codex.wordpress.org/Theme_Development...
2014/04/05
[ "https://wordpress.stackexchange.com/questions/140353", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31648/" ]
I haven't done wordpress development in quite some time so it looks like some things have changed (naturally). I'm using codekit to compile my themes sass files and minify my scripts as well. It requires that all files have a specific output path, in other words I can't specify that the style.scss file should compile t...
Create a theme's `style.css` as normal but [just include the header information](http://codex.wordpress.org/Theme_Development#Theme_Stylesheet). This will be a config file only. The [register](http://codex.wordpress.org/Function_Reference/wp_register_style) and [enqueue](http://codex.wordpress.org/Function_Reference/w...
140,362
<p>I'm currently using the code below to display my breadcrumbs. Which works fine up to a point. What I want is: </p> <p>Home > Level 1 > Level 2 > Level 3</p> <p>What I get is: </p> <p>Home > Level 1 > Level 3</p> <p>It's displaying one parent, so as long as your deepest link is a Level 2 you can't tell the differ...
[ { "answer_id": 140364, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 0, "selected": false, "text": "<p>For hierarchical page breadcrumb navigation, here's what I do:</p>\n\n<pre><code>// Define Parent Page Hie...
2014/04/05
[ "https://wordpress.stackexchange.com/questions/140362", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49971/" ]
I'm currently using the code below to display my breadcrumbs. Which works fine up to a point. What I want is: Home > Level 1 > Level 2 > Level 3 What I get is: Home > Level 1 > Level 3 It's displaying one parent, so as long as your deepest link is a Level 2 you can't tell the difference. But you know, for complex...
Doing same thing in more concise way: ``` function breadcrump_page( $post ) { $format = '<a href="%s" title="%s">%s</a> &gt;'; $anc = array_map( 'get_post', array_reverse( (array) get_post_ancestors( $post ) ) ); $links = array_map( 'get_permalink', $anc ); foreach ( $anc as $i => $apost ) { $title = a...