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
119,879
<p>The problem I'm having is the <strong>keyword page analysis tool</strong> doesn't read my custom fields so I am trying to figure out how to run a filter on them. </p> <p>I found a blog post on Yoast website here <a href="http://yoast.com/wordpress-seo-content-analysis/">here</a> which references this issue and they...
[ { "answer_id": 119880, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 3, "selected": false, "text": "<p>Looking at the filter:</p>\n\n<pre><code>$post_content = apply_filters( 'wpseo_pre_analysis_post_content', ...
2013/10/23
[ "https://wordpress.stackexchange.com/questions/119879", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35203/" ]
The problem I'm having is the **keyword page analysis tool** doesn't read my custom fields so I am trying to figure out how to run a filter on them. I found a blog post on Yoast website here [here](http://yoast.com/wordpress-seo-content-analysis/) which references this issue and they list the filter `wpseo_pre_analys...
Looking at the filter: ``` $post_content = apply_filters( 'wpseo_pre_analysis_post_content', $post->post_content, $post ); ``` it would be a matter of adding your fields content to string being analyzed. You have to do the `get_field()` part right, this is untested: ``` add_filter( 'wpseo_pre_analysis_post_content...
119,881
<p>I need to place in post edit dashboard metabox with post author e-mail (or other user meta fields). So it can be edited when admin reviews this post.</p> <pre><code>$meta_id = get_the_author_meta( 'user_email', $user_id ); $meta_box = array( 'id' =&gt; 'my-meta-box', 'title' =&gt; 'DANE FIRMY', 'page' ...
[ { "answer_id": 119883, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": false, "text": "<p>You can use the following:</p>\n\n<pre><code>/**\n * Gets the author of the specified post. Can also be ...
2013/10/23
[ "https://wordpress.stackexchange.com/questions/119881", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40822/" ]
I need to place in post edit dashboard metabox with post author e-mail (or other user meta fields). So it can be edited when admin reviews this post. ``` $meta_id = get_the_author_meta( 'user_email', $user_id ); $meta_box = array( 'id' => 'my-meta-box', 'title' => 'DANE FIRMY', 'page' => 'post', 'cont...
``` add_action( 'edit_form_after_title', 'myprefix_edit_form_after_title' ); function myprefix_edit_form_after_title() { global $post; $author_id=$post->post_author; $authord = get_the_author_meta( 'user_email', $author_id); echo $authord; } ``` With this function I was able to display post author e-m...
119,882
<p>I'm using a plugin that shows content only to specific user roles. This content is surrounded by a shortcode tag to make it invisible to other other user roles. Now I'd like to call other shortcodes inside that restricted content.</p> <p>I understand that I need to set the plugins shortcodes up so that they use <co...
[ { "answer_id": 119883, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": false, "text": "<p>You can use the following:</p>\n\n<pre><code>/**\n * Gets the author of the specified post. Can also be ...
2013/10/23
[ "https://wordpress.stackexchange.com/questions/119882", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27120/" ]
I'm using a plugin that shows content only to specific user roles. This content is surrounded by a shortcode tag to make it invisible to other other user roles. Now I'd like to call other shortcodes inside that restricted content. I understand that I need to set the plugins shortcodes up so that they use `do_shortcode...
``` add_action( 'edit_form_after_title', 'myprefix_edit_form_after_title' ); function myprefix_edit_form_after_title() { global $post; $author_id=$post->post_author; $authord = get_the_author_meta( 'user_email', $author_id); echo $authord; } ``` With this function I was able to display post author e-m...
119,916
<p>I have implemented my own pingback client and sent out pingbacks to different hosts.</p> <p>Some wordpress instances responded to the XML-RPC pingback request with a <code>faultCode</code> of <code>0</code> and an empty <code>faultMessage</code>.</p> <p>What can be the cause for that? </p>
[ { "answer_id": 119883, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": false, "text": "<p>You can use the following:</p>\n\n<pre><code>/**\n * Gets the author of the specified post. Can also be ...
2013/10/24
[ "https://wordpress.stackexchange.com/questions/119916", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33900/" ]
I have implemented my own pingback client and sent out pingbacks to different hosts. Some wordpress instances responded to the XML-RPC pingback request with a `faultCode` of `0` and an empty `faultMessage`. What can be the cause for that?
``` add_action( 'edit_form_after_title', 'myprefix_edit_form_after_title' ); function myprefix_edit_form_after_title() { global $post; $author_id=$post->post_author; $authord = get_the_author_meta( 'user_email', $author_id); echo $authord; } ``` With this function I was able to display post author e-m...
119,930
<p>If a theme and a plugin uses the same action hook, for example <code>comment_form</code> is used by both theme and plugin. Then , which one will be called first? the function associated with the theme's hook or the function associated with the plugin's hook.</p>
[ { "answer_id": 119935, "author": "Maruti Mohanty", "author_id": 37890, "author_profile": "https://wordpress.stackexchange.com/users/37890", "pm_score": 1, "selected": false, "text": "<p>Every <code>action/filter</code> hooks have a priority parameter(<strong>the third parameter</strong>)...
2013/10/24
[ "https://wordpress.stackexchange.com/questions/119930", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40848/" ]
If a theme and a plugin uses the same action hook, for example `comment_form` is used by both theme and plugin. Then , which one will be called first? the function associated with the theme's hook or the function associated with the plugin's hook.
An action hook is simply a *queue point* that acts *at a specific point in the PHP execution process*: callbacks are queued via `add_action()` call, and everything in the queue gets processed in turn: ``` add_action( 'hook_name', 'callback_name', $priority, $number_of_args ); ``` A filter hook is a similar *queue po...
119,958
<p>I have a Custom Post Type that has several custom fields. One of the fields is multi-line and includes text with p tags.</p> <p>When I view this field in the visual editor the p tags are all there.</p> <p>I suspect the issue is how I am displaying the data in a custom template.</p> <p>This is the code that I am u...
[ { "answer_id": 119935, "author": "Maruti Mohanty", "author_id": 37890, "author_profile": "https://wordpress.stackexchange.com/users/37890", "pm_score": 1, "selected": false, "text": "<p>Every <code>action/filter</code> hooks have a priority parameter(<strong>the third parameter</strong>)...
2013/10/24
[ "https://wordpress.stackexchange.com/questions/119958", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36113/" ]
I have a Custom Post Type that has several custom fields. One of the fields is multi-line and includes text with p tags. When I view this field in the visual editor the p tags are all there. I suspect the issue is how I am displaying the data in a custom template. This is the code that I am using in the template to ...
An action hook is simply a *queue point* that acts *at a specific point in the PHP execution process*: callbacks are queued via `add_action()` call, and everything in the queue gets processed in turn: ``` add_action( 'hook_name', 'callback_name', $priority, $number_of_args ); ``` A filter hook is a similar *queue po...
119,964
<p>For users with the <code>Contributor</code> <a href="http://codex.wordpress.org/Roles_and_Capabilities" rel="nofollow noreferrer">user role</a>, I want to restrict the total amount of images that they are allowed to upload. I found this code posted on an <a href="https://wordpress.stackexchange.com/a/47605/24875">an...
[ { "answer_id": 119992, "author": "Maruti Mohanty", "author_id": 37890, "author_profile": "https://wordpress.stackexchange.com/users/37890", "pm_score": 0, "selected": false, "text": "<p>I have adjusted the later answer to check for the user role, I haven't tested it but this should work<...
2013/10/24
[ "https://wordpress.stackexchange.com/questions/119964", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24875/" ]
For users with the `Contributor` [user role](http://codex.wordpress.org/Roles_and_Capabilities), I want to restrict the total amount of images that they are allowed to upload. I found this code posted on an [answer here](https://wordpress.stackexchange.com/a/47605/24875): ``` add_filter( 'wp_handle_upload', 'wpse47580...
I'm not really sure which is the *real* problem with code you posted, however I cant understand why use 2 functions when one is enough... ``` add_filter( 'wp_handle_upload_prefilter', 'limit_uploads_for_user_roles' ); function limit_uploads_for_user_roles( $file ) { $user = wp_get_current_user(); // add the role ...
119,971
<p>I'm trying to load masonry but I'm having no luck, I've managed to load it manually but then I realised it was included in the wordpress core, so I thought oh that's handy.</p> <p>I have it enqueue' (I really hate that word) like this:</p> <pre><code>function lart_front_end_scripts() { if (is_admin()) ...
[ { "answer_id": 119972, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 0, "selected": false, "text": "<p>Masonry is bundled with and already registered by WordPress.</p>\n\n<p>All you have to do, is to enqueue it:...
2013/10/24
[ "https://wordpress.stackexchange.com/questions/119971", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35858/" ]
I'm trying to load masonry but I'm having no luck, I've managed to load it manually but then I realised it was included in the wordpress core, so I thought oh that's handy. I have it enqueue' (I really hate that word) like this: ``` function lart_front_end_scripts() { if (is_admin()) return; w...
Okay, so I made Underscore and Masonry a Dependency of another script and then it worked. I stopped trying to enqueue add action core scripts and just set it as a dependency for the script that needed it. Now, I'm not entirely sure if that is how it's supposed to work, I thought you still had to enqueue add action t...
119,986
<p>In a WP-based site I have a custom form which I need to hide from the general public and give access to only a select few who would then get a password from me, enter it and access the form and submit it. On form submission, I redirect them to another page. I have employed this bit of code below in my <code>function...
[ { "answer_id": 119994, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 0, "selected": false, "text": "<p>I did this small test and it works, but <em>I have <strong>no idea</strong> if it's technically correct</em...
2013/10/24
[ "https://wordpress.stackexchange.com/questions/119986", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25508/" ]
In a WP-based site I have a custom form which I need to hide from the general public and give access to only a select few who would then get a password from me, enter it and access the form and submit it. On form submission, I redirect them to another page. I have employed this bit of code below in my `functions.php`, ...
After submitting the form and before redirecting to new page, reset the current user's password. A simple `wp_update_user(array('ID' => $userid, 'user_pass' => 'YourNewPaSSword'));` will do everything for you.
120,000
<p>I have a WordPress theme that I am working with called "Forte". Yes, it is a premium theme. I have reached out to the developer but apparently he doesn't really want to help in this situation. Well I need to change the "portfolio" slug to something else. "Portfolio" doesn't really work at all with the website I am w...
[ { "answer_id": 120002, "author": "Lukas J.", "author_id": 40730, "author_profile": "https://wordpress.stackexchange.com/users/40730", "pm_score": 0, "selected": false, "text": "<p>The slug is stored in this line:</p>\n\n<pre><code>register_post_type( 'portfolio' , $args );\n</code></pre>...
2013/10/24
[ "https://wordpress.stackexchange.com/questions/120000", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40873/" ]
I have a WordPress theme that I am working with called "Forte". Yes, it is a premium theme. I have reached out to the developer but apparently he doesn't really want to help in this situation. Well I need to change the "portfolio" slug to something else. "Portfolio" doesn't really work at all with the website I am work...
Re-save your Permalinks after changing the name and slug from portfolio Looks like you need to add this line to your code ``` 'rewrite' => array( 'slug' => 'portfolio', 'with_front' => false ), ``` And change this to true ``` 'public' => true, ```
120,004
<p>I'm wondering how can I find plugins' slug (slug = internal name used by WordPress to do plugin updates and to determine which plugins are currently active)? It is usually plugin's folder name but if a plugin doesn't have a folder, it is its file name (like hello.php). Are there any other exceptions?</p> <ol> <li>D...
[ { "answer_id": 120015, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>The string used in WordPress to identify the plugin is:</p>\n\n<pre><code>plugin_basename($file);\n</code></pre>\n\n<p...
2013/10/24
[ "https://wordpress.stackexchange.com/questions/120004", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17167/" ]
I'm wondering how can I find plugins' slug (slug = internal name used by WordPress to do plugin updates and to determine which plugins are currently active)? It is usually plugin's folder name but if a plugin doesn't have a folder, it is its file name (like hello.php). Are there any other exceptions? 1. Do lowercase a...
The string used in WordPress to identify the plugin is: ``` plugin_basename($file); ``` … where `$file` is a [file with the plugin headers](https://wordpress.stackexchange.com/a/102097/73). So if you are in your plugin, get the slug with: ``` $slug = plugin_basename( __FILE__ ); ```
120,037
<p>This is kind of a unique situation. I have an invoicing custom post type that when it is marked as "paid" I want to then generate another custom post type. I have a custom meta file that handles the invoice meta and am trying to get this function to work. Currently, it does work, but it creates an infinite number...
[ { "answer_id": 120050, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 1, "selected": true, "text": "<p>Yep, <code>wp_insert_post</code> will call <code>save_post</code>, hence the closed-loop.</p>\n\n<p>Use</p>\...
2013/10/25
[ "https://wordpress.stackexchange.com/questions/120037", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40891/" ]
This is kind of a unique situation. I have an invoicing custom post type that when it is marked as "paid" I want to then generate another custom post type. I have a custom meta file that handles the invoice meta and am trying to get this function to work. Currently, it does work, but it creates an infinite number of ne...
Yep, `wp_insert_post` will call `save_post`, hence the closed-loop. Use ``` remove_action( 'save_post', 'generate_ceu'); $pid = wp_insert_post($new_post); add_action( 'save_post', 'generate_ceu'); ```
120,038
<p>I have created Custom Post Type called - listing</p> <p>Also created custom taxonomy - listingcategories</p> <p>In listing categories, i have created two categories </p> <ol> <li>music 2. features</li> </ol> <p>Now i want to create a conditional statement for music category</p> <p>I am trying this, but its not ...
[ { "answer_id": 120098, "author": "luckyrajiv", "author_id": 37664, "author_profile": "https://wordpress.stackexchange.com/users/37664", "pm_score": 1, "selected": true, "text": "<pre><code> &lt;?php if( has_term( 'music', 'listingcategory' ) ) {\n //content...
2013/10/25
[ "https://wordpress.stackexchange.com/questions/120038", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37664/" ]
I have created Custom Post Type called - listing Also created custom taxonomy - listingcategories In listing categories, i have created two categories 1. music 2. features Now i want to create a conditional statement for music category I am trying this, but its not working ``` <?php global $post; if (($post->pos...
``` <?php if( has_term( 'music', 'listingcategory' ) ) { //content1 } else { //content2 } ?> ``` Got working using this <http://codex.wordpress.org/Function...
120,055
<p>I am customizing woo-commerce plugin to add product from the front end into the cart. I have written the function in functions.php, but i am getting a Fatal error. </p> <p>Getting this error--></p> <blockquote> <p>Fatal error: Call to a member function add_to_cart() on a non-object in<br> C:\wamp\www\cutting...
[ { "answer_id": 120068, "author": "Svetlana Silina", "author_id": 33680, "author_profile": "https://wordpress.stackexchange.com/users/33680", "pm_score": 0, "selected": false, "text": "<p>The $woocommerce->cart apparently is not an object during the call. Set it to get checked before the ...
2013/10/25
[ "https://wordpress.stackexchange.com/questions/120055", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39122/" ]
I am customizing woo-commerce plugin to add product from the front end into the cart. I have written the function in functions.php, but i am getting a Fatal error. Getting this error--> > > Fatal error: Call to a member function add\_to\_cart() on a non-object > in > > C:\wamp\www\cutting-edge\_server\wordpres...
I'm not sure exactly what you are doing, but the following code did work for me in that it created a new product and added it to the cart. Note, I had to use `$_GET` to test on my setup since I don't have the rest of your code and didn't feel like creating a form. **EDIT**: I've added a simple `<form>` element and sw...
120,062
<p>Is there a way when adding a new product that all available Attributes would automatically be added to this product and oppened/expanded so that when I'm adding new product I don't have to first add them and then click on the headers to expand them?</p> <p>Hope this image clears what I want to achieve: <img src="h...
[ { "answer_id": 120095, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 4, "selected": true, "text": "<p>This was not as easy as I initially thought.</p>\n\n<p>This will show show every attribute.... apparently...
2013/10/25
[ "https://wordpress.stackexchange.com/questions/120062", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7238/" ]
Is there a way when adding a new product that all available Attributes would automatically be added to this product and oppened/expanded so that when I'm adding new product I don't have to first add them and then click on the headers to expand them? Hope this image clears what I want to achieve: ![enter image descript...
This was not as easy as I initially thought. This will show show every attribute.... apparently by default WC hides any attribute that doesn't have any terms. They're already in the code, just with a `display:none;`. ``` function wpa_120062_scripts(){ ?> <script type="text/javascript"> jQuery(document).re...
120,065
<p>I have the following custom query and im attempting to paginate the links of previous archive posts using the example from the wordpress codex</p> <p><a href="http://codex.wordpress.org/Function_Reference/paginate_links#Basic_Example" rel="nofollow">http://codex.wordpress.org/Function_Reference/paginate_links#Basic...
[ { "answer_id": 120095, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 4, "selected": true, "text": "<p>This was not as easy as I initially thought.</p>\n\n<p>This will show show every attribute.... apparently...
2013/10/25
[ "https://wordpress.stackexchange.com/questions/120065", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23874/" ]
I have the following custom query and im attempting to paginate the links of previous archive posts using the example from the wordpress codex <http://codex.wordpress.org/Function_Reference/paginate_links#Basic_Example> Am i inserting this in the wrong place? I inserted before the end of the query with the basic argu...
This was not as easy as I initially thought. This will show show every attribute.... apparently by default WC hides any attribute that doesn't have any terms. They're already in the code, just with a `display:none;`. ``` function wpa_120062_scripts(){ ?> <script type="text/javascript"> jQuery(document).re...
120,080
<p>I have a custom post type with its own taxonomy, basically 'show venues' is the post type and venue-regions is the taxonomy. </p> <p>Seeing how a venue cant exsist in mutiple regions, I've removed the default metta box and added my own as a dropdown using <code>wp_dropdown_categories()</code>. The taxonomy items ar...
[ { "answer_id": 216584, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 0, "selected": false, "text": "<p>Using the <a href=\"https://codex.wordpress.org/Function_Reference/wp_dropdown_categories\" rel=\"nofollow\...
2013/10/25
[ "https://wordpress.stackexchange.com/questions/120080", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13551/" ]
I have a custom post type with its own taxonomy, basically 'show venues' is the post type and venue-regions is the taxonomy. Seeing how a venue cant exsist in mutiple regions, I've removed the default metta box and added my own as a dropdown using `wp_dropdown_categories()`. The taxonomy items are being output and ap...
**get post id** ``` $post_id=get_the_ID(); ``` **get selected region** ``` $terms = wp_get_post_terms( $post_id, $taxonomy ); $selected_id=''; if(isset($terms[0]->term_id)){ $selected_id=$terms[0]->term_id; } ``` **build hierarchical dropdown** ``` wp_dropdown_categories( array( ...
120,081
<p>WordPress 3.7 added automatic updates. How does this work, and how can I configure this feature?</p>
[ { "answer_id": 120082, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 6, "selected": true, "text": "<p>Automatic updates are automatic.</p>\n\n<p>The basic, default behavior in WordPress 3.7 is automatic update...
2013/10/25
[ "https://wordpress.stackexchange.com/questions/120081", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3966/" ]
WordPress 3.7 added automatic updates. How does this work, and how can I configure this feature?
Automatic updates are automatic. The basic, default behavior in WordPress 3.7 is automatic update of core for minor versions (i.e. `X.Y.Z` to `X.Y.Z+1`.) No configuration options are exposed in the UI. To change the behavior, you'll need to modify your `wp-config.php` file, or add some filters: Easy Disabling ------...
120,105
<p>I'm building a website with wordpress and the Canvas Theme (from WooThemes).</p> <p>I'm using the Top navigation for displaying items when a user is logged in. When the user is not logged in, you can see only 'become a member' and 'login'. When the user logins, he/she sees another navigation with other menu items.<...
[ { "answer_id": 120082, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 6, "selected": true, "text": "<p>Automatic updates are automatic.</p>\n\n<p>The basic, default behavior in WordPress 3.7 is automatic update...
2013/10/25
[ "https://wordpress.stackexchange.com/questions/120105", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40920/" ]
I'm building a website with wordpress and the Canvas Theme (from WooThemes). I'm using the Top navigation for displaying items when a user is logged in. When the user is not logged in, you can see only 'become a member' and 'login'. When the user logins, he/she sees another navigation with other menu items. I thought...
Automatic updates are automatic. The basic, default behavior in WordPress 3.7 is automatic update of core for minor versions (i.e. `X.Y.Z` to `X.Y.Z+1`.) No configuration options are exposed in the UI. To change the behavior, you'll need to modify your `wp-config.php` file, or add some filters: Easy Disabling ------...
120,112
<p>I'm trying to create certain modulair blocks which I can add to multiple pages in Wordpress. But I use sidebar-[name].php files for this, what is the best practice for this? Should you add them to a function or add them in a sidebar...</p> <p>It feels Kinda off using many sidebar's. It would be nice if I could add ...
[ { "answer_id": 120119, "author": "mantis", "author_id": 34045, "author_profile": "https://wordpress.stackexchange.com/users/34045", "pm_score": 3, "selected": true, "text": "<p>I would say to add them as template parts as in content-[name].php. For instance in <code>page.php</code> you c...
2013/10/25
[ "https://wordpress.stackexchange.com/questions/120112", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34570/" ]
I'm trying to create certain modulair blocks which I can add to multiple pages in Wordpress. But I use sidebar-[name].php files for this, what is the best practice for this? Should you add them to a function or add them in a sidebar... It feels Kinda off using many sidebar's. It would be nice if I could add them to a ...
I would say to add them as template parts as in content-[name].php. For instance in `page.php` you could have something like: ``` <?php while ( have_posts() ) : the_post(); ?> <?php if (is_page( 'home' ) ){ get_template_part( 'content', 'benefits' ); } elseif (is_page( 'Con...
120,124
<p>this is the issue:</p> <pre><code>add_action('admin_menu', 'bittech_login_settings'); function bittech_login_settings() { add_menu_page('BitTech Login Settings', 'BitTech Login Settings', 'administrator', 'bittech_settings', 'bittech_login_settings')...
[ { "answer_id": 120125, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"http://codex.wordpress.org/Administration_Menus#Determining_Location_for_New_Menus\" rel=\"n...
2013/10/25
[ "https://wordpress.stackexchange.com/questions/120124", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40592/" ]
this is the issue: ``` add_action('admin_menu', 'bittech_login_settings'); function bittech_login_settings() { add_menu_page('BitTech Login Settings', 'BitTech Login Settings', 'administrator', 'bittech_settings', 'bittech_login_settings'); $filename = ".....
You're using `add_menu_page` wrong. The function `bittech_login_settings` should be only: ``` function bittech_login_settings() { add_menu_page( 'BitTech Login Settings', 'BitTech Login Settings', 'add_users', 'bittech_settings', 'bittech_login_settings_callback' ); ...
120,136
<p>I'm trying to get a list of wpsc_product_category terms, for a given category, and have them display in alphabetical order (by name) with links to their pages. </p> <p>This gives me the right list, but the sort() doesn't work. The terms aren't in alphabetical order. Any help would be greatly appreciated!</p> <pre>...
[ { "answer_id": 120138, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/get_terms#Parameters\" rel=\"nofollow\">default ...
2013/10/26
[ "https://wordpress.stackexchange.com/questions/120136", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40929/" ]
I'm trying to get a list of wpsc\_product\_category terms, for a given category, and have them display in alphabetical order (by name) with links to their pages. This gives me the right list, but the sort() doesn't work. The terms aren't in alphabetical order. Any help would be greatly appreciated! ``` <?php //disp...
This code works! Sorts by category name (visible name), produces a list of links of categories (that aren't empty) that are children of category\_id. ``` <?php //display sorted list of wpsc product categories $category_id = 10; $terms = get_terms('wpsc_product_category','hide_empty=1&parent='.$category_id); usort($te...
120,143
<p>What would be the reason for <code>&lt;?php echo esc_url( home_url( '/' ) ); ?&gt;</code> to be sending me to an incorrect website?</p> <p>I use it in my search bar and when I search a value it sends me to one of my other websites, but I am not sure what I did to make this happen.</p>
[ { "answer_id": 120138, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/get_terms#Parameters\" rel=\"nofollow\">default ...
2013/10/26
[ "https://wordpress.stackexchange.com/questions/120143", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32290/" ]
What would be the reason for `<?php echo esc_url( home_url( '/' ) ); ?>` to be sending me to an incorrect website? I use it in my search bar and when I search a value it sends me to one of my other websites, but I am not sure what I did to make this happen.
This code works! Sorts by category name (visible name), produces a list of links of categories (that aren't empty) that are children of category\_id. ``` <?php //display sorted list of wpsc product categories $category_id = 10; $terms = get_terms('wpsc_product_category','hide_empty=1&parent='.$category_id); usort($te...
120,155
<p>I am modifying a job theme and having a problem with woo commerce plugin</p> <p>There are 3 products to purchase.<br/> 1. posting a job (options: 1job, 2 jobs, 5 jobs)<br/> 2. Able to read full resumes for 1 day (option: for 1 day, 7 days, 15 days)<br/> 3. Both of them (posting jobs and read resumes)<br/><br/></p> ...
[ { "answer_id": 120138, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/get_terms#Parameters\" rel=\"nofollow\">default ...
2013/10/26
[ "https://wordpress.stackexchange.com/questions/120155", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34463/" ]
I am modifying a job theme and having a problem with woo commerce plugin There are 3 products to purchase. 1. posting a job (options: 1job, 2 jobs, 5 jobs) 2. Able to read full resumes for 1 day (option: for 1 day, 7 days, 15 days) 3. Both of them (posting jobs and read resumes) I have successfully done wi...
This code works! Sorts by category name (visible name), produces a list of links of categories (that aren't empty) that are children of category\_id. ``` <?php //display sorted list of wpsc product categories $category_id = 10; $terms = get_terms('wpsc_product_category','hide_empty=1&parent='.$category_id); usort($te...
120,161
<p>Apologies for the general question, but I spent some time looking for an answer and couldn't find anything.</p> <p>I often find myself in a situation where I need to make tweaks to a live site based on a client's feedback after going live, so I'm wondering the best way to quickly make changes on the live site witho...
[ { "answer_id": 120138, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/get_terms#Parameters\" rel=\"nofollow\">default ...
2013/10/26
[ "https://wordpress.stackexchange.com/questions/120161", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2685/" ]
Apologies for the general question, but I spent some time looking for an answer and couldn't find anything. I often find myself in a situation where I need to make tweaks to a live site based on a client's feedback after going live, so I'm wondering the best way to quickly make changes on the live site without disrupt...
This code works! Sorts by category name (visible name), produces a list of links of categories (that aren't empty) that are children of category\_id. ``` <?php //display sorted list of wpsc product categories $category_id = 10; $terms = get_terms('wpsc_product_category','hide_empty=1&parent='.$category_id); usort($te...
120,179
<p>I want to disable this just for one Post Type, as it doesn't really matters if there's another user editing it (the main content editing area is Ajaxified and non-admins can only see that).</p> <p><img src="https://i.stack.imgur.com/JIKlb.png" alt="enter image description here"></p> <p>I looked at the core functio...
[ { "answer_id": 120187, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": false, "text": "<p>To remove the <em>edit-lock</em> popup window, you could try:</p>\n\n<pre><code>add_filter( 'wp_check_post_lo...
2013/10/26
[ "https://wordpress.stackexchange.com/questions/120179", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12615/" ]
I want to disable this just for one Post Type, as it doesn't really matters if there's another user editing it (the main content editing area is Ajaxified and non-admins can only see that). ![enter image description here](https://i.stack.imgur.com/JIKlb.png) I looked at the core functions but couldn't find an entry p...
As an addition to ***@birgire*** answer… Findings -------- [`register_post_type()`](http://queryposts.com/function/add_post_type_support/) allows to register a post type support, which can as well be [done later on using `add_post_type_support()`](http://queryposts.com/function/add_post_type_support/). And that can g...
120,206
<p>I have a review based wordpress site where I have a page for each different company where there users can review them. The theme I use adds a custom post type called "review" and I have used Press Permit to create limited user accounts that can modifying some parts of these review pages.</p> <p>I wanted to hide som...
[ { "answer_id": 120417, "author": "George G.", "author_id": 33604, "author_profile": "https://wordpress.stackexchange.com/users/33604", "pm_score": 1, "selected": false, "text": "<p>Does lowering the priority of your <code>add_action()</code> call here help? This was mentioned by <a href=...
2013/10/26
[ "https://wordpress.stackexchange.com/questions/120206", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40950/" ]
I have a review based wordpress site where I have a page for each different company where there users can review them. The theme I use adds a custom post type called "review" and I have used Press Permit to create limited user accounts that can modifying some parts of these review pages. I wanted to hide some of the M...
Does lowering the priority of your `add_action()` call here help? This was mentioned by [Kid Slimmer](https://wordpress.stackexchange.com/users/29054/kid-slimmer) and [Piet](https://wordpress.stackexchange.com/users/2015/piet) in the very post you linked to you, in this comment → <https://wordpress.stackexchange.com/a/...
120,240
<p>Let assume I have the following page structure</p> <pre><code>/about-us (used as a parent holder only) /about-us/history (real page) /about-us/team (real page) /about-us/industry (real page) </code></pre> <p>There is no content in the page "<strong>about-us</strong> ", but it is needed for two purpose</p> <ol> <l...
[ { "answer_id": 120242, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 3, "selected": false, "text": "<p>I am using two strategies here...</p>\n\n<p>1) is simple redirection to first child (using menu order)\n...
2013/10/27
[ "https://wordpress.stackexchange.com/questions/120240", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16037/" ]
Let assume I have the following page structure ``` /about-us (used as a parent holder only) /about-us/history (real page) /about-us/team (real page) /about-us/industry (real page) ``` There is no content in the page "**about-us** ", but it is needed for two purpose 1. Allow hierarchical structure in url 2. Allow hi...
I am using two strategies here... 1) is simple redirection to first child (using menu order) `page-redirect.php` ``` <?php /* * Template Name: Redirector * Description: Empty Holder (redirect page) */ $rp = new WP_Query(array( 'post_parent' => get_the_id(), 'post_type' => 'page', ...
120,252
<p>I'm developing a website for a product (audio speaker) I'm launching and I'm experiencing an issue I can't resolve (on my own ;) ).</p> <p>I've added this code to <code>functions.php</code> to disable dashboard access for subscribers.</p> <pre><code>add_action('admin_init', 'no_mo_dashboard'); function no_mo_dashb...
[ { "answer_id": 120256, "author": "TomC", "author_id": 36980, "author_profile": "https://wordpress.stackexchange.com/users/36980", "pm_score": 0, "selected": false, "text": "<p>You could use the $path parameter with home_url as follows:</p>\n\n<pre><code>$url = home_url('/en');\nwp_redire...
2013/10/27
[ "https://wordpress.stackexchange.com/questions/120252", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40963/" ]
I'm developing a website for a product (audio speaker) I'm launching and I'm experiencing an issue I can't resolve (on my own ;) ). I've added this code to `functions.php` to disable dashboard access for subscribers. ``` add_action('admin_init', 'no_mo_dashboard'); function no_mo_dashboard() { if (!current_user_c...
You need to use the same method qtranslate uses to get the language parameter in the url. Quickly glancing through the source it seems to be [`qtrans_getLanguage()`](http://plugins.trac.wordpress.org/browser/qtranslate/trunk/qtranslate_utils.php?rev=776757#L63) ``` $url = home_url( qtrans_get_language() ); wp_redirect...
120,259
<p>I have a WordPress install for a personal blog and I'm gradually porting all of the little web bits I have written over the years to pages on the blog. </p> <p>One such page is <a href="http://www.projecttoomanycooks.co.uk/cgi-bin/memory/majorAnalysis.py" rel="noreferrer">http://www.projecttoomanycooks.co.uk/cgi-bi...
[ { "answer_id": 120261, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 6, "selected": true, "text": "<p>You can use <a href=\"http://php.net/manual/en/function.popen.php\" rel=\"noreferrer\"><code>popen()</code></a> to rea...
2013/10/27
[ "https://wordpress.stackexchange.com/questions/120259", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11774/" ]
I have a WordPress install for a personal blog and I'm gradually porting all of the little web bits I have written over the years to pages on the blog. One such page is <http://www.projecttoomanycooks.co.uk/cgi-bin/memory/majorAnalysis.py> which is a simple python script that returns a list of words - I'd like to emb...
You can use [`popen()`](http://php.net/manual/en/function.popen.php) to read **or** write to a Python script (this works with any other language too). If you need interaction (passing variables) use [`proc_open()`](http://www.php.net/manual/en/function.proc-open.php). ### A simple example to print *Hello World!* in a ...
120,272
<p>I'm trying to create a plugin that is basically just a WordPress widget. I'm having great difficulty getting the WordPress color picker to function correctly when my widget is first added to the sidebar. I've followed these <a href="http://zourbuth.com/archives/877/how-to-use-wp-color-picker-in-widgets" rel="nofollo...
[ { "answer_id": 124838, "author": "skywalker14", "author_id": 43282, "author_profile": "https://wordpress.stackexchange.com/users/43282", "pm_score": 1, "selected": false, "text": "<p>I struggled with this same issue, and found a solution.</p>\n\n<p>The first issue, is that you need to ta...
2013/10/27
[ "https://wordpress.stackexchange.com/questions/120272", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40949/" ]
I'm trying to create a plugin that is basically just a WordPress widget. I'm having great difficulty getting the WordPress color picker to function correctly when my widget is first added to the sidebar. I've followed these [instructions for integrating the picker](http://zourbuth.com/archives/877/how-to-use-wp-color-p...
I added code from [this](https://core.trac.wordpress.org/attachment/ticket/25809/color-picker-widget.php) example and it works! (wp 9 still has same issue with color picker) ``` <script> ( function( $ ){ function initColorPicker( widget ) { widget.find( '.color-picker' ).wpColorPicker( { ...
120,273
<p>In the function below, I'm trying to convert the fopen/fwrite/fclose methods to the preferred WP_filesystem methods. Everything works as expected using the commented out script block, however, the WP_filesystem methods always return the error block.</p> <p>Any ideas what I'm doing wrong?</p> <pre><code>function so...
[ { "answer_id": 120278, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>I expect that the problem is with the login credentials. Your code assumes that the credentials are set but ...
2013/10/27
[ "https://wordpress.stackexchange.com/questions/120273", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
In the function below, I'm trying to convert the fopen/fwrite/fclose methods to the preferred WP\_filesystem methods. Everything works as expected using the commented out script block, however, the WP\_filesystem methods always return the error block. Any ideas what I'm doing wrong? ``` function so_doHtaccess(){ if (...
The get\_contents function returns the contents of the file, not a file handle. Using put\_contents with $f after that is incorrect. Try `$wp_filesystem->put_contents( $htaccess_file, $htaccessnew, FS_CHMOD_FILE )` instead. Also, it's not necessarily safe to use things like "get\_home\_path" and such with the WP\_Fi...
120,294
<p>I've written a custom front-end change password page. At the top of the page I have this snippet of code:</p> <pre><code>&lt;?php if ( !is_user_logged_in() ) { auth_redirect(); } ?&gt; </code></pre> <p>After the request is processed and the user's password is changed the page draws, but the next page view trigg...
[ { "answer_id": 120295, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>The login cookie is named <code>'wp-postpass_' . COOKIEHASH</code> where <code>COOKIEHASH</code> is either defined in...
2013/10/27
[ "https://wordpress.stackexchange.com/questions/120294", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40469/" ]
I've written a custom front-end change password page. At the top of the page I have this snippet of code: ``` <?php if ( !is_user_logged_in() ) { auth_redirect(); } ?> ``` After the request is processed and the user's password is changed the page draws, but the next page view triggers `is_user_logged_in()` to ret...
The login cookie is named `'wp-postpass_' . COOKIEHASH` where `COOKIEHASH` is either defined in your `wp-config.php` or in `wp-includes/default-constants.php function wp_cookie_constants()`. The value is: ``` $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ) ``` Whenever the password is changed, the co...
120,304
<p>I am working on a site and sometimes I run into an error when logging out and on the site tab it says 'Wordpress Failure Notice'. I am trying to remove all instances of wordpress so users dont know Im using it, but I can not figure out how to remove the text from the tab. I dont have no code to try and show because ...
[ { "answer_id": 120324, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>this string is displayed when you get a nonce mismatch, something that should not happen much under norma...
2013/10/28
[ "https://wordpress.stackexchange.com/questions/120304", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24067/" ]
I am working on a site and sometimes I run into an error when logging out and on the site tab it says 'Wordpress Failure Notice'. I am trying to remove all instances of wordpress so users dont know Im using it, but I can not figure out how to remove the text from the tab. I dont have no code to try and show because Im ...
this string is displayed when you get a nonce mismatch, something that should not happen much under normal usage. If it does haen enough to make you aware to it then you should investigate the cause. Anyway, no easy filter for that string so you will have to use the translation api to replace it. ``` add_filter ( 'ge...
120,317
<p>I have registered a custom post type in my functions.php file for "Wines", with this code:</p> <pre><code>function customposttype_wines() { $labels = array( 'name' =&gt; 'Wines', 'singular_name' =&gt; 'Wine', 'menu_name' =&gt; 'Wines', 'parent_item_colon' =&gt; 'Par...
[ { "answer_id": 120323, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 0, "selected": false, "text": "<p>Read more carefully about <a href=\"http://codex.wordpress.org/Function_Reference/register_taxonomy\" re...
2013/10/28
[ "https://wordpress.stackexchange.com/questions/120317", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40679/" ]
I have registered a custom post type in my functions.php file for "Wines", with this code: ``` function customposttype_wines() { $labels = array( 'name' => 'Wines', 'singular_name' => 'Wine', 'menu_name' => 'Wines', 'parent_item_colon' => 'Parent Wine', 'all_items'...
I was not able to find a solution for doing it the way I was wanting/thinking I could. So...decided to name the **taxonomies** the singular name (ie: brand, grape, region) and then create **pages** with the plural of the same name (ie: brands, grapes, regions) and on each **page** I will have to use the `get_terms` fun...
120,326
<p>I have uploaded my images to Amazon S3. There are some featured images. In order to modify their path, I run the update scripts to change the path of <code>wp_posts.guid</code>. But the image still points to the old path. </p> <p>How can I change the featured image url so as to point to the Amazon S3 path?</p> <p>...
[ { "answer_id": 120342, "author": "Maruti Mohanty", "author_id": 37890, "author_profile": "https://wordpress.stackexchange.com/users/37890", "pm_score": 0, "selected": false, "text": "<p>Then you have to point the uploads folder to the same location. You can do it by making the below chan...
2013/10/28
[ "https://wordpress.stackexchange.com/questions/120326", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40991/" ]
I have uploaded my images to Amazon S3. There are some featured images. In order to modify their path, I run the update scripts to change the path of `wp_posts.guid`. But the image still points to the old path. How can I change the featured image url so as to point to the Amazon S3 path? Thanks
You can hook into the output and modify the URL there. ``` add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 5 ); function my_post_image_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) { $upload_dir = wp_upload_dir(); $base_url = $upload_dir['baseurl']; // Change the default upload direct...
120,339
<p>This question might be wrong, I am not sure about it. Because I am not clear on this.</p> <p>I know <code>add_action</code> it is used to to hook our function to the specified function. For example <code>add_action('wp_head'.'myfunc');</code> now what ever code in <code>myfunc</code> will be executed in the <code>w...
[ { "answer_id": 120344, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 5, "selected": true, "text": "<p>Use <code>do_action( 'unique_name' )</code> to create your own actions.</p>\n\n<p>You can use that to offer an <a href...
2013/10/28
[ "https://wordpress.stackexchange.com/questions/120339", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35819/" ]
This question might be wrong, I am not sure about it. Because I am not clear on this. I know `add_action` it is used to to hook our function to the specified function. For example `add_action('wp_head'.'myfunc');` now what ever code in `myfunc` will be executed in the `wp_head()`. This is clear but i am having doubt i...
Use `do_action( 'unique_name' )` to create your own actions. You can use that to offer an [API for your plugin](https://wordpress.stackexchange.com/a/98783/73), so other plugins can register callbacks for your custom action. Example: [Do I need to call do\_action in my plugin?](https://wordpress.stackexchange.com/a/64...
120,347
<p>I am working on E-commerce functions where i require to Add custom fieldset as Profile Fields the fields in it are as billing</p> <p>Below are the Fields that is needed in My Check out and signup form</p> <pre><code>profile_first_name profile_last_name profile_company profile_address_1 profile_address_2 profile_ci...
[ { "answer_id": 120516, "author": "J G", "author_id": 34302, "author_profile": "https://wordpress.stackexchange.com/users/34302", "pm_score": 1, "selected": true, "text": "<p>The \"Customizing checkout fields using actions and filters\" page <a href=\"http://docs.woothemes.com/document/tu...
2013/10/28
[ "https://wordpress.stackexchange.com/questions/120347", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14872/" ]
I am working on E-commerce functions where i require to Add custom fieldset as Profile Fields the fields in it are as billing Below are the Fields that is needed in My Check out and signup form ``` profile_first_name profile_last_name profile_company profile_address_1 profile_address_2 profile_city profile_postcode p...
The "Customizing checkout fields using actions and filters" page [in the WooCommerce Codex might help you](http://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/).
120,352
<p>I have a multisite network of sites which should display blog content from each other if the blog post has a tag with the site name.</p> <p>To gather all posts within the network I use the SWT (Sitewide Tags) plugin as it seems most efficient. I store all posts in the main site (blog id 1) and from my other sites I...
[ { "answer_id": 137213, "author": "Johan Nordström", "author_id": 14820, "author_profile": "https://wordpress.stackexchange.com/users/14820", "pm_score": 3, "selected": true, "text": "<p>OK so for reference I ended up actually using <code>switch_to_blog()</code> and <code>restore_current_...
2013/10/28
[ "https://wordpress.stackexchange.com/questions/120352", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14820/" ]
I have a multisite network of sites which should display blog content from each other if the blog post has a tag with the site name. To gather all posts within the network I use the SWT (Sitewide Tags) plugin as it seems most efficient. I store all posts in the main site (blog id 1) and from my other sites I want to q...
OK so for reference I ended up actually using `switch_to_blog()` and `restore_current_blog()`. I found no references whatever for querying multiple tables (except writing my own `JOIN`-statements) when followed the source code for the action `pre_get_posts`. A lot of advice was given to skip `restore_current_blog()` t...
120,402
<p>I need to execute posts from 2 separated keywords using <code>s=keyword</code> with <code>get_posts</code>, but only searching in titles. I found <a href="https://wordpress.stackexchange.com/questions/11822/how-to-limit-search-to-post-titles/11826#11826">this answer</a>.</p> <p>I created a custom template to use it ...
[ { "answer_id": 120510, "author": "Charles Clarkson", "author_id": 31788, "author_profile": "https://wordpress.stackexchange.com/users/31788", "pm_score": 1, "selected": false, "text": "<p>I didn't load the plugin to check and I never use <code>query_posts()</code>, but perhaps <code>tie_...
2013/10/28
[ "https://wordpress.stackexchange.com/questions/120402", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38852/" ]
I need to execute posts from 2 separated keywords using `s=keyword` with `get_posts`, but only searching in titles. I found [this answer](https://wordpress.stackexchange.com/questions/11822/how-to-limit-search-to-post-titles/11826#11826). I created a custom template to use it in single page. Then I used a merged `get_...
after more than 15 hours testing & working **The Solution is** replace this line `query_posts('paged='.$paged.'&posts_per_page='. $cat_query);` with `query_posts(array('post__in' => $uniqueposts, 'posts_per_page' => 12,'paged' => $paged,));` **The Problem is** this line only responsible for run the paginatio...
120,404
<p>I need to take the post meta from a post, and create a custom post type post. I'm using the code below but think it's creating an infinite loop.</p> <p>When wp_insert_post fires I have create_cptpost function execute which gets the PID of the post created <code>$post_id</code> gets a custom field <code>ac_1</code> ...
[ { "answer_id": 120405, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": false, "text": "<p>Yeah, that would be an infinite loop.</p>\n\n<p>Why not have your function check to make sure that the post is som...
2013/10/28
[ "https://wordpress.stackexchange.com/questions/120404", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10413/" ]
I need to take the post meta from a post, and create a custom post type post. I'm using the code below but think it's creating an infinite loop. When wp\_insert\_post fires I have create\_cptpost function execute which gets the PID of the post created `$post_id` gets a custom field `ac_1` then I need to create a new p...
Yeah, that would be an infinite loop. Why not have your function check to make sure that the post is something you'd actually want to insert a new cpt post for, and return if not. You're already checking for revisions. You could easily check for your own type too.
120,407
<p>I have added a custom/secondary query to a template file/custom page template; how can I make WordPress use my custom query for pagination, instead of using the main query loop's pagination?</p> <h3>Addendum</h3> <p>I have modified the main loop query via <a href="http://codex.wordpress.org/Function_Reference/quer...
[ { "answer_id": 120408, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 9, "selected": true, "text": "<h1>The Problem</h1>\n\n<p>By default, in any given context, WordPress uses the main query to determine pagina...
2013/10/28
[ "https://wordpress.stackexchange.com/questions/120407", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3966/" ]
I have added a custom/secondary query to a template file/custom page template; how can I make WordPress use my custom query for pagination, instead of using the main query loop's pagination? ### Addendum I have modified the main loop query via [`query_posts()`](http://codex.wordpress.org/Function_Reference/query_post...
The Problem =========== By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the `$wp_query` global, which is also used to output the main query loop: ``` if ( have_posts() ) : while ( have_posts() ) : the_post(); ``` When you [use a custom quer...
120,438
<p>I have a standalone PHP script in my WordPress theme's directory that I run once every hour through a cron job (or manually if needed). All other WordPress functions are working except the <code>update_option()</code> function.</p> <p>A simplified version of my script looks like this:</p> <pre><code>require_once('...
[ { "answer_id": 120451, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 2, "selected": false, "text": "<p>I'm not sure why it does't work for you, but the following works in the file <code>wp-content/test.php</cod...
2013/10/29
[ "https://wordpress.stackexchange.com/questions/120438", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9788/" ]
I have a standalone PHP script in my WordPress theme's directory that I run once every hour through a cron job (or manually if needed). All other WordPress functions are working except the `update_option()` function. A simplified version of my script looks like this: ``` require_once('/path/to/site/wp-load.php'); $v...
I'm not sure why it does't work for you, but the following works in the file `wp-content/test.php`: ``` <?php // doesn't make difference to have this or not, for the rest to work define( 'WP_USE_THEMES', false ); require( $_SERVER['DOCUMENT_ROOT'] .'/wp-load.php' ); function my_function() { return 'hello world'...
120,440
<p>I want to contribute to a guys plugin (TimberWp). I'd like to do it with tests. his plugin has a test dir that looks just like the wp-cli scaffolded dir. all v standard. </p> <p>Iv'e managed to get as far as installing wp-cli, phpunit (already had that) and I got past the couldn't connect to mysql issue (make i...
[ { "answer_id": 120451, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 2, "selected": false, "text": "<p>I'm not sure why it does't work for you, but the following works in the file <code>wp-content/test.php</cod...
2013/10/29
[ "https://wordpress.stackexchange.com/questions/120440", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19935/" ]
I want to contribute to a guys plugin (TimberWp). I'd like to do it with tests. his plugin has a test dir that looks just like the wp-cli scaffolded dir. all v standard. Iv'e managed to get as far as installing wp-cli, phpunit (already had that) and I got past the couldn't connect to mysql issue (make it use the mamp...
I'm not sure why it does't work for you, but the following works in the file `wp-content/test.php`: ``` <?php // doesn't make difference to have this or not, for the rest to work define( 'WP_USE_THEMES', false ); require( $_SERVER['DOCUMENT_ROOT'] .'/wp-load.php' ); function my_function() { return 'hello world'...
120,460
<p>I trying to create a child theme from theme twenty thirteen. One feature I want to add in my child theme is that I can specify (via Coding) a different header image on each page. I've <a href="https://wordpress.stackexchange.com/questions/89451/display-different-header-images-based-on-current-page">asked the same fo...
[ { "answer_id": 120463, "author": "7usien", "author_id": 13806, "author_profile": "https://wordpress.stackexchange.com/users/13806", "pm_score": 0, "selected": false, "text": "<p>hmm i think you can do it only via css with the body class, you get body class that generate automatic from wp...
2013/10/29
[ "https://wordpress.stackexchange.com/questions/120460", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12614/" ]
I trying to create a child theme from theme twenty thirteen. One feature I want to add in my child theme is that I can specify (via Coding) a different header image on each page. I've [asked the same for twenty eleven theme](https://wordpress.stackexchange.com/questions/89451/display-different-header-images-based-on-cu...
I don't see any hooks available to help you hook your function. As you are using **child theming**, so take the copy of the `header.php` file from the parent twenty thirteen theme and paste it in the `child theme folder` and make the changes. This will work.
120,462
<p>I've wrapped a quick hack as a plugin to add Google Analytics to my site. Named it "Google Analytics" and, sure enough, WP offered me to upgrade my v0.1 plugin to some random plugin from the plugin repo.</p> <p>I vaguely recall it getting raised a few times around WP 2.7 to 3.0. Is there a new API available somewhe...
[ { "answer_id": 120467, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 4, "selected": true, "text": "<p>You can remove you plugin from the <em>updateble</em> list with:</p>\n\n<pre><code>add_action( 'plugins_load...
2013/10/29
[ "https://wordpress.stackexchange.com/questions/120462", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1208/" ]
I've wrapped a quick hack as a plugin to add Google Analytics to my site. Named it "Google Analytics" and, sure enough, WP offered me to upgrade my v0.1 plugin to some random plugin from the plugin repo. I vaguely recall it getting raised a few times around WP 2.7 to 3.0. Is there a new API available somewhere to disa...
You can remove you plugin from the *updateble* list with: ``` add_action( 'plugins_loaded', function(){ add_filter( 'site_transient_update_plugins', function ( $value ) { if( isset( $value->response['google-analytics/google-analytics.php'] ) ) unset( $value->response['google-analytics/goog...
120,469
<p>How can i achive that? I found <a href="http://codex.wordpress.org/Function_Reference/count_user_posts" rel="nofollow">count_user_posts</a> and <a href="http://codex.wordpress.org/Function_Reference/get_users" rel="nofollow">get_users</a>, but how would I merge them into the desired result? Do I really have to use a...
[ { "answer_id": 120467, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 4, "selected": true, "text": "<p>You can remove you plugin from the <em>updateble</em> list with:</p>\n\n<pre><code>add_action( 'plugins_load...
2013/10/29
[ "https://wordpress.stackexchange.com/questions/120469", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33790/" ]
How can i achive that? I found [count\_user\_posts](http://codex.wordpress.org/Function_Reference/count_user_posts) and [get\_users](http://codex.wordpress.org/Function_Reference/get_users), but how would I merge them into the desired result? Do I really have to use a WP DB Query?
You can remove you plugin from the *updateble* list with: ``` add_action( 'plugins_loaded', function(){ add_filter( 'site_transient_update_plugins', function ( $value ) { if( isset( $value->response['google-analytics/google-analytics.php'] ) ) unset( $value->response['google-analytics/goog...
120,493
<p>I have bought a theme, but on a particular page i don't want to use the theme js/css files.</p> <p>The theme registers the files like</p> <pre><code>function add_our_scripts() { global $post; $options = get_option('radium_theme'); wp_enqueue_style( 'radium', RADIUM_CSS_URL . '/radium.css', false,'1.0...
[ { "answer_id": 120502, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p>All you need to dequeue that stylesheet is:</p>\n\n<pre><code>function remove_radium_scripts() {\n wp_deq...
2013/10/29
[ "https://wordpress.stackexchange.com/questions/120493", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9936/" ]
I have bought a theme, but on a particular page i don't want to use the theme js/css files. The theme registers the files like ``` function add_our_scripts() { global $post; $options = get_option('radium_theme'); wp_enqueue_style( 'radium', RADIUM_CSS_URL . '/radium.css', false,'1.0','all'); //the frame...
Use the correct action hook --------------------------- Notice the action hook being used: ``` add_action( 'wp_enqueue_scripts', 'add_our_scripts',0); ``` And the action hook you're defining/using: ``` add_action( 'test_remove_scripts', 'remove_radium_scripts', 999 ); ``` You need to hook into the *same action*:...
120,527
<p>i use this code to show post's thumbnail in my site but this code cant show the title Attribute of the thumbnails. </p> <p><strong>how can i add Title Attribute to WordPress thumbnails?</strong></p> <pre><code>&lt;?php if ( has_post_thumbnail() ) { the_post_thumbnail('large'); } else {?&gt; &lt;img alt="&lt;?php...
[ { "answer_id": 120530, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": false, "text": "<p>As per <a href=\"http://codex.wordpress.org/Function_Reference/the_post_thumbnail\" rel=\"noreferrer\">the...
2013/10/29
[ "https://wordpress.stackexchange.com/questions/120527", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39305/" ]
i use this code to show post's thumbnail in my site but this code cant show the title Attribute of the thumbnails. **how can i add Title Attribute to WordPress thumbnails?** ``` <?php if ( has_post_thumbnail() ) { the_post_thumbnail('large'); } else {?> <img alt="<?php the_title(); ?>" title="<?php the_title(); ?>...
You can do that because you can add all the attributes you need: ``` the_post_thumbnail( 'large', array( 'title' => get_the_title() ) ); ``` Please read on in the [Function Reference of the\_post\_thumbnail](http://codex.wordpress.org/Function_Reference/the_post_thumbnail).
120,544
<p>I have the following code on my site.</p> <pre><code>&lt;?php // image gallery content if( has_shortcode( $post-&gt;post_content, 'gallery' ) ) { $gallery = get_post_gallery_images( $post-&gt;ID ); $image_list = '&lt;ul id="cfImageGallery"&gt;'; foreach( $g...
[ { "answer_id": 120547, "author": "tfer77", "author_id": 41063, "author_profile": "https://wordpress.stackexchange.com/users/41063", "pm_score": 3, "selected": true, "text": "<p>If you're working within a template file, this code should work. However, I didn't test it.</p>\n\n<pre><code>&...
2013/10/29
[ "https://wordpress.stackexchange.com/questions/120544", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4130/" ]
I have the following code on my site. ``` <?php // image gallery content if( has_shortcode( $post->post_content, 'gallery' ) ) { $gallery = get_post_gallery_images( $post->ID ); $image_list = '<ul id="cfImageGallery">'; foreach( $gallery as $image ) {// Loop th...
If you're working within a template file, this code should work. However, I didn't test it. ``` <?php echo do_shortcode('[gallery size="full"]'); ?> ```
120,550
<p>Steps for problem reproduction:</p> <ol> <li>Open WordPress Admin Dashboard (I use version 3.7);</li> <li>Click on Page > Add Page;</li> <li>On the editor, choose the "HTML" Tab;</li> <li>Write <code>&lt;p&gt;Lorem ipsum dolor sit amet&lt;/p&gt;&lt;br&gt;</code> on the content area;</li> <li>Choose the "Visual" Tab...
[ { "answer_id": 120551, "author": "Suthan Bala", "author_id": 38866, "author_profile": "https://wordpress.stackexchange.com/users/38866", "pm_score": 1, "selected": false, "text": "<p>Once you save it, the <p> tags are automatically added to the contents. It only removes it when you have ...
2013/10/29
[ "https://wordpress.stackexchange.com/questions/120550", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35834/" ]
Steps for problem reproduction: 1. Open WordPress Admin Dashboard (I use version 3.7); 2. Click on Page > Add Page; 3. On the editor, choose the "HTML" Tab; 4. Write `<p>Lorem ipsum dolor sit amet</p><br>` on the content area; 5. Choose the "Visual" Tab; 6. Choose "HTML" Tab back; 7. The code `<p>Lorem ipsum dolor sit...
Once you save it, the tags are automatically added to the contents. It only removes it when you have a plain `<p>....</p>` but if you have `<p class='something'>...</p>` it would preserve it.
120,558
<p>Can you please let me know how I can dynamically register/link to my js files in wordpress? I have two js files as below code but I do not know how to map to them uring the <code>bloginfo()</code> as it is taking parameters! </p> <pre><code> &lt;!--[if lt IE 9]&gt; &lt;script src="assets/js/html5shiv.js"&gt;...
[ { "answer_id": 120551, "author": "Suthan Bala", "author_id": 38866, "author_profile": "https://wordpress.stackexchange.com/users/38866", "pm_score": 1, "selected": false, "text": "<p>Once you save it, the <p> tags are automatically added to the contents. It only removes it when you have ...
2013/10/29
[ "https://wordpress.stackexchange.com/questions/120558", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31793/" ]
Can you please let me know how I can dynamically register/link to my js files in wordpress? I have two js files as below code but I do not know how to map to them uring the `bloginfo()` as it is taking parameters! ``` <!--[if lt IE 9]> <script src="assets/js/html5shiv.js"></script> <script src="assets/js...
Once you save it, the tags are automatically added to the contents. It only removes it when you have a plain `<p>....</p>` but if you have `<p class='something'>...</p>` it would preserve it.
120,583
<p>i'm new to wordpress and i'm trying to create a website. i need display the content of the pages when corresponding menu items are clicked. my page.php contain</p> <pre><code>&lt;?php while ( have_posts() ) : the_post(); $page_data= $post-&gt;ID; if($page_data=='116') ...
[ { "answer_id": 120551, "author": "Suthan Bala", "author_id": 38866, "author_profile": "https://wordpress.stackexchange.com/users/38866", "pm_score": 1, "selected": false, "text": "<p>Once you save it, the <p> tags are automatically added to the contents. It only removes it when you have ...
2013/10/30
[ "https://wordpress.stackexchange.com/questions/120583", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41053/" ]
i'm new to wordpress and i'm trying to create a website. i need display the content of the pages when corresponding menu items are clicked. my page.php contain ``` <?php while ( have_posts() ) : the_post(); $page_data= $post->ID; if($page_data=='116') ...
Once you save it, the tags are automatically added to the contents. It only removes it when you have a plain `<p>....</p>` but if you have `<p class='something'>...</p>` it would preserve it.
120,589
<p>Is there any way to disable core and plugin updates? I am modifying a plugin and bit of <strong>WordPress Core</strong> (I know its a sin to do so), but can't help it.</p>
[ { "answer_id": 120590, "author": "Abhishek Kaushik", "author_id": 41048, "author_profile": "https://wordpress.stackexchange.com/users/41048", "pm_score": 4, "selected": true, "text": "<p>Yes you can do that…</p>\n\n<pre><code>define( 'DISALLOW_FILE_MODS', true ); \n</code></pre>\n\n<p>Pu...
2013/10/30
[ "https://wordpress.stackexchange.com/questions/120589", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40896/" ]
Is there any way to disable core and plugin updates? I am modifying a plugin and bit of **WordPress Core** (I know its a sin to do so), but can't help it.
Yes you can do that… ``` define( 'DISALLOW_FILE_MODS', true ); ``` Put this snippet in your `wp-config.php` file and you will able to disable core and plugin updates.
120,647
<p>Hi i tried for picking all images in a folder so that what ever images user puts in a specified folder inside my plugin i can take and use it in plugin.</p> <p>I tried the following php functions to pick images or files in folder</p> <pre><code>glob scandir </code></pre> <p>When i try the above in wordpress fram...
[ { "answer_id": 120653, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 2, "selected": false, "text": "<p><sub><sup><em>This Answer relates to the <a href=\"https://wordpress.stackexchange.com/revisions/120647/1\"...
2013/10/30
[ "https://wordpress.stackexchange.com/questions/120647", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35819/" ]
Hi i tried for picking all images in a folder so that what ever images user puts in a specified folder inside my plugin i can take and use it in plugin. I tried the following php functions to pick images or files in folder ``` glob scandir ``` When i try the above in wordpress framework am getting error `The syste...
`scandir` and `glob` are related to directory things, so tried with `WP_PLUGIN_DIR` instead of `plugins_url()` which return url but not directory. Below both function are useful `WP_PLUGIN_DIR` ``` plugin_dir_path( __FILE__ ) ``` I tried the above functions it worked well for me. Remember if you just use ``` <?...
120,686
<p>I'm starting with Wordpress, already achieved some queries, but this one... ugh! It's being a pain to me!</p> <p>What i want to do is this part of query:</p> <pre><code>" ... WHERE "VALUE_THAT_I_WANT" BETWEEN event_start_date AND event_end_date ..." </code></pre> <p>Where "event_start_date" and "event_end_date" a...
[ { "answer_id": 120688, "author": "Toni Michel Caubet", "author_id": 3435, "author_profile": "https://wordpress.stackexchange.com/users/3435", "pm_score": 1, "selected": false, "text": "<p>Didn't <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow\">test</a> it,...
2013/10/30
[ "https://wordpress.stackexchange.com/questions/120686", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41135/" ]
I'm starting with Wordpress, already achieved some queries, but this one... ugh! It's being a pain to me! What i want to do is this part of query: ``` " ... WHERE "VALUE_THAT_I_WANT" BETWEEN event_start_date AND event_end_date ..." ``` Where "event\_start\_date" and "event\_end\_date" are meta keys ( i want to use ...
This should work for you: ``` $tEA = array( 'post_type' => 'event', // you dont need meta_key as you use meta_query //'meta_key' => $metaKey, 'orderby' => 'meta_value', 'order' => $order, 'posts_per_page' => $postPerPage, 'meta_query' => array( array( 'key' => $metaKey, ...
120,689
<p>I need to change the rewrite-slug of the built in post-type 'post' to 'example.com/magazine/news/any-nice-news-item'.</p> <p>When I re-register the post-type 'post' and set the rewrite-slug to 'magazine/news' it works fine. But now I'm not sure about any side-effects. Does anybody have any positive or negative expe...
[ { "answer_id": 120728, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 0, "selected": false, "text": "<p>I wouldn't recommend reregistering the 'posts' post-type. Modifying _builtins can be a headache.</p>\n\...
2013/10/30
[ "https://wordpress.stackexchange.com/questions/120689", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41134/" ]
I need to change the rewrite-slug of the built in post-type 'post' to 'example.com/magazine/news/any-nice-news-item'. When I re-register the post-type 'post' and set the rewrite-slug to 'magazine/news' it works fine. But now I'm not sure about any side-effects. Does anybody have any positive or negative experience wit...
You do not need to re register post type. Symply go in you backend, *Settings > Permalinks* and set the permalink structure to a custom one: `/magazine/news/%postname%/` then save changes. See image below: --- ![enter image description here](https://i.stack.imgur.com/u39zk.jpg)
120,721
<h1>What am I trying to do?</h1> <p>Assign more than 1 category to a post so that it would appear in each category template without 1 main category in the URL.</p> <p>WP's default behavior when you select more than one category for a post is to assign the post to the category with the lowest ID.</p> <p>For example: If...
[ { "answer_id": 120722, "author": "Courtney Ivey", "author_id": 11224, "author_profile": "https://wordpress.stackexchange.com/users/11224", "pm_score": 1, "selected": false, "text": "<p>Developing locally first - using WAMP / MAMP or similar software - is a smart way to go...\nUsually, I'...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120721", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41148/" ]
What am I trying to do? ======================= Assign more than 1 category to a post so that it would appear in each category template without 1 main category in the URL. WP's default behavior when you select more than one category for a post is to assign the post to the category with the lowest ID. For example: If...
I STRONGLY suggest you take your time and set up a development server with versioning like GIT. It is awesome. But since i am in exactly the same position as you and have not yet done it myself, I will share how I do things. If I have changes to implement that will possibly bring down the site or do some whacky stuff t...
120,734
<p>I want to add a text widget to my new WordPress website, but in the text widget there are some PHP snippets and I am finding it difficult to do it.</p> <p>Please help me Guys.</p>
[ { "answer_id": 120735, "author": "Josh Karteson", "author_id": 40896, "author_profile": "https://wordpress.stackexchange.com/users/40896", "pm_score": -1, "selected": false, "text": "<pre><code>function add_php_text($text) {\n if (strpos($text, '&lt;' . '?') !== false) {\n ob_start();\n ...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120734", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40795/" ]
I want to add a text widget to my new WordPress website, but in the text widget there are some PHP snippets and I am finding it difficult to do it. Please help me Guys.
Instead you should consider using a shortcode. This is exactly the problem that shortcodes try to solve. By default, Widgets don't process shortcodes, but that can be easily changed. ``` add_filter( 'widget_text', 'do_shortcode' ); ``` This would allow you to use any shortcodes in the Widget text area. Next would b...
120,741
<pre><code> // Hook in add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); // Our hooked in function - $fields is passed via the filter! function custom_override_checkout_fields( $fields ) { $fields['order']['order_comments']['placeholder'] = 'Special delivery requirements'; $fields['...
[ { "answer_id": 120767, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 4, "selected": true, "text": "<p>You have to use the <code>woocommerce_default_address_fields</code> hook:</p>\n\n<pre><code>add_filt...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120741", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41154/" ]
``` // Hook in add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); // Our hooked in function - $fields is passed via the filter! function custom_override_checkout_fields( $fields ) { $fields['order']['order_comments']['placeholder'] = 'Special delivery requirements'; $fields['billing...
You have to use the `woocommerce_default_address_fields` hook: ``` add_filter( 'woocommerce_default_address_fields' , 'wpse_120741_wc_def_state_label' ); function wpse_120741_wc_def_state_label( $address_fields ) { $address_fields['state']['label'] = 'County'; return $address_fields; } ``` This (and more) ...
120,749
<p><strong>How would go about if I just want a temporary function?</strong> (It's a converter just for converting Access to Wordpress tables). I want to execute several times so therefore I want it automated, but I don't know how to execute the function after adding the filter in add_action(). After I'm done converting...
[ { "answer_id": 120767, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 4, "selected": true, "text": "<p>You have to use the <code>woocommerce_default_address_fields</code> hook:</p>\n\n<pre><code>add_filt...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120749", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38848/" ]
**How would go about if I just want a temporary function?** (It's a converter just for converting Access to Wordpress tables). I want to execute several times so therefore I want it automated, but I don't know how to execute the function after adding the filter in add\_action(). After I'm done converting, I will delete...
You have to use the `woocommerce_default_address_fields` hook: ``` add_filter( 'woocommerce_default_address_fields' , 'wpse_120741_wc_def_state_label' ); function wpse_120741_wc_def_state_label( $address_fields ) { $address_fields['state']['label'] = 'County'; return $address_fields; } ``` This (and more) ...
120,755
<p>What I need to achieve is to get all comments from all products in Woocommerce.</p> <p>This is not getting me ANY comments at all...</p> <pre><code>&lt;?php $comments = get_comments( array( 'post_type' =&gt; 'product') ); ?&gt; </code></pre> <p>However</p> <pre><code>&lt;?php $comments = get_comments( array( 'po...
[ { "answer_id": 120765, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>Please try this:</p>\n\n<pre><code> $args = array( \n 'number' =&gt; 100, \n ...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120755", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41162/" ]
What I need to achieve is to get all comments from all products in Woocommerce. This is not getting me ANY comments at all... ``` <?php $comments = get_comments( array( 'post_type' => 'product') ); ?> ``` However ``` <?php $comments = get_comments( array( 'post_id' => '4169') ); ``` Gets me comments for particul...
Please try this: ``` $args = array( 'number' => 100, 'status' => 'approve', 'post_status' => 'publish', 'post_type' => 'product' ); $comments = get_comments( $args ); ``` where you can edit the number of comments to your need...
120,759
<p>Is there any way to show a list of all posts without any preview of the content on the homepage?</p>
[ { "answer_id": 120761, "author": "adnan", "author_id": 38852, "author_profile": "https://wordpress.stackexchange.com/users/38852", "pm_score": -1, "selected": false, "text": "<p>you can use <code>query_posts</code> in any place you need </p>\n\n<pre><code>&lt;?php query_posts('order=dsc&...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120759", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41164/" ]
Is there any way to show a list of all posts without any preview of the content on the homepage?
If the posts are already shown on your page, just with a bunch of unnecessary text that you want to take away, do the following: 1. Open the template file of your homepage (it can be named different in different themes, so impossible to give you the exact name of file, but usually they are named like index.php or home...
120,793
<p>I'm trying to figure out how to insert a new post. I have a custom post-type (course) that is related to a custom taxonomy (categorycourses).</p> <p>I've managed to insert a post with custom post type course, <strong>but I can't figure out how to relate this post to custom taxonomy categorycourses</strong>.</p> <p...
[ { "answer_id": 120806, "author": "Sriram Sri", "author_id": 41045, "author_profile": "https://wordpress.stackexchange.com/users/41045", "pm_score": 2, "selected": false, "text": "<p>Try changing this line</p>\n\n<pre><code> wp_set_object_terms( $post_id, array($cat_ids), 'categorycourse...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120793", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38848/" ]
I'm trying to figure out how to insert a new post. I have a custom post-type (course) that is related to a custom taxonomy (categorycourses). I've managed to insert a post with custom post type course, **but I can't figure out how to relate this post to custom taxonomy categorycourses**. ``` //This will return array ...
I'll supply with an answer so people with the same issue in the future might be helped... ***The problem wasn't in the actual function. It was about when the taxonomy (categorycourses) was registered...*** Function for registerering custom post type course and course-category: ``` function courses_with_cats() { ...
120,810
<p>I have 4 videos in my single post which are being displayed using nextpage quicktag. To style pagination i am using the follwing code in single.php</p> <pre><code> &lt;div class="pagelink"&gt;&lt;?php wp_link_pages('before=LQ &amp;pagelink=Chapter %'); ?&gt;&lt;/div&gt; </code></pre> <p>its giving me output lik...
[ { "answer_id": 120802, "author": "user9", "author_id": 33790, "author_profile": "https://wordpress.stackexchange.com/users/33790", "pm_score": 2, "selected": false, "text": "<p>In the current Version (3.7) of Wordpress it is possible to just upload mp3 files to your post and insert them,...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120810", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41187/" ]
I have 4 videos in my single post which are being displayed using nextpage quicktag. To style pagination i am using the follwing code in single.php ``` <div class="pagelink"><?php wp_link_pages('before=LQ &pagelink=Chapter %'); ?></div> ``` its giving me output like *LQ Chapter 1 Chapter 2 Chapter 3 Chapter4* B...
In the current Version (3.7) of Wordpress it is possible to just upload mp3 files to your post and insert them, using the known media upload button. They will then render as a nice html5 player.
120,825
<p>So I am having an issue where I can't pull variables such as mysite.com/?utm_campaign=testing unless I am logged in as admin or editor. </p> <p>When logged out and just a regular users I can't grab any variables which start in utm_ such as utm_campaign. However utmcampaign works, and any other variable I try. Just...
[ { "answer_id": 120826, "author": "user9", "author_id": 33790, "author_profile": "https://wordpress.stackexchange.com/users/33790", "pm_score": 1, "selected": false, "text": "<p>did you try the <a href=\"http://codex.wordpress.org/Function_Reference/get_query_var\" rel=\"nofollow\">get_qu...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120825", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15412/" ]
So I am having an issue where I can't pull variables such as mysite.com/?utm\_campaign=testing unless I am logged in as admin or editor. When logged out and just a regular users I can't grab any variables which start in utm\_ such as utm\_campaign. However utmcampaign works, and any other variable I try. Just not utm...
It's not a core behaviour to overwrite the global $\_GET array, which means it's likely that something else then WordPress itself is the issue here. I would suggest the following steps to debug the issue: * Disable all active plugins and revert to standard theme, see if the problem persists. * If the problem is still...
120,828
<p>I am working in a Child theme on a page with a custom template. That custom template is not displaying any text that I enter into the wordpress editor. How do I "call" that text and display it in my custom template?</p> <p>Is there something like</p> <pre><code>&lt;?php get_editor_text(); ?&gt; </code></pre> <p>I...
[ { "answer_id": 120836, "author": "Alex Dumitru", "author_id": 5810, "author_profile": "https://wordpress.stackexchange.com/users/5810", "pm_score": 0, "selected": false, "text": "<p>You do it like in any other template. <code>the_title()</code> for the title, <code>the_content()</code> f...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120828", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26841/" ]
I am working in a Child theme on a page with a custom template. That custom template is not displaying any text that I enter into the wordpress editor. How do I "call" that text and display it in my custom template? Is there something like ``` <?php get_editor_text(); ?> ``` I just need a way to display the text in...
I was able to fix my problem. In order to access the content I used -- ``` <?php /* Start the Loop */ ?> <?php while(have_posts()) : the_post(); ?> <?php the_content();?> <?php endwhile; ?> ``` By adding that snippet of code directly into my template page I was able to easily add the content from the visual editor. ...
120,831
<p>I'm trying to add custom CSS (set via theme options) to the TinyMCE visual editor in WordPress. On the front end, the theme generates this CSS and outputs it on the <code>wp_head</code> hook. The problem I'm running into is being able to add that CSS output to the editor.</p> <p>This can't be done with <code>add_ed...
[ { "answer_id": 120835, "author": "ungestaltbar", "author_id": 12449, "author_profile": "https://wordpress.stackexchange.com/users/12449", "pm_score": 4, "selected": true, "text": "<h2>Solution 1</h2>\n<p>This works as javascript solution:</p>\n<p>Example:</p>\n<pre><code>tinyMCE.activeEd...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120831", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41192/" ]
I'm trying to add custom CSS (set via theme options) to the TinyMCE visual editor in WordPress. On the front end, the theme generates this CSS and outputs it on the `wp_head` hook. The problem I'm running into is being able to add that CSS output to the editor. This can't be done with `add_editor_style( 'editor-style....
Solution 1 ---------- This works as javascript solution: Example: ``` tinyMCE.activeEditor.dom.addStyle('p {color:red; font-size:28px;}'); ``` just open your js console and paste it for a quick test. To target a specific editor one should use: ``` tinyMCE.getInstanceById('##editorID##').dom.addStyle('p {color:red...
120,833
<p>I was able to add a extra custom field, named <code>sticky</code>, to a custom taxonomy, using the <a href="http://www.deluxeblogtips.com/taxonomy-meta-script-for-wordpress/" rel="nofollow noreferrer">wp taxonomy meta</a> plugin, like this:</p> <pre><code>function YOUR_PREFIX_register_taxonomy_meta_boxes() { //...
[ { "answer_id": 120896, "author": "lonchbox", "author_id": 7251, "author_profile": "https://wordpress.stackexchange.com/users/7251", "pm_score": 0, "selected": false, "text": "<p>first change this:</p>\n\n<pre><code>// First meta section\n$meta_sections[] = array(\n 'title' =&gt; ...
2013/10/31
[ "https://wordpress.stackexchange.com/questions/120833", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3435/" ]
I was able to add a extra custom field, named `sticky`, to a custom taxonomy, using the [wp taxonomy meta](http://www.deluxeblogtips.com/taxonomy-meta-script-for-wordpress/) plugin, like this: ``` function YOUR_PREFIX_register_taxonomy_meta_boxes() { // Make sure there's no errors when the plugin is deactivated or...
OK, got it ``` <?php $types = get_terms( 'tvr_amenity', array( 'parent' => '0', 'hide_empty' => 1 ) ); foreach( $types as $type ) : $myname = trim($type->name); $meta = get_option('amenity_sticky'); if (empty($meta))...
120,860
<p>I'm trying to show a link to the full size image of an attached image. I took a code for Wordpress' Twelve Thirteen theme:</p> <pre><code>&lt;?php $metadata = wp_get_attachment_metadata(); printf( '&lt;span class="attachment-meta full-size-link"&gt;&lt;a href="%1$s" rel="lightbox"&gt;%3$s&lt;/a&gt;&lt;/span&gt;', ...
[ { "answer_id": 120863, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>That's not going to work, instead just use <code>wp_get_attachment_image_src</code> , it takes a size parameter.</...
2013/11/01
[ "https://wordpress.stackexchange.com/questions/120860", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40667/" ]
I'm trying to show a link to the full size image of an attached image. I took a code for Wordpress' Twelve Thirteen theme: ``` <?php $metadata = wp_get_attachment_metadata(); printf( '<span class="attachment-meta full-size-link"><a href="%1$s" rel="lightbox">%3$s</a></span>', esc_url( wp_get_attachment_url() ), esc_a...
That's not going to work, instead just use `wp_get_attachment_image_src` , it takes a size parameter. ``` // get the $attachment_id $attach_stuff = wp_get_attachment_image_src( $attachment_id, 'full'); var_dump($attach_stuff); ``` You will be returned an array fo values to work with: ``` [0] => url [1] => width [2]...
120,880
<p>I tried to install WordPress Multi-Site. But I ran into some problems with the DB.</p> <pre><code>wp_1_posts: Table 'studioc_editionspanda.wp_1_posts' doesn't exist wp_1_comments: Table 'studioc_editionspanda.wp_1_comments' doesn't exist wp_1_links: Table 'studioc_editionspanda.wp_1_links' doesn't exist wp_1_option...
[ { "answer_id": 255491, "author": "S P", "author_id": 32572, "author_profile": "https://wordpress.stackexchange.com/users/32572", "pm_score": 2, "selected": false, "text": "<p>You most probably only added one of the following in your <code>wp-config.php</code> file thinking they were the ...
2013/11/01
[ "https://wordpress.stackexchange.com/questions/120880", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36110/" ]
I tried to install WordPress Multi-Site. But I ran into some problems with the DB. ``` wp_1_posts: Table 'studioc_editionspanda.wp_1_posts' doesn't exist wp_1_comments: Table 'studioc_editionspanda.wp_1_comments' doesn't exist wp_1_links: Table 'studioc_editionspanda.wp_1_links' doesn't exist wp_1_options: Table 'stud...
You most probably only added one of the following in your `wp-config.php` file thinking they were the same, as [m73mitchell](https://www.digitalocean.com/community/questions/some-tables-not-getting-created-in-wordpress-setup-tutorial) and I had done: ``` define('WP_ALLOW_MULTISITE', true); define('MULTISITE', true); ...
120,886
<p>I'd like to include content from one Page (named "contact_text") to another Page in a specific spot (both of these are WordPress admin pages). I've followed <a href="https://stackoverflow.com/questions/4090698/wordpress-include-content-of-one-page-in-another">this Stack Overflow thread</a>.</p> <p>However I don't b...
[ { "answer_id": 120888, "author": "Zogot", "author_id": 41159, "author_profile": "https://wordpress.stackexchange.com/users/41159", "pm_score": 0, "selected": false, "text": "<p>You could take exactly that code and apply into a shortcode if you want.</p>\n\n<pre><code>add_shortcode( 'show...
2013/11/01
[ "https://wordpress.stackexchange.com/questions/120886", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41214/" ]
I'd like to include content from one Page (named "contact\_text") to another Page in a specific spot (both of these are WordPress admin pages). I've followed [this Stack Overflow thread](https://stackoverflow.com/questions/4090698/wordpress-include-content-of-one-page-in-another). However I don't believe I can call a ...
Another shortcode option (add the following to your functions.php). With this one, you have two options. You can query by the post/page ID (will work for any post type), or the page name/slug (only works for pages). ``` // Add "Show Content" Shortcode function wpse_120886_show_content( $atts ) { // Attributes ...
120,887
<p>I created a custom folder ("/templates") and I put all of my template files in the folder. instead of root ("/wp-content/themes/my-theme/"). It works fine.</p> <p>Do I have to add some function for indicating "/templates/" folder as my templates folder? Usually you put them on root, right? </p> <p>It works fine no...
[ { "answer_id": 120900, "author": "Rahil Wazir", "author_id": 36349, "author_profile": "https://wordpress.stackexchange.com/users/36349", "pm_score": 2, "selected": false, "text": "<p>You can place your templates within your active theme where ever you want but you have to include your fi...
2013/11/01
[ "https://wordpress.stackexchange.com/questions/120887", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34463/" ]
I created a custom folder ("/templates") and I put all of my template files in the folder. instead of root ("/wp-content/themes/my-theme/"). It works fine. Do I have to add some function for indicating "/templates/" folder as my templates folder? Usually you put them on root, right? It works fine now but I just wond...
As of [WordPress 3.4](https://nacin.com/2012/03/29/page-templates-in-subdirectories-new-in-wordpress-3-4/) you can put your page templates in whatever **direct subdirectory** you need, it doesn't sound like you can put them into sub-sub directories but I haven't tested this. I suggest storing templates into `/page-tem...
120,894
<p>I'm using the new WP media manager for a branding plugin (well, new from 3.5), and it is working well.</p> <p>My only issue is that I have an 'Attachment Details' area on the right, allowing users to edit, delete and generally mess with images.</p> <p>Is there a way to remove this area? Thanks.</p> <p>Here is an ...
[ { "answer_id": 120926, "author": "Toni Michel Caubet", "author_id": 3435, "author_profile": "https://wordpress.stackexchange.com/users/3435", "pm_score": 1, "selected": false, "text": "<p>Have you tried to remove it with js before opening the manager?</p>\n\n<pre><code>$(document).ready(...
2013/11/01
[ "https://wordpress.stackexchange.com/questions/120894", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10097/" ]
I'm using the new WP media manager for a branding plugin (well, new from 3.5), and it is working well. My only issue is that I have an 'Attachment Details' area on the right, allowing users to edit, delete and generally mess with images. Is there a way to remove this area? Thanks. Here is an image showing which area...
I use CSS for that: ``` add_action('admin_head-post.php', 'hide_media_stuff_wpse_120894' ); add_action('admin_head-post-new.php', 'hide_media_stuff_wpse_120894' ); function hide_media_stuff_wpse_120894(){ ?> <style type="text/css"> .attachment-details [data-setting="title"], .attachment-detail...
120,902
<p><em>Allow me to explain with an example, for the sake of clarity. Please take the time to <strong>read it all to get a good idea</strong> of what I am exactly after.</em></p> <p>On my WordPress site categories are used as <strong>Editions</strong> and there are 4 of them — Category (slug):</p> <ul> <li>US (main)</...
[ { "answer_id": 120907, "author": "Zogot", "author_id": 41159, "author_profile": "https://wordpress.stackexchange.com/users/41159", "pm_score": -1, "selected": false, "text": "<p>Perhaps the easiest solution is to hook into <code>save_post</code> and if the a special $_POST variable is se...
2013/11/01
[ "https://wordpress.stackexchange.com/questions/120902", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10691/" ]
*Allow me to explain with an example, for the sake of clarity. Please take the time to **read it all to get a good idea** of what I am exactly after.* On my WordPress site categories are used as **Editions** and there are 4 of them — Category (slug): * US (main) * UK (uk) * India (in) * International (intl) The perm...
One way to deal with the problem is to use the `redirect_canonical` filter to cancel the redirect (that happens when the category that the post is assigned to doesn't match the category slug in the requested post URL) for posts assigned to *International (intl)* category. ``` /* * Related core file: wp-includes/canon...
120,917
<p>I have installed the latest WordPress on my EC2 Ubuntu 13.1 server. Once I have changed the permalink to use <code>/%post-name%/</code>, I encounter 404 not found for posts. I have followed almost everything here in this article (<a href="http://www.felfelworld.com/2013/02/12/page-not-found-permalink-wordpress/" rel...
[ { "answer_id": 120907, "author": "Zogot", "author_id": 41159, "author_profile": "https://wordpress.stackexchange.com/users/41159", "pm_score": -1, "selected": false, "text": "<p>Perhaps the easiest solution is to hook into <code>save_post</code> and if the a special $_POST variable is se...
2013/11/01
[ "https://wordpress.stackexchange.com/questions/120917", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41230/" ]
I have installed the latest WordPress on my EC2 Ubuntu 13.1 server. Once I have changed the permalink to use `/%post-name%/`, I encounter 404 not found for posts. I have followed almost everything here in this article ([Page Not Found - Permalink WordPress — FelfelWorld.com](http://www.felfelworld.com/2013/02/12/page-n...
One way to deal with the problem is to use the `redirect_canonical` filter to cancel the redirect (that happens when the category that the post is assigned to doesn't match the category slug in the requested post URL) for posts assigned to *International (intl)* category. ``` /* * Related core file: wp-includes/canon...
120,941
<p>I have two custom post types (Branding Elements and Products) that I'm showing on a single page, and the client wants to be able to control the sort order of the page.</p> <p>What would be the best course of action for creating a way for the client to re-order two post types with a drag n drop interface? Because th...
[ { "answer_id": 176239, "author": "Josh Burson", "author_id": 66384, "author_profile": "https://wordpress.stackexchange.com/users/66384", "pm_score": 0, "selected": false, "text": "<p>Use categories.</p>\n\n<p>Make a category that you can apply to both post types, and then use this plugin...
2013/11/01
[ "https://wordpress.stackexchange.com/questions/120941", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41241/" ]
I have two custom post types (Branding Elements and Products) that I'm showing on a single page, and the client wants to be able to control the sort order of the page. What would be the best course of action for creating a way for the client to re-order two post types with a drag n drop interface? Because they're 2 di...
It's common to utilize the WordPress navigational menu UI to get the **drag/drop** feature for *free*. *I think there are already some answers, on this site, explaining this better than I can, but I can't seem to find them for you. So let my try to construct one simple example:* 1. We go to *Appearance/Menus* and cre...
120,946
<p>On the search results page (<code>search.php</code>) I would like to perform an additional <code>WP_Query</code> to keep a specific order of search result types e.g. search results from authors should always be shown before the other results -</p> <p><strong>The first few pages should hold the author results, the o...
[ { "answer_id": 121365, "author": "sam", "author_id": 9384, "author_profile": "https://wordpress.stackexchange.com/users/9384", "pm_score": 1, "selected": false, "text": "<p>Filter the main query to include the additional posts. You can add query params with <code>pre_get_posts</code> or ...
2013/11/01
[ "https://wordpress.stackexchange.com/questions/120946", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22546/" ]
On the search results page (`search.php`) I would like to perform an additional `WP_Query` to keep a specific order of search result types e.g. search results from authors should always be shown before the other results - **The first few pages should hold the author results, the other results should be shown on all th...
I think the only solution is to skip the sql pagination and handle it only via php. My idea involves 2 functions, one hooked on `pre_get_posts`, the second to filter `the_posts`. The first function does 2 things: 1. unset the paged value for search, in this way all the posts are returned from the SQL query. 2. save t...
120,947
<p>I have an options page for my plugin, but cannot seem to figure out how to create an option to allow admins to select a page that will display my plugins content.</p> <p>Does anyone have an example of how this is done?</p> <p>EDIT: I created a plugin and have a widget to search the content of my plugin. However I...
[ { "answer_id": 120960, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Here's a quick options page that will give you a dropdown select for choosing a page, using the <a href=\"http://co...
2013/11/01
[ "https://wordpress.stackexchange.com/questions/120947", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41240/" ]
I have an options page for my plugin, but cannot seem to figure out how to create an option to allow admins to select a page that will display my plugins content. Does anyone have an example of how this is done? EDIT: I created a plugin and have a widget to search the content of my plugin. However I need the widget ...
Here's a quick options page that will give you a dropdown select for choosing a page, using the [`get_pages`](http://codex.wordpress.org/Function_Reference/get_pages) function. The [Settings API](http://codex.wordpress.org/Settings_API) takes care of saving the options for you. You can then use [`get_option`](http://co...
120,959
<p>I'm deeply confused by this one: I have a WordPress install on a Media Temple GS [one of many which work fine and are configured almost exactly the same] which is occasionally giving me 404s sitewide. When this happens I get 3 errors together in my PHP error log:</p> <pre><code>[01-Nov-2013 22:20:50 UTC] PHP Notice...
[ { "answer_id": 307508, "author": "kierzniak", "author_id": 132363, "author_profile": "https://wordpress.stackexchange.com/users/132363", "pm_score": 0, "selected": false, "text": "<p>You have not enough information to solve your problem. Try to add full stack trace and request informatio...
2013/11/01
[ "https://wordpress.stackexchange.com/questions/120959", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12624/" ]
I'm deeply confused by this one: I have a WordPress install on a Media Temple GS [one of many which work fine and are configured almost exactly the same] which is occasionally giving me 404s sitewide. When this happens I get 3 errors together in my PHP error log: ``` [01-Nov-2013 22:20:50 UTC] PHP Notice: Trying to g...
There are two types of 404 errors: WordPress-generated, and server-generated. In some server environments, 404s could be inaccurately displayed by the server in cases of CPU overload or due to certain instances of misconfiguration, etc. Usually server-generated 404 errors will say something like "Nginx" or "Apache" at...
120,987
<p>Does anyone know how to resize the served images, so the image has a width due to the content containers width. I do not mean to resize the image via 100% width css, but instead resize the actual dimensions and size if the image itself. </p> <p>For e.g.: An image in an article which has the dimensions of <code>400p...
[ { "answer_id": 120990, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>As things like this are often requested, I've written a plugin named <a href=\"https://github.com/franz-josef-kais...
2013/11/02
[ "https://wordpress.stackexchange.com/questions/120987", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17691/" ]
Does anyone know how to resize the served images, so the image has a width due to the content containers width. I do not mean to resize the image via 100% width css, but instead resize the actual dimensions and size if the image itself. For e.g.: An image in an article which has the dimensions of `400px × 300px`. But...
As things like this are often requested, I've written a plugin named ["Dynamic Image Resize"](https://github.com/franz-josef-kaiser/Dynamic-Image-Resize). It's basically a plugin, but, due to it's one-file approach, it can be used as mu-plugin or theme include without a problem. It's main purpose is to resize single im...
120,992
<p>I want to create a small plugin to automatically purge the APC opcode cache after specific actions in the Wordpress admin interface. This is necessary if e.g. apc.stat is set to 0, as a change to a file then doesn't reset its cache value in the opcode cache and so calls will use the old, cached, out-of-date file. To...
[ { "answer_id": 121006, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://core.trac.wordpress.org/browser/trunk/src/wp-admin/theme-editor.php#L89\" rel=\"nofollow\">...
2013/11/02
[ "https://wordpress.stackexchange.com/questions/120992", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6495/" ]
I want to create a small plugin to automatically purge the APC opcode cache after specific actions in the Wordpress admin interface. This is necessary if e.g. apc.stat is set to 0, as a change to a file then doesn't reset its cache value in the opcode cache and so calls will use the old, cached, out-of-date file. Total...
[The system redirects after an update with `updated=true`](http://core.trac.wordpress.org/browser/trunk/src/wp-admin/theme-editor.php#L89). You could check for that `GET` parameter on the `load-theme-editor.php` hook, something like: ``` add_action( 'load-theme-editor.php', function() { if (isset($_GET['update...
120,996
<p>I have action which adds meta field with value on post publish. Problem is that when I update post meta field is reset to default value. </p> <p>I already tried 'new_to_publish' instead of 'publish_post' but it doesn't work. </p> <pre><code>add_action('publish_post', 'add_custom_field_automatically'); function ad...
[ { "answer_id": 120999, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 3, "selected": true, "text": "<p>Like @milo pointed out in the comment, checking if the post meta exists is the easiest way to achiev...
2013/11/02
[ "https://wordpress.stackexchange.com/questions/120996", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40822/" ]
I have action which adds meta field with value on post publish. Problem is that when I update post meta field is reset to default value. I already tried 'new\_to\_publish' instead of 'publish\_post' but it doesn't work. ``` add_action('publish_post', 'add_custom_field_automatically'); function add_custom_field_auto...
Like @milo pointed out in the comment, checking if the post meta exists is the easiest way to achieve what you want - like this: ``` add_action('publish_post', 'wpse120996_add_custom_field_automatically'); function wpse120996_add_custom_field_automatically($post_id) { global $wpdb; $votes_count = get_post_meta...
121,051
<p>How can I get comments from multiple post type? I want to display 5 comments from my different post types pages.</p> <pre><code>&lt;?php $defaults = array( 'number' =&gt; 5, 'post_type' =&gt; array('post','authors','movies') ); $comments = get_comments($defaults); ?&gt; </code></pre>
[ { "answer_id": 121054, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": true, "text": "<p>It looks like <a href=\"http://core.trac.wordpress.org/browser/tags/3.7.1/src/wp-includes/comment.php#L165\" r...
2013/11/03
[ "https://wordpress.stackexchange.com/questions/121051", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41283/" ]
How can I get comments from multiple post type? I want to display 5 comments from my different post types pages. ``` <?php $defaults = array( 'number' => 5, 'post_type' => array('post','authors','movies') ); $comments = get_comments($defaults); ?> ```
It looks like [`WP_Comment_Query()`](http://core.trac.wordpress.org/browser/tags/3.7.1/src/wp-includes/comment.php#L165) only supports a single post type. You can adjust it, by using the `comments_clauses` filter. Try for example: ``` $defaults = array( 'number' => 5, 'post_type' => array( 'post','author...
121,080
<p>I have custom field <code>my_cf</code> for Taxonomy/Term. How can I get and output value with custom field for taxonomy/term? </p> <p>I've tried using: </p> <pre><code>$variable = get_field('my_cf', 'basic'); echo $variable; </code></pre> <p>where basic - name for my taxonomy. But this doesn't work. </p> <p>...
[ { "answer_id": 121096, "author": "Joey Yax", "author_id": 6148, "author_profile": "https://wordpress.stackexchange.com/users/6148", "pm_score": 1, "selected": false, "text": "<p>Is your field data stored in wp_options? If so...</p>\n\n<pre><code>$term_id = 12345;\n$term_meta = get_option...
2013/11/03
[ "https://wordpress.stackexchange.com/questions/121080", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40473/" ]
I have custom field `my_cf` for Taxonomy/Term. How can I get and output value with custom field for taxonomy/term? I've tried using: ``` $variable = get_field('my_cf', 'basic'); echo $variable; ``` where basic - name for my taxonomy. But this doesn't work. Any suggestions?
I can't really explain it any better than the [ACF documentation page I posted in the comments](http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/): > > All the API functions can be used with a taxonomy term, however, a second parameter is required to target the term ID. This...
121,082
<p>I want to store list of user IDs in the post meta who have rated a post . So, for each post I will need to check the post meta to see if the user id exists in it or not.</p> <p>So my question is that, is it good idea to store that information in the post meta OR should I create a table and add it in the table. Will...
[ { "answer_id": 121096, "author": "Joey Yax", "author_id": 6148, "author_profile": "https://wordpress.stackexchange.com/users/6148", "pm_score": 1, "selected": false, "text": "<p>Is your field data stored in wp_options? If so...</p>\n\n<pre><code>$term_id = 12345;\n$term_meta = get_option...
2013/11/03
[ "https://wordpress.stackexchange.com/questions/121082", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41290/" ]
I want to store list of user IDs in the post meta who have rated a post . So, for each post I will need to check the post meta to see if the user id exists in it or not. So my question is that, is it good idea to store that information in the post meta OR should I create a table and add it in the table. Will there be ...
I can't really explain it any better than the [ACF documentation page I posted in the comments](http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/): > > All the API functions can be used with a taxonomy term, however, a second parameter is required to target the term ID. This...
121,084
<p>I have a WordPress site hosted on GoDaddy, it's a Windows server, (i have the <code>web.config</code> set up). and <code>.htaccess</code> correctly configured. The site was working on <code>example.com/wordpress</code> , as it was a development test. I moved the site to <code>example.com</code> . </p> <p>I changed ...
[ { "answer_id": 179788, "author": "James", "author_id": 68366, "author_profile": "https://wordpress.stackexchange.com/users/68366", "pm_score": 4, "selected": true, "text": "<p>I had the same issue. To fix it I had to make some changes to the database. Use phpMyAdmin or just log directly ...
2013/11/03
[ "https://wordpress.stackexchange.com/questions/121084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38401/" ]
I have a WordPress site hosted on GoDaddy, it's a Windows server, (i have the `web.config` set up). and `.htaccess` correctly configured. The site was working on `example.com/wordpress` , as it was a development test. I moved the site to `example.com` . I changed the site url and wordpress URL to `example.com` on the...
I had the same issue. To fix it I had to make some changes to the database. Use phpMyAdmin or just log directly into the database and look at your `wp_options` table. Check the following two fields: `siteurl` and `home`. ``` SELECT * FROM wp_options WHERE option_name IN ('siteurl', 'home'); ``` Make sure these field...
121,089
<p>I need to get the featured image outside the loop. This is so that I can have a different full-screen background image for each page, set by the featured image.</p> <p>After doing some research I was able to get the post ID outside the loop.</p> <p>This is what I've got:</p> <pre><code>$page_object = get_queried_...
[ { "answer_id": 121090, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>You have a couple of syntax errors, but in your question you state that...</p>\n\n<blockquote>\n <p>This is...
2013/11/03
[ "https://wordpress.stackexchange.com/questions/121089", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31560/" ]
I need to get the featured image outside the loop. This is so that I can have a different full-screen background image for each page, set by the featured image. After doing some research I was able to get the post ID outside the loop. This is what I've got: ``` $page_object = get_queried_object(); $page_id = get...
if the result you're looking for is a printout of the URL, like in your example, then this should work: ``` $page_id = get_queried_object_id(); if ( has_post_thumbnail( $page_id ) ) : $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $page_id ), 'optional-size' ); $image = $image_array[0]; els...
121,093
<p>I'm building a simple plugin and need to be able to access current post id when user clicks custom tinyMCE button (inside its onclick function). How should I get current post ID to do that.</p> <p>Just for this example, code from this tutorial: <a href="http://brettterpstra.com/2010/04/17/adding-a-tinymce-button/" ...
[ { "answer_id": 121102, "author": "josh", "author_id": 24323, "author_profile": "https://wordpress.stackexchange.com/users/24323", "pm_score": 3, "selected": true, "text": "<p>You would need to place a globally namespaced javascript variable in your php code where you enqueue the script t...
2013/11/03
[ "https://wordpress.stackexchange.com/questions/121093", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25644/" ]
I'm building a simple plugin and need to be able to access current post id when user clicks custom tinyMCE button (inside its onclick function). How should I get current post ID to do that. Just for this example, code from this tutorial: <http://brettterpstra.com/2010/04/17/adding-a-tinymce-button/> can be used, and a...
You would need to place a globally namespaced javascript variable in your php code where you enqueue the script to be loaded for the editor pages. So, this code will enqueue a script function to be added to the "edit post/page" screens: ``` add_action('admin_head','my_add_styles_admin'); function my_add_styles_admin(...
121,103
<p>I want to change header and menu based on what category a post is listed in. </p> <p>I could duplicate the post and assigned each of the two categories separately but this sounds messy and bleh.</p> <p>The post/s in this example belong in both "pirtek" and "btcc". </p> <p><a href="http://www.talkativebroadcasting...
[ { "answer_id": 121109, "author": "gmazzap", "author_id": 35541, "author_profile": "https://wordpress.stackexchange.com/users/35541", "pm_score": 2, "selected": true, "text": "<p>One easy way is to use <a href=\"http://codex.wordpress.org/Function_Reference/has_category\" rel=\"nofollow\"...
2013/11/04
[ "https://wordpress.stackexchange.com/questions/121103", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37330/" ]
I want to change header and menu based on what category a post is listed in. I could duplicate the post and assigned each of the two categories separately but this sounds messy and bleh. The post/s in this example belong in both "pirtek" and "btcc". <http://www.talkativebroadcasting.co.uk/> but the posts with pir...
One easy way is to use [`has_category`](http://codex.wordpress.org/Function_Reference/has_category) function. E.g. in your header you can use ``` if ( has_category('pirtek') ) { $header = '/path/to/pirtek/header' } else { $header = '/path/to/standard/header' } ``` If the post has the 'kirtek' category, then the...
121,123
<p>I'm Twitter Bootstrap and need to add data-toggle="modal" attribute to the a tag of menu link. Upon searching most all results reference doing a walking for Twitter Bootstrap dropdown menus however this menu has no dropdowns and I only need to add the particular attribute.</p> <p>Next I found this: <a href="https:/...
[ { "answer_id": 121135, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": false, "text": "<p>The second <code>$item</code> argument, which is being made available to your filter function, contains a menu item...
2013/11/04
[ "https://wordpress.stackexchange.com/questions/121123", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5465/" ]
I'm Twitter Bootstrap and need to add data-toggle="modal" attribute to the a tag of menu link. Upon searching most all results reference doing a walking for Twitter Bootstrap dropdown menus however this menu has no dropdowns and I only need to add the particular attribute. Next I found this: [Add custom attributes to ...
Specifically editing the code you provided in the original question: ``` add_filter( 'nav_menu_link_attributes', 'wpse121123_contact_menu_atts', 10, 3 ); function wpse121123_contact_menu_atts( $atts, $item, $args ) { // The ID of the target menu item $menu_target = 123; // inspect $item if ($item->ID == $menu...
121,132
<p>I'm developing a theme especially for Bānglā blog posting, and it'd be under GNU license. I questioned about a Calendar Widget translation with some problems today, and got a <a href="https://wordpress.stackexchange.com/questions/121101/how-to-hook-some-unicode-texts-into-calendar-widget-safely#comment170266_121101"...
[ { "answer_id": 121135, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": false, "text": "<p>The second <code>$item</code> argument, which is being made available to your filter function, contains a menu item...
2013/11/04
[ "https://wordpress.stackexchange.com/questions/121132", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
I'm developing a theme especially for Bānglā blog posting, and it'd be under GNU license. I questioned about a Calendar Widget translation with some problems today, and got a [comment](https://wordpress.stackexchange.com/questions/121101/how-to-hook-some-unicode-texts-into-calendar-widget-safely#comment170266_121101) s...
Specifically editing the code you provided in the original question: ``` add_filter( 'nav_menu_link_attributes', 'wpse121123_contact_menu_atts', 10, 3 ); function wpse121123_contact_menu_atts( $atts, $item, $args ) { // The ID of the target menu item $menu_target = 123; // inspect $item if ($item->ID == $menu...
121,137
<p>I have this function:</p> <pre><code>function test_add_my_stylesheet() { wp_register_style( 'test-admin-style', plugins_url('../css/style.css', __FILE__) ); wp_enqueue_style( 'test-admin-style' ); } </code></pre> <p>but the css is not loaded in my admin area. Why?</p> <p>In the html source code from the b...
[ { "answer_id": 121152, "author": "user9", "author_id": 33790, "author_profile": "https://wordpress.stackexchange.com/users/33790", "pm_score": 1, "selected": false, "text": "<p>I am just using</p>\n\n<pre><code> wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/css/boo...
2013/11/04
[ "https://wordpress.stackexchange.com/questions/121137", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17368/" ]
I have this function: ``` function test_add_my_stylesheet() { wp_register_style( 'test-admin-style', plugins_url('../css/style.css', __FILE__) ); wp_enqueue_style( 'test-admin-style' ); } ``` but the css is not loaded in my admin area. Why? In the html source code from the browser it looks like this: ``` <...
[`plugins_url`](http://codex.wordpress.org/Function_Reference/plugins_url) `plugins_url( $path, $plugin );` You can use: ``` wp_enqueue_style( 'test-admin-style', plugins_url( 'plugin-unique-name/css/plugin.min.css') ); ``` or you can use ``` wp_enqueue_style( 'test-admin-style', plugins_url( 'css/admin.min.css',...
121,140
<p>I have a query which looks like this:</p> <pre><code>$args = arguments for the query $query = new WP_Query($args); while ($query-&gt;have_posts()): $query-&gt;the_post(); $post_id = get_the_ID(); echo my_function($post_id); endwhile; wp_reset_query(); endif; </code></pre> <p>Then in <code>my_function</code> there...
[ { "answer_id": 121142, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 2, "selected": false, "text": "<p>Using <a href=\"http://codex.wordpress.org/Function_Reference/wp_reset_query\" rel=\"nofollow noref...
2013/11/04
[ "https://wordpress.stackexchange.com/questions/121140", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36783/" ]
I have a query which looks like this: ``` $args = arguments for the query $query = new WP_Query($args); while ($query->have_posts()): $query->the_post(); $post_id = get_the_ID(); echo my_function($post_id); endwhile; wp_reset_query(); endif; ``` Then in `my_function` there's another query with a second function. Th...
Using [wp\_reset\_query()](http://codex.wordpress.org/Function_Reference/wp_reset_query) really just makes sense if you are using [query\_posts()](http://codex.wordpress.org/Function_Reference/query_posts), which you don't need and shouldn't do - see [When should you use WP\_Query vs query\_posts() vs get\_posts()?](ht...
121,144
<p>I wondering the session was disable in wordpress. I try to find some information on using session variables in the wordpress. I tried the following method to implement session variables in the wordpress site. </p> <p>I tried this way.</p> <pre><code>&lt;?php session_start(); $_SESSION['firstname'] = $_POST['fir...
[ { "answer_id": 121147, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 3, "selected": true, "text": "<p>Your code doesn't seem to be wrong, it's just how I would do it - see my <a href=\"https://wordpress...
2013/11/04
[ "https://wordpress.stackexchange.com/questions/121144", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24481/" ]
I wondering the session was disable in wordpress. I try to find some information on using session variables in the wordpress. I tried the following method to implement session variables in the wordpress site. I tried this way. ``` <?php session_start(); $_SESSION['firstname'] = $_POST['firstname']; ?> ``` If i ...
Your code doesn't seem to be wrong, it's just how I would do it - see my [answer](https://wordpress.stackexchange.com/a/117260/22534) here. So the question would be is your session getting started? Try debugging this: ``` // do you have a session id $s_id = session_id(); print_r($s_id); // can you declare a bogus ses...
121,146
<p>E.g. I have a meta field called <code>car_number</code>:</p> <p>So, normally I would try something like this to get this value:</p> <pre><code>$car_value = get_post_meta($post-&gt;ID, 'car_number'); </code></pre> <p>But the porblem is that I need to get the row only where the <code>car_number</code> is highest e...
[ { "answer_id": 121149, "author": "user9", "author_id": 33790, "author_profile": "https://wordpress.stackexchange.com/users/33790", "pm_score": 1, "selected": false, "text": "<p>Try this method</p>\n\n<pre><code>function end_meta_value( $end = \"max\", $meta )\n{\n global $wpdb;\n $...
2013/11/04
[ "https://wordpress.stackexchange.com/questions/121146", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17368/" ]
E.g. I have a meta field called `car_number`: So, normally I would try something like this to get this value: ``` $car_value = get_post_meta($post->ID, 'car_number'); ``` But the porblem is that I need to get the row only where the `car_number` is highest e.g. 45. so I need somehow to get the highest value and do ...
The `WP_Query` has a feature called `meta_query`. Using it allows you to either query by value or *numeric* value: ``` $car = new WP_Query( array( 'post_type' => array( 'cars' ), 'meta_key' => 'car_number', 'orderby' => 'meta_value_num', 'posts_per_page' => 1, 'order' => ...
121,154
<p>Let's say that I have few posts with meta key "videoid". Value of that meta key is different for every post (and has to be different). When adding new post, how can I check if videoid with that exact value already exist for some older posts? I used this as a refference for adding custom meta box to admin area of WP:...
[ { "answer_id": 121163, "author": "SomeoneS", "author_id": 17624, "author_profile": "https://wordpress.stackexchange.com/users/17624", "pm_score": 0, "selected": false, "text": "<p>Found it:</p>\n\n<pre><code>$args = array(\n 'meta_query' =&gt; array(\n array(\n 'key'...
2013/11/04
[ "https://wordpress.stackexchange.com/questions/121154", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17624/" ]
Let's say that I have few posts with meta key "videoid". Value of that meta key is different for every post (and has to be different). When adding new post, how can I check if videoid with that exact value already exist for some older posts? I used this as a refference for adding custom meta box to admin area of WP: <h...
Just do a query with `WP_Query` using the [Custom Field parameters (`meta_query`)](https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters) to look for posts with the meta key and the value - exemplary code: ``` // args to query for your key $args = array( 'post_type' => 'you...
121,160
<p>I had a bit of an issue with wp-to-twitter publishing a tweet linking to a post that was set as 'pending' that i had emailed to my wordpress.org site. The email included a footer, which included my mobile number.</p> <p>I decided to create my own plugin.</p> <pre><code>add_action('publish_post', 'tcr_tweet'); /* ...
[ { "answer_id": 121181, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 2, "selected": false, "text": "<p>There is an extra action hook for scheduled posts: <a href=\"https://codex.wordpress.org/Plugin_API...
2013/11/04
[ "https://wordpress.stackexchange.com/questions/121160", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10914/" ]
I had a bit of an issue with wp-to-twitter publishing a tweet linking to a post that was set as 'pending' that i had emailed to my wordpress.org site. The email included a footer, which included my mobile number. I decided to create my own plugin. ``` add_action('publish_post', 'tcr_tweet'); /* the function */ funct...
I reworked (added another version of) my function to remove the if statement to check post status, as the post is scheduled to publish it turns out i don't need to check it again. ``` /* the function */ function tcr_tweet2($postID) { /* get the post that's being published */ $post = get_post($...
121,183
<p>On my single product pages, I would like to change the meta data so that the Category button for the product does not display. I can't seem to figure out where this is called. I've looked in various php files. Thank you for your help.</p>
[ { "answer_id": 195521, "author": "Nick", "author_id": 76720, "author_profile": "https://wordpress.stackexchange.com/users/76720", "pm_score": 2, "selected": false, "text": "<p>As an alternative to editing the meta template, you can prevent the meta information from being displayed on sin...
2013/11/04
[ "https://wordpress.stackexchange.com/questions/121183", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41328/" ]
On my single product pages, I would like to change the meta data so that the Category button for the product does not display. I can't seem to figure out where this is called. I've looked in various php files. Thank you for your help.
As an alternative to editing the meta template, you can prevent the meta information from being displayed on single product pages at all. This can be handy if you also don't want to display the SKUs. Here is how to do it: ``` remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 )...
121,185
<p>While developing more and more customized Wordpress themes, I began adding more custom functions to my theme's functions.php file. While I try to make their names to be self-explanatory, I think this is not enough.</p> <p>Considering that you might not be the only web developer working on a theme, or that there mig...
[ { "answer_id": 121189, "author": "GhostToast", "author_id": 13676, "author_profile": "https://wordpress.stackexchange.com/users/13676", "pm_score": 1, "selected": false, "text": "<p>As I work for a company, I typically prepend my function names with our company nickname, for functions th...
2013/11/04
[ "https://wordpress.stackexchange.com/questions/121185", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27835/" ]
While developing more and more customized Wordpress themes, I began adding more custom functions to my theme's functions.php file. While I try to make their names to be self-explanatory, I think this is not enough. Considering that you might not be the only web developer working on a theme, or that there might be some...
I almost used the same convention as @GhostToas but to me I usually use classes to minimize conflict. For internal or company project: `class MyCompany_Classname {}` For Client specific project: `class ClientProject_Classname {}` Using a class will absolutely help you avoid conflicts and thus, you can name your functio...