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 |
|---|---|---|---|---|---|---|
192,429 | <p>I was writing a small plugin to remove some menu items for non-admin users from the backend, and discovered that my plugin didn't do anything unless I specified a priority in my code:</p>
<pre><code>add_action('admin_bar_menu', 'remove_toolbar_items', 999);
</code></pre>
<p>Without the <code>999</code>, the code d... | [
{
"answer_id": 192431,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>range of priority values?\n range of priority values?</p>\n</blockquote>\n\n<p>Generally, sp... | 2015/06/23 | [
"https://wordpress.stackexchange.com/questions/192429",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26666/"
] | I was writing a small plugin to remove some menu items for non-admin users from the backend, and discovered that my plugin didn't do anything unless I specified a priority in my code:
```
add_action('admin_bar_menu', 'remove_toolbar_items', 999);
```
Without the `999`, the code doesn't remove the items in my `remove... | >
> range of priority values?
> range of priority values?
>
>
>
Generally, speaking, you can't know *a priori* what priority something is hooked with. The priority needed depends on how other callbacks where hooked in. Often that is the default value of 10 but it could be anywhere between `PHP_INT_MIN` (negative ... |
192,434 | <p>I'm using CPT UI and I've manage to create a working custom post type called "Cars"<br/>
I would like to have "Sub Custom Post Type" like "Honda" for example and models like "M1", "M2", "M3" related to "Honda".<br/>
<br/>
So if I click on Honda it will display the models.<br/>
How can I achieve the same concept of P... | [
{
"answer_id": 192436,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress doesn't support nested post types, though you can created hierarchical types similar to the Core \... | 2015/06/23 | [
"https://wordpress.stackexchange.com/questions/192434",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74315/"
] | I'm using CPT UI and I've manage to create a working custom post type called "Cars"
I would like to have "Sub Custom Post Type" like "Honda" for example and models like "M1", "M2", "M3" related to "Honda".
So if I click on Honda it will display the models.
How can I achieve the same concept of POST+CATEGORY+SU... | WordPress doesn't support nested post types, though you can created hierarchical types similar to the Core "Page" type. However, what you are describing, including this sample "POST+CATEGORY+SUBCATEOGRY" is a [custom taxonomy](https://codex.wordpress.org/Function_Reference/register_taxonomy) for your Car post type. The... |
192,450 | <p>I am using multisite to translate WordPress website and I have the plugin <a href="https://wordpress.org/plugins/nmedia-user-file-uploader/" rel="nofollow noreferrer">https://wordpress.org/plugins/nmedia-user-file-uploader/</a>
which I want to be accessible from all languages. From all site you should see the same u... | [
{
"answer_id": 192494,
"author": "JJ Rohrer",
"author_id": 8972,
"author_profile": "https://wordpress.stackexchange.com/users/8972",
"pm_score": -1,
"selected": false,
"text": "<p>I almost thought this was a duplicate to <a href=\"https://wordpress.stackexchange.com/questions/15939/netwo... | 2015/06/23 | [
"https://wordpress.stackexchange.com/questions/192450",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75137/"
] | I am using multisite to translate WordPress website and I have the plugin <https://wordpress.org/plugins/nmedia-user-file-uploader/>
which I want to be accessible from all languages. From all site you should see the same uploaded content and settings.
How can I achieve that?
Currently if I upload in one language I won'... | The generic way to do it, is by using the `pre_option_{option}` <https://codex.wordpress.org/Plugin_API/Filter_Reference/pre_option_(option_name)> filter to override the "local" settings and use the value being stored in your "main" sub site.
something like
```
add_filter( 'pre_option_the_plugin_option_name', functio... |
192,478 | <p>Its simple and answered quite often: I want to get the post thumbnail variable. Even if there is a lot of input, I could not make it work for me.</p>
<p>Here is my current code I use somewhere inside my <code>front_page.php</code> template:</p>
<pre><code><?php
$args = array( 'numberposts' => '2' );
$recen... | [
{
"answer_id": 192480,
"author": "Nia Skywalk",
"author_id": 74433,
"author_profile": "https://wordpress.stackexchange.com/users/74433",
"pm_score": 2,
"selected": true,
"text": "<p>Initially, I saw the double and single quotes all jumbled up. This did fix some of what I saw, but I final... | 2015/06/24 | [
"https://wordpress.stackexchange.com/questions/192478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75154/"
] | Its simple and answered quite often: I want to get the post thumbnail variable. Even if there is a lot of input, I could not make it work for me.
Here is my current code I use somewhere inside my `front_page.php` template:
```
<?php
$args = array( 'numberposts' => '2' );
$recent_posts = wp_get_recent_posts( $args )... | Initially, I saw the double and single quotes all jumbled up. This did fix some of what I saw, but I finally had time to test the code you put up.
First step, I used `var_dump` on `$recent_posts` to make sure I was getting the usable values.
Next, I echoed each variable as it was called, to make sure I knew what was ... |
192,488 | <p>I am building a site client who makes anywhere from 20-50 news posts per day. I'd like to have a news feed where it shows the date / post count as an H3 and then list all the posts for that day underneath.</p>
<p>Example...</p>
<p><strong>TODAY (4 posts)</strong>
- News Article Link
- News Article Link
- News A... | [
{
"answer_id": 192480,
"author": "Nia Skywalk",
"author_id": 74433,
"author_profile": "https://wordpress.stackexchange.com/users/74433",
"pm_score": 2,
"selected": true,
"text": "<p>Initially, I saw the double and single quotes all jumbled up. This did fix some of what I saw, but I final... | 2015/06/24 | [
"https://wordpress.stackexchange.com/questions/192488",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75164/"
] | I am building a site client who makes anywhere from 20-50 news posts per day. I'd like to have a news feed where it shows the date / post count as an H3 and then list all the posts for that day underneath.
Example...
**TODAY (4 posts)**
- News Article Link
- News Article Link
- News Article Link
- News Article Li... | Initially, I saw the double and single quotes all jumbled up. This did fix some of what I saw, but I finally had time to test the code you put up.
First step, I used `var_dump` on `$recent_posts` to make sure I was getting the usable values.
Next, I echoed each variable as it was called, to make sure I knew what was ... |
192,496 | <p>I'm creating a custom walker menu where I'm adding custom fields to the menu items, but I would like the fields to be specific to menu locations. I can get all the menu locations with the menu ID's assigned to them from:</p>
<pre><code>$menu_locations = get_nav_menu_locations();
</code></pre>
<p>This outputs an ar... | [
{
"answer_id": 192497,
"author": "James Barrett",
"author_id": 74733,
"author_profile": "https://wordpress.stackexchange.com/users/74733",
"pm_score": -1,
"selected": false,
"text": "<p>wp_get_nav_menu_object( $menu );</p>\n\n<blockquote>\n <p>Returns nav menu object when given a menu i... | 2015/06/24 | [
"https://wordpress.stackexchange.com/questions/192496",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75163/"
] | I'm creating a custom walker menu where I'm adding custom fields to the menu items, but I would like the fields to be specific to menu locations. I can get all the menu locations with the menu ID's assigned to them from:
```
$menu_locations = get_nav_menu_locations();
```
This outputs an array like:
```
array:2 [
... | You'll find it much easier to control which fields are shown, by controlling which walker is used. Rather than trying to 'toggle' the fields inside the walker.
I also wanted to show a bunch of custom fields, and only show them on a menu at a particular menu location. So I used the following...
```
add_filter( 'wp_edi... |
192,513 | <p>I'm looking for some help in creating a query based on fields I made in Advanced Custom Fields. I'd like to create a query that would loop through a custom post type, using arguments such as:</p>
<pre><code>?genre=Dance&keyword=&mood=&album=
</code></pre>
<p>What I expect from this query is all posts w... | [
{
"answer_id": 192497,
"author": "James Barrett",
"author_id": 74733,
"author_profile": "https://wordpress.stackexchange.com/users/74733",
"pm_score": -1,
"selected": false,
"text": "<p>wp_get_nav_menu_object( $menu );</p>\n\n<blockquote>\n <p>Returns nav menu object when given a menu i... | 2015/06/24 | [
"https://wordpress.stackexchange.com/questions/192513",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75173/"
] | I'm looking for some help in creating a query based on fields I made in Advanced Custom Fields. I'd like to create a query that would loop through a custom post type, using arguments such as:
```
?genre=Dance&keyword=&mood=&album=
```
What I expect from this query is all posts with the `genre` meta-field of "Dance" ... | You'll find it much easier to control which fields are shown, by controlling which walker is used. Rather than trying to 'toggle' the fields inside the walker.
I also wanted to show a bunch of custom fields, and only show them on a menu at a particular menu location. So I used the following...
```
add_filter( 'wp_edi... |
192,555 | <p>I want my media-library and all currently uploaded files distributed and available to all users. I am using the <a href="https://wordpress.org/plugins/user-role-editor/" rel="nofollow">User Role Editor Plugin</a></p>
<p>Is there any functions.php hack that makes all media-uploads visible to all users and roles?</p>... | [
{
"answer_id": 192784,
"author": "Mitul",
"author_id": 74728,
"author_profile": "https://wordpress.stackexchange.com/users/74728",
"pm_score": -1,
"selected": false,
"text": "<p>I have not tested but the following code will help you please add the following two lines of code to your func... | 2015/06/25 | [
"https://wordpress.stackexchange.com/questions/192555",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | I want my media-library and all currently uploaded files distributed and available to all users. I am using the [User Role Editor Plugin](https://wordpress.org/plugins/user-role-editor/)
Is there any functions.php hack that makes all media-uploads visible to all users and roles?
I have a subscriber that is possible t... | The plugin you mentioned is only reportedly tested up to WordPress version 3.6.1.
I would not (in general) recommend abandoned plugins, because they might impose security risks.
Additionally it uses PHP4 class constructors, that might soon be deprecated and it calls non static methods in a static way.
If you remove ... |
192,597 | <p>In my WordPress project, I have several different <code>custom post types</code> and they all share a <strong>common</strong> taxonomy. I am in the final stage of the project and now is time to link all custom post types using a sidebar widget. The problem I am having is that I don't know the appropriate way to get ... | [
{
"answer_id": 193758,
"author": "Caio Mar",
"author_id": 54189,
"author_profile": "https://wordpress.stackexchange.com/users/54189",
"pm_score": 0,
"selected": false,
"text": "<p>Good news, I figured out a way to accomplish this. Here is my solution.</p>\n\n<p>Taking my example above, I... | 2015/06/25 | [
"https://wordpress.stackexchange.com/questions/192597",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54189/"
] | In my WordPress project, I have several different `custom post types` and they all share a **common** taxonomy. I am in the final stage of the project and now is time to link all custom post types using a sidebar widget. The problem I am having is that I don't know the appropriate way to get the `term link` linked to t... | This code display all posts of all categories of **genre taxonomy** for **custom post type book**. Now, For different **custom post type (author, product ) you have to change Custom Post Type Name inside $arg of WP\_Query().** You will get term link using get\_term\_link($catterm) function or you can use also [get\_the... |
192,608 | <p>I have restricted a users capabilities</p>
<pre><code>$capabilities = array(
'delete_posts' => true,
'delete_published_posts' => true,
'edit_posts' => true,
'edit_published_posts' => true,
'publish_posts' => true,
'read' =>... | [
{
"answer_id": 192610,
"author": "sakibmoon",
"author_id": 23214,
"author_profile": "https://wordpress.stackexchange.com/users/23214",
"pm_score": 1,
"selected": false,
"text": "<p>You haven't missed any capabilities. User should be able to insert images into the editor with these capabi... | 2015/06/25 | [
"https://wordpress.stackexchange.com/questions/192608",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51823/"
] | I have restricted a users capabilities
```
$capabilities = array(
'delete_posts' => true,
'delete_published_posts' => true,
'edit_posts' => true,
'edit_published_posts' => true,
'publish_posts' => true,
'read' => true,
'upload_files' ... | You haven't missed any capabilities. User should be able to insert images into the editor with these capabilities.
The only problem I can think of is that, you are trying to modify the capabilities of a role which won't work.
[See this section](https://codex.wordpress.org/Function_Reference/add_role#Delete_existing_r... |
192,619 | <p>I am using wp_localize_script to pass values to a jquery script. Sometimes this might happen several times on the same page, which means I need to set a different variable name to each wp_localize_script. That also means that my jquery script doesn't know what is the variable name being passed by wp_localize_script ... | [
{
"answer_id": 192610,
"author": "sakibmoon",
"author_id": 23214,
"author_profile": "https://wordpress.stackexchange.com/users/23214",
"pm_score": 1,
"selected": false,
"text": "<p>You haven't missed any capabilities. User should be able to insert images into the editor with these capabi... | 2015/06/25 | [
"https://wordpress.stackexchange.com/questions/192619",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30984/"
] | I am using wp\_localize\_script to pass values to a jquery script. Sometimes this might happen several times on the same page, which means I need to set a different variable name to each wp\_localize\_script. That also means that my jquery script doesn't know what is the variable name being passed by wp\_localize\_scri... | You haven't missed any capabilities. User should be able to insert images into the editor with these capabilities.
The only problem I can think of is that, you are trying to modify the capabilities of a role which won't work.
[See this section](https://codex.wordpress.org/Function_Reference/add_role#Delete_existing_r... |
192,624 | <p>I'm trying to mock <code>get_adjacent_post</code> for unit testing but I'm not sure how to mock global function in PHPUnit</p>
<pre><code> $badCode = $this->getMockBuilder('get_adjacent_post')
->setMethods(array('somthing'))
->getMock();
</code></pre>
<p>Here's what I got so far which o... | [
{
"answer_id": 192701,
"author": "J.D.",
"author_id": 27757,
"author_profile": "https://wordpress.stackexchange.com/users/27757",
"pm_score": 2,
"selected": false,
"text": "<p>I think you are looking for <a href=\"https://github.com/10up/wp_mock\" rel=\"nofollow\">WP_Mock</a>:</p>\n\n<bl... | 2015/06/25 | [
"https://wordpress.stackexchange.com/questions/192624",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62360/"
] | I'm trying to mock `get_adjacent_post` for unit testing but I'm not sure how to mock global function in PHPUnit
```
$badCode = $this->getMockBuilder('get_adjacent_post')
->setMethods(array('somthing'))
->getMock();
```
Here's what I got so far which obviously doesn't work.
And here's how I use ... | I think you are looking for [WP\_Mock](https://github.com/10up/wp_mock):
>
> WP\_Mock is an API mocking framework, built and maintained by 10up for the purpose of making it possible to properly unit test within WordPress.
>
>
>
From [an example there](https://github.com/10up/wp_mock#using-wp_mock), you'd mock `ge... |
192,708 | <p>I am working on a site where I use get_template_part to retrieve the loop. In the header of the template I specified so it runs the global query. </p>
<pre><code>global $user_ID, $wp_query, $pagename;
</code></pre>
<p>Now, what does best practice say if I want multiple queries on the same page? I tried to simply ... | [
{
"answer_id": 249416,
"author": "Jackie Taferner",
"author_id": 109052,
"author_profile": "https://wordpress.stackexchange.com/users/109052",
"pm_score": 0,
"selected": false,
"text": "<p>For anyone stumbling across this post with the same problem, I was able to resolve it by removing t... | 2015/06/26 | [
"https://wordpress.stackexchange.com/questions/192708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7820/"
] | I am working on a site where I use get\_template\_part to retrieve the loop. In the header of the template I specified so it runs the global query.
```
global $user_ID, $wp_query, $pagename;
```
Now, what does best practice say if I want multiple queries on the same page? I tried to simply go in and specify another... | Did you migrate from managed wp to unmanaged? Check this page
<https://ru.godaddy.com/help/move-a-managed-wordpress-site-to-an-unmanaged-wordpress-account-19798>
In the site directory, locate the /wp-content/mu-plugins/ directory, and delete the gd-system-plugin and gd-system-plugin.php files.
In the wp-config.php fi... |
192,733 | <p>I'm using Advanced Custom Fields and Content Protector plugins in trying to protect an iframe for eventbrite ticket registration that gets displayed through Event Calendar plugin. I believe I'm wrapping the part that displayed the iframe with the Content Protector shortcode, but it gets displayed anyway even before ... | [
{
"answer_id": 192734,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 2,
"selected": false,
"text": "<p><code>do_action</code> does not return text, it just does the action. So, calling <code>do_action( 'tribe_events_s... | 2015/06/26 | [
"https://wordpress.stackexchange.com/questions/192733",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74495/"
] | I'm using Advanced Custom Fields and Content Protector plugins in trying to protect an iframe for eventbrite ticket registration that gets displayed through Event Calendar plugin. I believe I'm wrapping the part that displayed the iframe with the Content Protector shortcode, but it gets displayed anyway even before ent... | `do_action` does not return text, it just does the action. So, calling `do_action( 'tribe_events_single_event_after_the_meta' )` in your `do_shortcode` call there will cause the iframe to be output before the shortcode. |
192,773 | <p>Is it possible to replace a <code>get_template_directory()</code> in my child's functions.php file?</p>
<p>I want to make changes to the file:</p>
<pre><code>/**
* Load Custom Post types file.
*/
require get_template_directory() . '/inc/post-types.php';
</code></pre>
<p>I'd obviously prefer my work not be overwri... | [
{
"answer_id": 192774,
"author": "James Barrett",
"author_id": 74733,
"author_profile": "https://wordpress.stackexchange.com/users/74733",
"pm_score": 4,
"selected": false,
"text": "<p>You need to use <code>get_stylesheet_directory_uri()</code> instead of <code>get_template_directory()</... | 2015/06/27 | [
"https://wordpress.stackexchange.com/questions/192773",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62370/"
] | Is it possible to replace a `get_template_directory()` in my child's functions.php file?
I want to make changes to the file:
```
/**
* Load Custom Post types file.
*/
require get_template_directory() . '/inc/post-types.php';
```
I'd obviously prefer my work not be overwritten when I update my theme, so can I un-reg... | Late answer, but in Wordpress 4.7 two new functions were introduced to address this question.
`get_theme_file_path()` (for absolute file paths) and `get_theme_file_uri()` (for URLs) work just like `get_template_part()` in that they will automatically look in the child theme for that file first, then fallback to the pa... |
192,778 | <p>So I have this array (just taking an example, it's dynamically built up):</p>
<pre><code>$v_values = array(
array("C1","C2"),
array("F1","F2")
);
$v_name = array("color","fabric");
$v_price = array(
array(1000,2000),
array(3000,4000)
);
... | [
{
"answer_id": 192809,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 0,
"selected": false,
"text": "<p>with your code, you have this : </p>\n\n<blockquote>\n <p>+++++++++++++++++++++++++++++++++++++++++++++++++++\n ... | 2015/06/27 | [
"https://wordpress.stackexchange.com/questions/192778",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75314/"
] | So I have this array (just taking an example, it's dynamically built up):
```
$v_values = array(
array("C1","C2"),
array("F1","F2")
);
$v_name = array("color","fabric");
$v_price = array(
array(1000,2000),
array(3000,4000)
);
```
Now I wa... | I found a solution with a recursive function
```
function decomposePrice($base, $iValue, $values, $prices) {
$d = array();
foreach ($prices as $i => $p) {
$baseP = "$base{$values[$iValue][$i]}|";
if (!is_array($p)) {
$d[$baseP] = $p;
} else {
$d = array_merg... |
192,781 | <p>I need some kind of plugin (if it exists) or a wp query which would display number of posts published within a certain time range.</p>
<p><em>For example:</em></p>
<p>I need to know how many posts have been published since 2015-06-01 until now -- 2015-06-27.</p>
<p>I really hope someone could help me out.</p>
<p... | [
{
"answer_id": 192782,
"author": "Mitul",
"author_id": 74728,
"author_profile": "https://wordpress.stackexchange.com/users/74728",
"pm_score": 1,
"selected": false,
"text": "<p>You can fetch the record using bellow query </p>\n\n<pre><code>$posts= get_posts(array(\n 'numberpos... | 2015/06/27 | [
"https://wordpress.stackexchange.com/questions/192781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75317/"
] | I need some kind of plugin (if it exists) or a wp query which would display number of posts published within a certain time range.
*For example:*
I need to know how many posts have been published since 2015-06-01 until now -- 2015-06-27.
I really hope someone could help me out.
Thanks. | You can fetch the record using bellow query
```
$posts= get_posts(array(
'numberposts' => -1,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'date_query' => array(
'column' => 'post_date',
'after' ... |
192,785 | <p>The concept is to put a Button in Post Content which the user will click. </p>
<p>Two things - The ID of the post and Number of times the user clicks the Button should be displayed.</p>
<p>Reason - With this we are presenting Posts as Products and with that button user can add products,
and number of clicks on th... | [
{
"answer_id": 193049,
"author": "Hari Om Gupta",
"author_id": 68792,
"author_profile": "https://wordpress.stackexchange.com/users/68792",
"pm_score": -1,
"selected": false,
"text": "<p>I think you need to start session at init action, find the piece of code given below..\nmay be helpful... | 2015/06/27 | [
"https://wordpress.stackexchange.com/questions/192785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19409/"
] | The concept is to put a Button in Post Content which the user will click.
Two things - The ID of the post and Number of times the user clicks the Button should be displayed.
Reason - With this we are presenting Posts as Products and with that button user can add products,
and number of clicks on the button will sig... | I think in your code you must add this line for ajax acting
```
jQuery.ajax({
type : 'POST',
url : '<?php echo admin_url('admin-ajax.php'); ?>',
data : { action : 'vg_show_post_id', post_id: $post_id, data-id: true },
),
``` |
192,789 | <p>Is it possible to add a CSS class to ALL links generated from the HTML tab of the post editor?</p>
<p>That is to have the part class='myclass" added automatically?</p>
<pre><code><a class="myclass" href="http://www.google.com">Click me</a>
</code></pre>
<p>EDIT to avoid misunderstanding: The class has... | [
{
"answer_id": 192791,
"author": "cptstarling",
"author_id": 74024,
"author_profile": "https://wordpress.stackexchange.com/users/74024",
"pm_score": 1,
"selected": false,
"text": "<p>It would be more efficient to add a container with a certain class name around content that has been crea... | 2015/06/27 | [
"https://wordpress.stackexchange.com/questions/192789",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54737/"
] | Is it possible to add a CSS class to ALL links generated from the HTML tab of the post editor?
That is to have the part class='myclass" added automatically?
```
<a class="myclass" href="http://www.google.com">Click me</a>
```
EDIT to avoid misunderstanding: The class has to be added in the editor and not on the fly... | It would be more efficient to add a container with a certain class name around content that has been created with the HTML tab. That way you're avoiding the code getting bulky. |
192,805 | <p>For example,any "naked" code, i.e.:</p>
<pre><code>IF ($_POST) then....,
</code></pre>
<p>runs directly, before any WP action.
for example, this runs later (even with point 1):</p>
<pre><code>add_action('init','my_function',1);
</code></pre>
<p>I want to execute my code before any WP action starts. Which hook e... | [
{
"answer_id": 192791,
"author": "cptstarling",
"author_id": 74024,
"author_profile": "https://wordpress.stackexchange.com/users/74024",
"pm_score": 1,
"selected": false,
"text": "<p>It would be more efficient to add a container with a certain class name around content that has been crea... | 2015/06/27 | [
"https://wordpress.stackexchange.com/questions/192805",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33667/"
] | For example,any "naked" code, i.e.:
```
IF ($_POST) then....,
```
runs directly, before any WP action.
for example, this runs later (even with point 1):
```
add_action('init','my_function',1);
```
I want to execute my code before any WP action starts. Which hook executes at first? | It would be more efficient to add a container with a certain class name around content that has been created with the HTML tab. That way you're avoiding the code getting bulky. |
192,854 | <p>I'll try explain this the best I can...</p>
<p>I have a search form on my homepage:</p>
<pre><code><form role="search" method="get" id="searchform" class="form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label class="u-visuallyHidden" for="s">Search for property:</label>
&... | [
{
"answer_id": 192856,
"author": "lucian",
"author_id": 70333,
"author_profile": "https://wordpress.stackexchange.com/users/70333",
"pm_score": 1,
"selected": false,
"text": "<p>The default \"pretty\" alternative to <code>?s=</code> is <code>/search/</code> - you should be able to use th... | 2015/06/28 | [
"https://wordpress.stackexchange.com/questions/192854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51284/"
] | I'll try explain this the best I can...
I have a search form on my homepage:
```
<form role="search" method="get" id="searchform" class="form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label class="u-visuallyHidden" for="s">Search for property:</label>
<input type="search" class="form-input search-... | None of the above worked for me. Found another solution by overwriting the search rewrite rules using the search\_rewrite\_rules filter.
1 - Add this to the functions.php of your theme:
```
add_filter( 'search_rewrite_rules', function($rules) {
$new_rules = [];
// New search slug here
$new_search_slu... |
192,872 | <p>I am a content supervisor on a wordpress site, it uses <a href="https://wordpress.org/plugins/wordpress-seo/" rel="nofollow">wordpress seo by yoast</a> plugin. My duty includes analyzing the content and marking it sticky if seems fit. When I mark a particular post as sticky, there is a function which then sets the p... | [
{
"answer_id": 192874,
"author": "Christine Cooper",
"author_id": 24875,
"author_profile": "https://wordpress.stackexchange.com/users/24875",
"pm_score": 0,
"selected": false,
"text": "<p>Why don't you just check if the post is sticky and then add noindex? You can use the <a href=\"https... | 2015/06/28 | [
"https://wordpress.stackexchange.com/questions/192872",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25508/"
] | I am a content supervisor on a wordpress site, it uses [wordpress seo by yoast](https://wordpress.org/plugins/wordpress-seo/) plugin. My duty includes analyzing the content and marking it sticky if seems fit. When I mark a particular post as sticky, there is a function which then sets the post to only appear on the cat... | In my effort to solve this I discovered a [great resource for wordpress hooks](http://hookr.io/) for the job and found the right hook `wpseo_saved_postdata` [here](http://hookr.io/actions/wpseo_saved_postdata/). Feel free to modify the code if you think it could be better. For now, it works for me.
```
function set_no... |
192,902 | <p>I don't get any errors, but the post images are not displayed on the front page, all other pages displays the images correctly. How can I fix this? Here is the site</p>
<p>The front page is set to display the recent posts.</p>
<p>This is the index.php file</p>
<pre><code><?php get_header(); ?>
<?php
... | [
{
"answer_id": 192903,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Something that generates the image links is broken. You are not getting a valid <code>src</code> attribute i... | 2015/06/29 | [
"https://wordpress.stackexchange.com/questions/192902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15760/"
] | I don't get any errors, but the post images are not displayed on the front page, all other pages displays the images correctly. How can I fix this? Here is the site
The front page is set to display the recent posts.
This is the index.php file
```
<?php get_header(); ?>
<?php
// get options
$pinthis_infinite... | Something that generates the image links is broken. You are not getting a valid `src` attribute in the `title` tag. The result is:
```
<p class="thumb">
<a href="http://paper-backgrounds.com/red-grunge-concrete-texture-3/" title="Red Grunge Concrete Texture">
<img src="undefined" alt="Red Grunge Concrete Textu... |
192,917 | <p>I want do a custom query to get all products with an especific attribute ("demo" in my case)
The query what i want returns from this:</p>
<pre><code>a:5:{s:4:"demo";
a:6:{s:4:"name";
s:4:"DEMO";
s:5:"value";
s:366:"LINK TO DEMO";
s:8:"position";
s:1:"0";
s:10:"is_visible";
i:0;
s:12:... | [
{
"answer_id": 192919,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 1,
"selected": false,
"text": "<p>try something like this</p>\n\n<pre><code>$args = array(\n \"post_type\" => \"product\",\n \"meta_query\... | 2015/06/29 | [
"https://wordpress.stackexchange.com/questions/192917",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75388/"
] | I want do a custom query to get all products with an especific attribute ("demo" in my case)
The query what i want returns from this:
```
a:5:{s:4:"demo";
a:6:{s:4:"name";
s:4:"DEMO";
s:5:"value";
s:366:"LINK TO DEMO";
s:8:"position";
s:1:"0";
s:10:"is_visible";
i:0;
s:12:"is_variation"... | OK I HAVE ALREADY!! yuhuuu!
Thanks a lot guys!!
I have this:
```
$args = array (
'post_type' => 'product',
'posts_per_page' => -1,
'meta_query' => array(
array(
'value' => 'demo',
'compare' => 'like'
),
),
);
```
Well this works at least fo... |
192,944 | <p>When I Import Mysql from local server to web ser it is showng me error</p>
<h1>1115 - Unknown character set: 'utf8mb4' in Creating wordpress wp_comment table</h1>
<pre><code>CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
//
//
) ENGINE = INNODB DEFAULT CHARSET = utf8mb4 AUTO_INCREMENT =1;
#1115 - Unknown character ... | [
{
"answer_id": 198767,
"author": "Selorm",
"author_id": 73965,
"author_profile": "https://wordpress.stackexchange.com/users/73965",
"pm_score": -1,
"selected": false,
"text": "<p>simply open your exported database in a text editor and replace all utf8mb4 with utf8 and export after.\njust... | 2015/06/29 | [
"https://wordpress.stackexchange.com/questions/192944",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74540/"
] | When I Import Mysql from local server to web ser it is showng me error
1115 - Unknown character set: 'utf8mb4' in Creating wordpress wp\_comment table
===============================================================================
```
CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
//
//
) ENGINE = INNODB DEFAULT CHAR... | WordPress does not support MySQL 4 :
>
> To run WordPress your host just needs a couple of things:
>
>
> MySQL version **5.0** or greater (recommended: MySQL **5.5** or greater)
>
>
> <https://wordpress.org/about/requirements/>
>
>
>
While the utf8mb4 encoding is recent change and you might work around it, *o... |
192,996 | <p>I hope someone will help me:</p>
<p>I have a <strong>Custom Post Type</strong> (Movie) with its <strong>custom taxonomy</strong> (Producer), this taxonomy has its <strong>own terms</strong>, for example 'WarnerBros'.</p>
<p>How I can get all the posts of my term (WarnerBros)?</p>
<p>I have this but doesn't work y... | [
{
"answer_id": 192999,
"author": "Iftieaq",
"author_id": 35653,
"author_profile": "https://wordpress.stackexchange.com/users/35653",
"pm_score": 1,
"selected": false,
"text": "<p>Try like this</p>\n\n<pre><code>$args = array(\n 'post_type' => 'movie',\n 'tax_query' => array(\... | 2015/06/29 | [
"https://wordpress.stackexchange.com/questions/192996",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73891/"
] | I hope someone will help me:
I have a **Custom Post Type** (Movie) with its **custom taxonomy** (Producer), this taxonomy has its **own terms**, for example 'WarnerBros'.
How I can get all the posts of my term (WarnerBros)?
I have this but doesn't work yet.
```
$args = array(
'post_type' => 'movie',
'tax_que... | This question has different answers in this specific Wordpress question, they may be of help:
[Display all posts in a custom post type, grouped by a custom taxonomy](https://wordpress.stackexchange.com/questions/32902/display-all-posts-in-a-custom-post-type-grouped-by-a-custom-taxonomy)
Personally I used this method ... |
193,024 | <p>I know there is an option to have the following code in the wp-config.php file:</p>
<pre><code>define('WP_DEFAULT_THEME', 'x-child-integrity-light');
define( 'TEMPLATEPATH', 'wp-content/themes/x');
</code></pre>
<p>I currently have this commented out and I'm trying to use the WP Replicator to replicate sites in a ... | [
{
"answer_id": 193025,
"author": "Karun",
"author_id": 63470,
"author_profile": "https://wordpress.stackexchange.com/users/63470",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the <code>switch_theme</code> function</p>\n\n<pre><code><?php switch_theme( $stylesheet ) ?>... | 2015/06/30 | [
"https://wordpress.stackexchange.com/questions/193024",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13472/"
] | I know there is an option to have the following code in the wp-config.php file:
```
define('WP_DEFAULT_THEME', 'x-child-integrity-light');
define( 'TEMPLATEPATH', 'wp-content/themes/x');
```
I currently have this commented out and I'm trying to use the WP Replicator to replicate sites in a multisite install. I'd lik... | Use `switch_theme` as already indicated in another answer, but hook it to `wpmu_new_blog`
>
> This function runs when a user self-registers a new site as well as when a super admin creates a new site. hook to 'wpmu\_new\_blog' for events that should affect all new sites.
>
>
> <https://codex.wordpress.org/function_... |
193,076 | <p>i use a <a href="http://www.broobe.com/wordpress-plugins/wp-jquery-timelinr/" rel="nofollow">plugin</a> that containing this code and i want to change js location to be located in my template directory instead of plugin without editing the plugin files</p>
<pre><code>class jqueryTimelinrLoad {
public function r... | [
{
"answer_id": 193077,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>If <code>loadScripts()</code> is registered/enqueued correctly (the code posted doesn't show the hook used) ... | 2015/06/30 | [
"https://wordpress.stackexchange.com/questions/193076",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75112/"
] | i use a [plugin](http://www.broobe.com/wordpress-plugins/wp-jquery-timelinr/) that containing this code and i want to change js location to be located in my template directory instead of plugin without editing the plugin files
```
class jqueryTimelinrLoad {
public function registerScripts()
{
if (!wp... | Scripts should be enqueued on `wp_enqueue_scripts` action hook, which runs after `init` action. So dequeuing on `init` won't work because sripts are not enqueued yet. Before enqueued scripts are printed, `wp_print_scripts` action is triggered so you can dequeue or unregister scripts safely at this moment:
```
add_acti... |
193,084 | <p><a href="http://wp-cli.org/" rel="noreferrer">wp-cli</a> is great. But it's not clear how I can quickly change a user password with it.</p>
<p><a href="https://wordpress.stackexchange.com/questions/9919/how-to-change-a-users-password-programatically">How to change a user's password programatically</a> can proba... | [
{
"answer_id": 193085,
"author": "the",
"author_id": 44793,
"author_profile": "https://wordpress.stackexchange.com/users/44793",
"pm_score": 7,
"selected": true,
"text": "<p>This does the trick:</p>\n\n<pre><code>wp user update USERNAME --user_pass=\"PASSWORD\"\n</code></pre>\n\n<p>(Foun... | 2015/06/30 | [
"https://wordpress.stackexchange.com/questions/193084",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44793/"
] | [wp-cli](http://wp-cli.org/) is great. But it's not clear how I can quickly change a user password with it.
[How to change a user's password programatically](https://wordpress.stackexchange.com/questions/9919/how-to-change-a-users-password-programatically) can probably help to figure this out.
Although `wp user updat... | This does the trick:
```
wp user update USERNAME --user_pass="PASSWORD"
```
(Found it [here](https://github.com/wp-cli/wp-cli/issues/1809).) |
193,086 | <p>I am using wordpress functions in a custom php file including <code>wp-load.php</code>, run from browser it is fine, but run from command line with <code>php /path/.php</code> <code>wp-load.php</code> causes problems:</p>
<pre><code>Warning: Cannot modify header information - headers already sent in /../wp-includes... | [
{
"answer_id": 193139,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 2,
"selected": true,
"text": "<p>WordPress has a command line library called <a href=\"http://wp-cli.org/\" rel=\"nofollow\">WP-CLI</a>. You ca... | 2015/06/30 | [
"https://wordpress.stackexchange.com/questions/193086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49220/"
] | I am using wordpress functions in a custom php file including `wp-load.php`, run from browser it is fine, but run from command line with `php /path/.php` `wp-load.php` causes problems:
```
Warning: Cannot modify header information - headers already sent in /../wp-includes/ms-settings.php on line 162
```
code example... | WordPress has a command line library called [WP-CLI](http://wp-cli.org/). You can extend it to create your own commands. I would recommend this for any work on the command line. |
193,089 | <p>I am trying to change the path to my uploads directory when on this one specific page in my custom plugin. The page is a standard php page and not any specific type of post type page.</p>
<p>I have found numerous articles explaining the process, and I can see how it would work if this were a custom post type, but s... | [
{
"answer_id": 193102,
"author": "EHerman",
"author_id": 43000,
"author_profile": "https://wordpress.stackexchange.com/users/43000",
"pm_score": 3,
"selected": true,
"text": "<p>After working on this for a bit and checking the GLOBALS variable for anything useful, it looks like the refer... | 2015/06/30 | [
"https://wordpress.stackexchange.com/questions/193089",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43000/"
] | I am trying to change the path to my uploads directory when on this one specific page in my custom plugin. The page is a standard php page and not any specific type of post type page.
I have found numerous articles explaining the process, and I can see how it would work if this were a custom post type, but seeing as i... | After working on this for a bit and checking the GLOBALS variable for anything useful, it looks like the referring URL inside of the media modal is the same URL as my custom plugin page.
Using that and splitting it up a bit I was able to confirm that I am on the approrpriate page. I'm sure that there are other, more e... |
193,095 | <p>I'm looking to edit my theme layout of the <em>aside</em> post format.</p>
<p>I have already included the <code>add_theme_support()</code> function to include the aside option when creating a post. However, the layout of an <em>aside</em> does not look good. I wish to style it pretty much identically to the <em>vid... | [
{
"answer_id": 212261,
"author": "Madivad",
"author_id": 37314,
"author_profile": "https://wordpress.stackexchange.com/users/37314",
"pm_score": 1,
"selected": false,
"text": "<p>Mostly you would just make CSS changes. For example, a post that has the <code>aside</code> format will have ... | 2015/06/30 | [
"https://wordpress.stackexchange.com/questions/193095",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58657/"
] | I'm looking to edit my theme layout of the *aside* post format.
I have already included the `add_theme_support()` function to include the aside option when creating a post. However, the layout of an *aside* does not look good. I wish to style it pretty much identically to the *video* format.
Which file in my theme re... | Mostly you would just make CSS changes. For example, a post that has the `aside` format will have included in it's mark-up a class of `format-aside` which you could override in your own CSS, whether it be by way of child theme support or CSS plugin.
I've only just been playing with this today (incidentally, which is h... |
193,110 | <p>I have the following bit of code:</p>
<pre><code>$args = array(
'posts_per_page' => -1,
'category' => 7,
'orderby' => 'name',
'order' => 'ASC',
'post_type' => 'product'
);
$posts = get_posts($args);var_dump($posts);
</code></pre>
<p>This shou... | [
{
"answer_id": 193145,
"author": "Rohit Gilbile",
"author_id": 75488,
"author_profile": "https://wordpress.stackexchange.com/users/75488",
"pm_score": 3,
"selected": false,
"text": "<pre><code><ul>\n <?php\n $args = array( 'posts_per_page' => 5, 'offset'=> 1, 'catego... | 2015/06/30 | [
"https://wordpress.stackexchange.com/questions/193110",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9243/"
] | I have the following bit of code:
```
$args = array(
'posts_per_page' => -1,
'category' => 7,
'orderby' => 'name',
'order' => 'ASC',
'post_type' => 'product'
);
$posts = get_posts($args);var_dump($posts);
```
This should return one post I know that is in the ... | In all probability you are using a custom taxonomy, and not the build-in `category` taxonomy. If this is the case, then the category parameters won't work. You will need a [`tax_query`](https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters) to query posts from a specific term. (*Remember, `get_posts`... |
193,122 | <p>I read that <code>get_template_part()</code> should only used by themes not plugins, I don't know if using it inside a widget function (created by the theme) is considered as a plugin or not.</p>
<p>Anyway, I'm trying to pass that widget variables ($myvar) to the template ('loop.php' in my case), but it doesn't fet... | [
{
"answer_id": 193124,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>set_query_var('myvarname', $myvarvalue);</code> before <code>get_template_part()</code>. Th... | 2015/06/30 | [
"https://wordpress.stackexchange.com/questions/193122",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37529/"
] | I read that `get_template_part()` should only used by themes not plugins, I don't know if using it inside a widget function (created by the theme) is considered as a plugin or not.
Anyway, I'm trying to pass that widget variables ($myvar) to the template ('loop.php' in my case), but it doesn't fetch it even with using... | Indeed, `get_template_part` is meant to be used in themes only, though that would include widgets inside your theme. [Looking at the source code](https://developer.wordpress.org/reference/functions/get_template_part/) of the function you'll see that the main reason for this is that `get_template_part` does some extra t... |
193,166 | <p>I am customizing this theme . I am using <code>get_the_gallery()</code> function to get the gallery from the custom post . I am able to do so, but when the gallery is inserted between the shortcodes...</p>
<p>For eg:</p>
<pre><code>[two-third]
[gallery ids="18,17,8,7,6"]
[/two-third]
</code></pre>
<p>then i am ... | [
{
"answer_id": 193180,
"author": "Mak",
"author_id": 75502,
"author_profile": "https://wordpress.stackexchange.com/users/75502",
"pm_score": -1,
"selected": false,
"text": "<pre><code><?php\n $id=the_ID();\n $gallery_count = $wpdb->get_var(\"SELECT COUNT(ID) FROM {$wpdb->p... | 2015/07/01 | [
"https://wordpress.stackexchange.com/questions/193166",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55034/"
] | I am customizing this theme . I am using `get_the_gallery()` function to get the gallery from the custom post . I am able to do so, but when the gallery is inserted between the shortcodes...
For eg:
```
[two-third]
[gallery ids="18,17,8,7,6"]
[/two-third]
```
then i am not able to get the gallery..I am using the ... | I don't know why the code is not working.
But this is how i did this may be helpful for some noob like me
```
<?php
$name = get_the_content();
preg_match('/\[gallery ids="([^]]*)\"]/', $name, $match);
$w3_ids = explode( ",", $match[1] );
$gallery_count=1;
... |
193,182 | <p>My admin panel is very slow I've tried to debug the issue. I nailed it to the function <code>wp_remote_post</code> and an internal error message thrown by curl on this line</p>
<pre><code>return new WP_Error( 'http_request_failed', curl_error( $handle ) );
</code></pre>
<p>I wonder what would have happened if I un... | [
{
"answer_id": 193185,
"author": "Jimtrim",
"author_id": 59213,
"author_profile": "https://wordpress.stackexchange.com/users/59213",
"pm_score": 0,
"selected": false,
"text": "<p>Wordpress themselfes claim to not require anything else than: </p>\n\n<ul>\n<li>Nginx or Apace .</li>\n<li>PH... | 2015/07/01 | [
"https://wordpress.stackexchange.com/questions/193182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74519/"
] | My admin panel is very slow I've tried to debug the issue. I nailed it to the function `wp_remote_post` and an internal error message thrown by curl on this line
```
return new WP_Error( 'http_request_failed', curl_error( $handle ) );
```
I wonder what would have happened if I uninstalled curl. Can WordPress use oth... | For the record, I have uninstalled curl and wordpress was working on seamlessly.
So I confirm that curl is not a dependency of wordpress.
However, some plugins may require curl. |
193,196 | <p>In my white theme, there is no alt attribute configured for the home slider post. I added the alt text for the image through the media library interface. I added the following code to display the alt text/attribute. But it does not display:</p>
<pre><code><img class="homepage-slider_image" src="http://www.blabla... | [
{
"answer_id": 193198,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 5,
"selected": false,
"text": "<p>Your problem is that you are not providing the correct attachment's ID to <code>get_post_meta()</code> and <c... | 2015/07/01 | [
"https://wordpress.stackexchange.com/questions/193196",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17703/"
] | In my white theme, there is no alt attribute configured for the home slider post. I added the alt text for the image through the media library interface. I added the following code to display the alt text/attribute. But it does not display:
```
<img class="homepage-slider_image" src="http://www.blabla.com/wp-content/u... | Came here as this post is among the top hits on the search engine when looking for WordPress image alt and title. Being rather surprised that none of the answers seem to provide a simple solution matching the question's title I'll drop what I came up with in the end hoping it helps future readers.
```
// An attachment... |
193,205 | <p>I know this might be considered off topic but I am not sure where else to post this as it also pertains to WordPress as well as the plugin Contact Form 7. If you know where I should post this other than here please tell me.</p>
<hr>
<p>I am looking to have a conditionally required field. I have found code to work ... | [
{
"answer_id": 193198,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 5,
"selected": false,
"text": "<p>Your problem is that you are not providing the correct attachment's ID to <code>get_post_meta()</code> and <c... | 2015/07/01 | [
"https://wordpress.stackexchange.com/questions/193205",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8337/"
] | I know this might be considered off topic but I am not sure where else to post this as it also pertains to WordPress as well as the plugin Contact Form 7. If you know where I should post this other than here please tell me.
---
I am looking to have a conditionally required field. I have found code to work with but I ... | Came here as this post is among the top hits on the search engine when looking for WordPress image alt and title. Being rather surprised that none of the answers seem to provide a simple solution matching the question's title I'll drop what I came up with in the end hoping it helps future readers.
```
// An attachment... |
193,212 | <p>I have a template file that is being called via wp_ajax that returns data from a specific WooCommerce product.</p>
<p>In the "tabs" section of the template file every tab is working fine:</p>
<ul>
<li>Description - Good</li>
<li>Additional Information - Good</li>
<li>Custom Tab - Good</li>
</ul>
<p>The only tab n... | [
{
"answer_id": 193198,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 5,
"selected": false,
"text": "<p>Your problem is that you are not providing the correct attachment's ID to <code>get_post_meta()</code> and <c... | 2015/07/01 | [
"https://wordpress.stackexchange.com/questions/193212",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68087/"
] | I have a template file that is being called via wp\_ajax that returns data from a specific WooCommerce product.
In the "tabs" section of the template file every tab is working fine:
* Description - Good
* Additional Information - Good
* Custom Tab - Good
The only tab not rendering tab panel content is the reviews ta... | Came here as this post is among the top hits on the search engine when looking for WordPress image alt and title. Being rather surprised that none of the answers seem to provide a simple solution matching the question's title I'll drop what I came up with in the end hoping it helps future readers.
```
// An attachment... |
193,220 | <p>Brand new to WordPress. Using it from GoDaddy and when I try to upload my video .mov file (it's only 10MB) I get an error saying it's not a valid media type. Any ideas? Thanks.</p>
| [
{
"answer_id": 193264,
"author": "Vee",
"author_id": 44979,
"author_profile": "https://wordpress.stackexchange.com/users/44979",
"pm_score": 0,
"selected": false,
"text": "<p>Check this another stack <a href=\"https://wordpress.stackexchange.com/questions/165706/embed-mov-file-via-add-me... | 2015/07/01 | [
"https://wordpress.stackexchange.com/questions/193220",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75520/"
] | Brand new to WordPress. Using it from GoDaddy and when I try to upload my video .mov file (it's only 10MB) I get an error saying it's not a valid media type. Any ideas? Thanks. | You can use `upload_mimes` filter and add mime for .mov files (`video/quicktime`).
```
add_filter( 'upload_mimes', 'customizeMimeTypes', 10, 1 );
function customizeMimeTypes( $mimeTypes) {
$mimeTypes['mov'] = 'video/quicktime';
return $mimeTypes;
}
```
If you want to embed video with media library you can us... |
193,222 | <p>Im trying to create a topics "section" similar to what Justin Tadlock has on <a href="http://justintadlock.com/topics" rel="nofollow">his site</a> but i'm not sure <strong>how</strong> he is doing this. Categories? Tags? or what?</p>
<p>I tried changing the Category base to topics as the instructions state: </p>
<... | [
{
"answer_id": 193264,
"author": "Vee",
"author_id": 44979,
"author_profile": "https://wordpress.stackexchange.com/users/44979",
"pm_score": 0,
"selected": false,
"text": "<p>Check this another stack <a href=\"https://wordpress.stackexchange.com/questions/165706/embed-mov-file-via-add-me... | 2015/07/01 | [
"https://wordpress.stackexchange.com/questions/193222",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12116/"
] | Im trying to create a topics "section" similar to what Justin Tadlock has on [his site](http://justintadlock.com/topics) but i'm not sure **how** he is doing this. Categories? Tags? or what?
I tried changing the Category base to topics as the instructions state:
>
> If you like, you may enter custom structures for ... | You can use `upload_mimes` filter and add mime for .mov files (`video/quicktime`).
```
add_filter( 'upload_mimes', 'customizeMimeTypes', 10, 1 );
function customizeMimeTypes( $mimeTypes) {
$mimeTypes['mov'] = 'video/quicktime';
return $mimeTypes;
}
```
If you want to embed video with media library you can us... |
193,284 | <p>Is there a way to query all pages and order them by <code>menu_order</code> <strong>but</strong> ignore those pages that the default value of <code>0</code>?</p>
<p>I was trying to do something like this:</p>
<pre><code> $the_query = array(
'post_type' => self::POST_TYPE,
'posts... | [
{
"answer_id": 193291,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>You can try the following <s>(untested)</s> mini plugin:</p>\n\n<pre><code><?php\n/**\n * Plugin Name: Supp... | 2015/07/02 | [
"https://wordpress.stackexchange.com/questions/193284",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35073/"
] | Is there a way to query all pages and order them by `menu_order` **but** ignore those pages that the default value of `0`?
I was trying to do something like this:
```
$the_query = array(
'post_type' => self::POST_TYPE,
'posts_per_page' => $total,
'product_cat' => $produc... | You can try the following ~~(untested)~~ mini plugin:
```
<?php
/**
* Plugin Name: Support for ignoring the default menu order in WP_Query
* Description: Uses the _ignore_default_menu_order argument
* Plugin URI: http://wordpress.stackexchange.com/a/193291/26350
*/
add_filter( 'posts_where', function( $where, $q ... |
193,286 | <p>I just want to once and for all get some clarity on jQuery within Wordpress as I can never remember from one project to the next how things should be done.</p>
<p>The particular example I am talking about is for flexslider. On the site I am working on now I have tried:</p>
<pre><code>jQuery(document).ready(functio... | [
{
"answer_id": 193294,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>To make jQuery work in noconflict mode you need to wrap all the functions in your js-file like this:</p>\n\n<pre... | 2015/07/02 | [
"https://wordpress.stackexchange.com/questions/193286",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34820/"
] | I just want to once and for all get some clarity on jQuery within Wordpress as I can never remember from one project to the next how things should be done.
The particular example I am talking about is for flexslider. On the site I am working on now I have tried:
```
jQuery(document).ready(function($) {
$('.flexslid... | I prefer this:
```
(function($){
"use strict";
$(document).ready(function(){
$('.flexslider').flexslider({
slideshow: true,
animationSpeed: 400,
initDelay: 100,
animation: "slide",
animationLoop: true,
itemWidth: 258,
itemMargin: 26
});... |
193,325 | <p>Sorry for the basic question, every Google query I try yields no useful results.</p>
<p>How do I change the search results directory in Wordpress? Currently all searches need to be on the <code>root</code> to produce results. i.e.</p>
<p><code>www.domain.tld/?s=query</code></p>
<p>But I'd like to be able to have ... | [
{
"answer_id": 193407,
"author": "Amirmasoud",
"author_id": 58133,
"author_profile": "https://wordpress.stackexchange.com/users/58133",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this with functions.php file:</p>\n\n<pre><code>function fb_change_search_url_rewrite() {\n ... | 2015/07/02 | [
"https://wordpress.stackexchange.com/questions/193325",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51906/"
] | Sorry for the basic question, every Google query I try yields no useful results.
How do I change the search results directory in Wordpress? Currently all searches need to be on the `root` to produce results. i.e.
`www.domain.tld/?s=query`
But I'd like to be able to have two searches (which I currently already have w... | You can create a new page. Let's say you want to have:
`http://example.com/mysearch/`
Create a page that will have that URL structure.
Next, Search form -> Go to and on you search form action do:
```
<form role="filter-search" method="get" id="sd_searchform_filter" action="<?php
echo home_url( '/mysearch/' ); ?... |
193,334 | <p>I couldn't find anything on Google or on here about best practice for data that is not really Wordpress related.</p>
<p>Say we have a database of clients that we'll be accessing through PHP/SQL. Should I just create new tables within the wordpress database or is it good practice to keep these in completely separate... | [
{
"answer_id": 193407,
"author": "Amirmasoud",
"author_id": 58133,
"author_profile": "https://wordpress.stackexchange.com/users/58133",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this with functions.php file:</p>\n\n<pre><code>function fb_change_search_url_rewrite() {\n ... | 2015/07/02 | [
"https://wordpress.stackexchange.com/questions/193334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17954/"
] | I couldn't find anything on Google or on here about best practice for data that is not really Wordpress related.
Say we have a database of clients that we'll be accessing through PHP/SQL. Should I just create new tables within the wordpress database or is it good practice to keep these in completely separate databases... | You can create a new page. Let's say you want to have:
`http://example.com/mysearch/`
Create a page that will have that URL structure.
Next, Search form -> Go to and on you search form action do:
```
<form role="filter-search" method="get" id="sd_searchform_filter" action="<?php
echo home_url( '/mysearch/' ); ?... |
193,344 | <p>I'm migrating my wordpress-blog and so imported my complete content with WordPress Importer 0.6.1. (which is the latest today (July, 2th 2015). My mySQL-server version is 5.1.56-community. </p>
<p>Unfortunatley two problems appear on my new blog after import:<br>
1.) all my backslashes are gone, e.g.</p>
<pre><co... | [
{
"answer_id": 193407,
"author": "Amirmasoud",
"author_id": 58133,
"author_profile": "https://wordpress.stackexchange.com/users/58133",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this with functions.php file:</p>\n\n<pre><code>function fb_change_search_url_rewrite() {\n ... | 2015/07/02 | [
"https://wordpress.stackexchange.com/questions/193344",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75467/"
] | I'm migrating my wordpress-blog and so imported my complete content with WordPress Importer 0.6.1. (which is the latest today (July, 2th 2015). My mySQL-server version is 5.1.56-community.
Unfortunatley two problems appear on my new blog after import:
1.) all my backslashes are gone, e.g.
```
C:\Program Files -> ... | You can create a new page. Let's say you want to have:
`http://example.com/mysearch/`
Create a page that will have that URL structure.
Next, Search form -> Go to and on you search form action do:
```
<form role="filter-search" method="get" id="sd_searchform_filter" action="<?php
echo home_url( '/mysearch/' ); ?... |
193,369 | <p>How do I get the authors avatar? Buddypress plugin or any plugin.</p>
<p>I have found this inside my PHP code:</p>
<p><code>"<i class="fa fa-user"></i><span>'.get_the_author().'</span></div>';"</code></p>
<p>It shows a small image before the author's name, I wanted to change the <cod... | [
{
"answer_id": 193372,
"author": "lucian",
"author_id": 70333,
"author_profile": "https://wordpress.stackexchange.com/users/70333",
"pm_score": 3,
"selected": false,
"text": "<p>The function you're looking for is <a href=\"https://codex.wordpress.org/Function_Reference/get_avatar\" rel=\... | 2015/07/02 | [
"https://wordpress.stackexchange.com/questions/193369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | How do I get the authors avatar? Buddypress plugin or any plugin.
I have found this inside my PHP code:
`"<i class="fa fa-user"></i><span>'.get_the_author().'</span></div>';"`
It shows a small image before the author's name, I wanted to change the `fa fa-user` into author's avatar or buddypress avatar.
What will be... | The function you're looking for is [`get_avatar`](https://codex.wordpress.org/Function_Reference/get_avatar) - you should put in something like this:
```
<?php echo get_avatar( get_the_author_meta( 'ID' )); ?>
``` |
193,390 | <p>Currently im making new theme and had the idea of adding featured image in the admin side of wordpress, unfortunately its not working this is what i have tried</p>
<p>I have added this code in functions.php</p>
<pre><code>add_theme_support( 'post-thumbnails');
</code></pre>
<p>i also tried to change it </p>
<pre... | [
{
"answer_id": 193394,
"author": "shuvroMithun",
"author_id": 65928,
"author_profile": "https://wordpress.stackexchange.com/users/65928",
"pm_score": -1,
"selected": false,
"text": "<p>Your code should work , but as it is not working the try the following things </p>\n\n<pre><code>add_th... | 2015/07/03 | [
"https://wordpress.stackexchange.com/questions/193390",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75608/"
] | Currently im making new theme and had the idea of adding featured image in the admin side of wordpress, unfortunately its not working this is what i have tried
I have added this code in functions.php
```
add_theme_support( 'post-thumbnails');
```
i also tried to change it
```
add_theme_support( 'post-thumbnails',... | You have misspelled the action hook name.
This:
```
add_action( 'after-setup_theme', 'ja_theme_setup' );
```
Should be:
```
add_action( 'after_setup_theme', 'ja_theme_setup' );
```
The full code:
```
add_action( 'after_setup_theme', 'ja_theme_setup' );
function ja_theme_setup() {
add_theme_support( 'post-th... |
193,402 | <p>I've created a CPT in my WordPress site. In this CPT I have the content element (which is the default WP content) and want to make it expandable, I mean, while viewing the CPT I want it to only display a few lines of text until you press the view full content or something similar, all this inside the post view. Like... | [
{
"answer_id": 193394,
"author": "shuvroMithun",
"author_id": 65928,
"author_profile": "https://wordpress.stackexchange.com/users/65928",
"pm_score": -1,
"selected": false,
"text": "<p>Your code should work , but as it is not working the try the following things </p>\n\n<pre><code>add_th... | 2015/07/03 | [
"https://wordpress.stackexchange.com/questions/193402",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60103/"
] | I've created a CPT in my WordPress site. In this CPT I have the content element (which is the default WP content) and want to make it expandable, I mean, while viewing the CPT I want it to only display a few lines of text until you press the view full content or something similar, all this inside the post view. Like in... | You have misspelled the action hook name.
This:
```
add_action( 'after-setup_theme', 'ja_theme_setup' );
```
Should be:
```
add_action( 'after_setup_theme', 'ja_theme_setup' );
```
The full code:
```
add_action( 'after_setup_theme', 'ja_theme_setup' );
function ja_theme_setup() {
add_theme_support( 'post-th... |
193,405 | <p>I'm using <a href="https://codex.wordpress.org/Template_Tags/get_posts" rel="noreferrer"><code>get_posts()</code></a> like this:</p>
<pre><code>$posts = get_posts(array('orderby' => 'post_status'))
</code></pre>
<p>which is not possible cause it's not in the allowed keys in the <a href="https://core.trac.wordpr... | [
{
"answer_id": 193410,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>You can use <a href=\"https://developer.wordpress.org/reference/hooks/posts_orderby/\"><code>'posts_orderby'</... | 2015/07/03 | [
"https://wordpress.stackexchange.com/questions/193405",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18981/"
] | I'm using [`get_posts()`](https://codex.wordpress.org/Template_Tags/get_posts) like this:
```
$posts = get_posts(array('orderby' => 'post_status'))
```
which is not possible cause it's not in the allowed keys in the [`parse_orderby()`](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/query.php#L221... | You can use [`'posts_orderby'`](https://developer.wordpress.org/reference/hooks/posts_orderby/) filter to change the SQL performed.
Note that:
* using `get_posts()` you need to set `'suppress_filters'` argument of `false` for the filter to be performed
* if you don't explicitly set `'post_status'` you'll get only pub... |
193,436 | <p>I've got a custom post type, and I'd like to be able to change the preview link but from what I can tell, the hook for preview_post_link only affects the default post type.</p>
<p>Any guidance?</p>
<p>Here's what I've been trying.</p>
<pre><code>add_filter( 'preview_post_link', 'append_preview_query_vars' );
fun... | [
{
"answer_id": 193446,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<h2>Two problems here:</h2>\n\n<p><strong>#1</strong> </p>\n\n<p>You're missing the <code>$accepted_args</code> ... | 2015/07/03 | [
"https://wordpress.stackexchange.com/questions/193436",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14828/"
] | I've got a custom post type, and I'd like to be able to change the preview link but from what I can tell, the hook for preview\_post\_link only affects the default post type.
Any guidance?
Here's what I've been trying.
```
add_filter( 'preview_post_link', 'append_preview_query_vars' );
function append_preview_query... | Two problems here:
------------------
**#1**
You're missing the `$accepted_args` argument in:
```
add_filter( $tag, $callback_function, $priority, $accepted_args );
```
Check out the [Codex here](https://codex.wordpress.org/Function_Reference/add_filter#Parameters) for more info on that.
**#2**
Note that `$lin... |
193,467 | <p>Is it possible to redirect a user in WP without the header/wp_redirect being before header()?</p>
<p>I have a plugin that allows users to manage content they have created on the site... for example, they can delete it or disable comments</p>
<p>It's quite basic so i'm just using a GET request.. ie.</p>
<p><code>?... | [
{
"answer_id": 193598,
"author": "Goodbytes",
"author_id": 74399,
"author_profile": "https://wordpress.stackexchange.com/users/74399",
"pm_score": 2,
"selected": true,
"text": "<p>It's simply not possible, so here is the work around I come up with</p>\n\n<pre><code> public function redi... | 2015/07/03 | [
"https://wordpress.stackexchange.com/questions/193467",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74399/"
] | Is it possible to redirect a user in WP without the header/wp\_redirect being before header()?
I have a plugin that allows users to manage content they have created on the site... for example, they can delete it or disable comments
It's quite basic so i'm just using a GET request.. ie.
`?action=comments&status=disab... | It's simply not possible, so here is the work around I come up with
```
public function redirect($url = false)
{
if(headers_sent())
{
$destination = ($url == false ? 'location.reload();' : 'window.location.href="' . $url . '";');
echo die('<script>' . $destination . '</script>');
}
else... |
193,489 | <p>I want to add small javascript program in wordpress post, please let me know how to add / execute in WP Post ?</p>
<h2>EDIT</h2>
<p>Yes I tried, but no luck.</p>
<p>First I added HTML Code & JavaScript in Post Text Editor, No Luck,
Then I created Separate JS file & posted only HTML code & called js fi... | [
{
"answer_id": 193490,
"author": "Carl Willis",
"author_id": 69413,
"author_profile": "https://wordpress.stackexchange.com/users/69413",
"pm_score": 0,
"selected": false,
"text": "<p>You can add your script on header or footer normally with .\nOr you can hooked your script on function.ph... | 2015/07/04 | [
"https://wordpress.stackexchange.com/questions/193489",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75652/"
] | I want to add small javascript program in wordpress post, please let me know how to add / execute in WP Post ?
EDIT
----
Yes I tried, but no luck.
First I added HTML Code & JavaScript in Post Text Editor, No Luck,
Then I created Separate JS file & posted only HTML code & called js file using `<Script src=<Path of th... | One option would be to create a shortcode exclusively for that script. Even thought it's not an elegant solution, it works. In your functions file (functions.php) of your theme add:
```
function custom_script_shortcode(){
$code = '<script>';
$code .= 'var foo = "bar";'
$code .= '</script>';
return $cod... |
193,495 | <p>How to change the username with <a href="http://wp-cli.org" rel="noreferrer">wp-cli</a>?</p>
<p>This does not work:</p>
<pre><code>wp user update old_login --user-login=new_login
</code></pre>
| [
{
"answer_id": 193496,
"author": "the",
"author_id": 44793,
"author_profile": "https://wordpress.stackexchange.com/users/44793",
"pm_score": 3,
"selected": false,
"text": "<p><code>search-replace</code> does the trick but can have undesired side effects if <code>old_login</code> appears ... | 2015/07/04 | [
"https://wordpress.stackexchange.com/questions/193495",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44793/"
] | How to change the username with [wp-cli](http://wp-cli.org)?
This does not work:
```
wp user update old_login --user-login=new_login
``` | Not allowed by design:
----------------------
If we try to change the user login by the email:
```
wp user update mary@example.tld --user_login=mary_new
```
or by the user id:
```
wp user update 123 --user_login=mary_new
```
we get the following warning:
>
> User logins can't be changed.
>
>
>
This is the ... |
193,566 | <p>I'm struggling with this one and all of the relevant links to the codex, articles and forum posts (stack or otherwise) that I've searched haven't helped.</p>
<p>I can best describe my problem as attempting to replicate the native "Add New User" Wordpress functionality. I.e. render a form from an admin page, insert ... | [
{
"answer_id": 193496,
"author": "the",
"author_id": 44793,
"author_profile": "https://wordpress.stackexchange.com/users/44793",
"pm_score": 3,
"selected": false,
"text": "<p><code>search-replace</code> does the trick but can have undesired side effects if <code>old_login</code> appears ... | 2015/07/05 | [
"https://wordpress.stackexchange.com/questions/193566",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75694/"
] | I'm struggling with this one and all of the relevant links to the codex, articles and forum posts (stack or otherwise) that I've searched haven't helped.
I can best describe my problem as attempting to replicate the native "Add New User" Wordpress functionality. I.e. render a form from an admin page, insert a new reco... | Not allowed by design:
----------------------
If we try to change the user login by the email:
```
wp user update mary@example.tld --user_login=mary_new
```
or by the user id:
```
wp user update 123 --user_login=mary_new
```
we get the following warning:
>
> User logins can't be changed.
>
>
>
This is the ... |
193,636 | <p>I use following code to display page in a index.php file of template but doesn't show page content.</p>
<pre><code><?php
$parent_page_content = get_the_content(1677);///my_page_id
echo $parent_page_content;
?>
</code></pre>
| [
{
"answer_id": 193638,
"author": "Anand",
"author_id": 75715,
"author_profile": "https://wordpress.stackexchange.com/users/75715",
"pm_score": -1,
"selected": false,
"text": "<p>Need to modify in code : </p>\n\n<pre><code><?php\n$post_1677 = get_post(1677); \n$contents = $post_1677-&g... | 2015/07/06 | [
"https://wordpress.stackexchange.com/questions/193636",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67821/"
] | I use following code to display page in a index.php file of template but doesn't show page content.
```
<?php
$parent_page_content = get_the_content(1677);///my_page_id
echo $parent_page_content;
?>
``` | ```
get_the_content( $more_link_text, $stripteaser )
```
`get_the_content` does not take a post ID as a parameter, it always refers to the current post.
Also, don't use magic numbers or hardcode post IDs into your theme, it will break after an import/export or migration.
Instead use `get_page_by_title`, which is no... |
193,641 | <p>It doesn't seem that output buffering takes into account echo's from within hooked functions. </p>
<pre><code>function buffer_start() { ob_start(); }
function buffer_end() { ob_end_flush(); }
add_action('init', 'buffer_start');
add_action('admin_footer', 'buffer_end');
add_action("draft_to_publish", "my_hooked_fu... | [
{
"answer_id": 193646,
"author": "Dexter0015",
"author_id": 62134,
"author_profile": "https://wordpress.stackexchange.com/users/62134",
"pm_score": 0,
"selected": false,
"text": "<p>Try to simply use ob in your function like so:</p>\n\n<pre><code>add_action( 'draft_to_publish', 'my_hooke... | 2015/07/06 | [
"https://wordpress.stackexchange.com/questions/193641",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71131/"
] | It doesn't seem that output buffering takes into account echo's from within hooked functions.
```
function buffer_start() { ob_start(); }
function buffer_end() { ob_end_flush(); }
add_action('init', 'buffer_start');
add_action('admin_footer', 'buffer_end');
add_action("draft_to_publish", "my_hooked_function", 10, 1... | TL;DR: After the `draft_to_publish` hook is executed, the page is redirected, so you won't see the echoed output.
Ref: <https://wordpress.stackexchange.com/a/94011/71131>
I think the problem is that the draft\_to\_publish action saves the post, which will call a `redirect` request to the browser, which loads the edit... |
193,643 | <p>I am trying to set the title tag for Woocommerce pages that have endpoints. I am using Yoast SEO and so far have created this:</p>
<pre><code>function woocommerce_endpoint_titles( $title ) {
$sep = ' | ';
$sitetitle = get_bloginfo();
if ( is_wc_endpoint_url( 'view-order' ) ) {
$title = 'View Or... | [
{
"answer_id": 193655,
"author": "Steve-ACET",
"author_id": 66113,
"author_profile": "https://wordpress.stackexchange.com/users/66113",
"pm_score": 2,
"selected": true,
"text": "<p>It turns out I just needed to return the $title variable which already had what I needed:</p>\n\n<pre><code... | 2015/07/06 | [
"https://wordpress.stackexchange.com/questions/193643",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66113/"
] | I am trying to set the title tag for Woocommerce pages that have endpoints. I am using Yoast SEO and so far have created this:
```
function woocommerce_endpoint_titles( $title ) {
$sep = ' | ';
$sitetitle = get_bloginfo();
if ( is_wc_endpoint_url( 'view-order' ) ) {
$title = 'View Order'. $sep . $... | It turns out I just needed to return the $title variable which already had what I needed:
```
function woocommerce_endpoint_titles( $title ) {
$sep = ' | ';
$sitetitle = get_bloginfo();
if ( is_wc_endpoint_url( 'view-order' ) ) {
$title = 'View Order: ' . $sep . $sitetitle;
}
if ( is_w... |
193,683 | <p>I have added the Open Graph meta data to my <strong>functions.php</strong>:</p>
<pre><code>function insert_fb_in_head() {
global $post;
if ( !is_singular())
return;
echo '<meta property="fb:admins" content="PAGE_ID"/>';
echo '<meta property="og:title" content="' . get_the_title() . ... | [
{
"answer_id": 193655,
"author": "Steve-ACET",
"author_id": 66113,
"author_profile": "https://wordpress.stackexchange.com/users/66113",
"pm_score": 2,
"selected": true,
"text": "<p>It turns out I just needed to return the $title variable which already had what I needed:</p>\n\n<pre><code... | 2015/07/06 | [
"https://wordpress.stackexchange.com/questions/193683",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75598/"
] | I have added the Open Graph meta data to my **functions.php**:
```
function insert_fb_in_head() {
global $post;
if ( !is_singular())
return;
echo '<meta property="fb:admins" content="PAGE_ID"/>';
echo '<meta property="og:title" content="' . get_the_title() . '"/>';
echo '<meta property=... | It turns out I just needed to return the $title variable which already had what I needed:
```
function woocommerce_endpoint_titles( $title ) {
$sep = ' | ';
$sitetitle = get_bloginfo();
if ( is_wc_endpoint_url( 'view-order' ) ) {
$title = 'View Order: ' . $sep . $sitetitle;
}
if ( is_w... |
193,695 | <p>I use the add_menu_page function in my custom theme builds but when I export my local copy of the site and import it in the production site some of post id numbers change and I have to update this function manually (ie: in the code below: <strong><em>?post=8, ?post=8, ?post=10</em></strong>). Is there a way to have ... | [
{
"answer_id": 193655,
"author": "Steve-ACET",
"author_id": 66113,
"author_profile": "https://wordpress.stackexchange.com/users/66113",
"pm_score": 2,
"selected": true,
"text": "<p>It turns out I just needed to return the $title variable which already had what I needed:</p>\n\n<pre><code... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193695",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40679/"
] | I use the add\_menu\_page function in my custom theme builds but when I export my local copy of the site and import it in the production site some of post id numbers change and I have to update this function manually (ie: in the code below: ***?post=8, ?post=8, ?post=10***). Is there a way to have these numbers be dyna... | It turns out I just needed to return the $title variable which already had what I needed:
```
function woocommerce_endpoint_titles( $title ) {
$sep = ' | ';
$sitetitle = get_bloginfo();
if ( is_wc_endpoint_url( 'view-order' ) ) {
$title = 'View Order: ' . $sep . $sitetitle;
}
if ( is_w... |
193,696 | <p>First off, this has nothing to do with permissions, I already checked that. So please don't mark this as a duplicate.</p>
<p>Any time I try to update a plugin, I get this dialog:</p>
<p><img src="https://i.stack.imgur.com/ZDa03.png" alt="enter image description here"></p>
<p>I went overboard and allowed all permi... | [
{
"answer_id": 193655,
"author": "Steve-ACET",
"author_id": 66113,
"author_profile": "https://wordpress.stackexchange.com/users/66113",
"pm_score": 2,
"selected": true,
"text": "<p>It turns out I just needed to return the $title variable which already had what I needed:</p>\n\n<pre><code... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193696",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32201/"
] | First off, this has nothing to do with permissions, I already checked that. So please don't mark this as a duplicate.
Any time I try to update a plugin, I get this dialog:

I went overboard and allowed all permissions (-rw-rw-rw-) on all files, and ... | It turns out I just needed to return the $title variable which already had what I needed:
```
function woocommerce_endpoint_titles( $title ) {
$sep = ' | ';
$sitetitle = get_bloginfo();
if ( is_wc_endpoint_url( 'view-order' ) ) {
$title = 'View Order: ' . $sep . $sitetitle;
}
if ( is_w... |
193,707 | <p>I'm trying to generate a table for a custom post type events, in which I have a few custom fields, one of these is the date. I want to display the posts in the table and order them by the Date value. This is my code:</p>
<p><strong>Date format</strong>: 07/07/2015 (DAY/MONTH/YEAR)</p>
<p>Right now, the loop isn't ... | [
{
"answer_id": 193655,
"author": "Steve-ACET",
"author_id": 66113,
"author_profile": "https://wordpress.stackexchange.com/users/66113",
"pm_score": 2,
"selected": true,
"text": "<p>It turns out I just needed to return the $title variable which already had what I needed:</p>\n\n<pre><code... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193707",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60103/"
] | I'm trying to generate a table for a custom post type events, in which I have a few custom fields, one of these is the date. I want to display the posts in the table and order them by the Date value. This is my code:
**Date format**: 07/07/2015 (DAY/MONTH/YEAR)
Right now, the loop isn't working and I don't know how t... | It turns out I just needed to return the $title variable which already had what I needed:
```
function woocommerce_endpoint_titles( $title ) {
$sep = ' | ';
$sitetitle = get_bloginfo();
if ( is_wc_endpoint_url( 'view-order' ) ) {
$title = 'View Order: ' . $sep . $sitetitle;
}
if ( is_w... |
193,709 | <pre><code>wp_register_script('moment', plugin_dir_url( __FILE__ )."js/moment.min.js", false, null, true);
wp_register_script('fullcalendar', plugin_dir_url( __FILE__ )."js/fullcalendar.min.js", false, null, true);
wp_enqueue_script('moment');
wp_enqueue_script('fullcalendar');
wp_regist... | [
{
"answer_id": 193655,
"author": "Steve-ACET",
"author_id": 66113,
"author_profile": "https://wordpress.stackexchange.com/users/66113",
"pm_score": 2,
"selected": true,
"text": "<p>It turns out I just needed to return the $title variable which already had what I needed:</p>\n\n<pre><code... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75764/"
] | ```
wp_register_script('moment', plugin_dir_url( __FILE__ )."js/moment.min.js", false, null, true);
wp_register_script('fullcalendar', plugin_dir_url( __FILE__ )."js/fullcalendar.min.js", false, null, true);
wp_enqueue_script('moment');
wp_enqueue_script('fullcalendar');
wp_register_styl... | It turns out I just needed to return the $title variable which already had what I needed:
```
function woocommerce_endpoint_titles( $title ) {
$sep = ' | ';
$sitetitle = get_bloginfo();
if ( is_wc_endpoint_url( 'view-order' ) ) {
$title = 'View Order: ' . $sep . $sitetitle;
}
if ( is_w... |
193,719 | <p>For some reason, <a href="http://tedxkarachi.pk/" rel="nofollow">my client's website</a> is blank. After some debugging, I realized that all of the colors have been changed to #FFF. What would be the best way to recover the site?</p>
<p>Method #1
I install the theme again.</p>
<p>Method #2
I upload the css file ag... | [
{
"answer_id": 193655,
"author": "Steve-ACET",
"author_id": 66113,
"author_profile": "https://wordpress.stackexchange.com/users/66113",
"pm_score": 2,
"selected": true,
"text": "<p>It turns out I just needed to return the $title variable which already had what I needed:</p>\n\n<pre><code... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | For some reason, [my client's website](http://tedxkarachi.pk/) is blank. After some debugging, I realized that all of the colors have been changed to #FFF. What would be the best way to recover the site?
Method #1
I install the theme again.
Method #2
I upload the css file again
Please guide me. | It turns out I just needed to return the $title variable which already had what I needed:
```
function woocommerce_endpoint_titles( $title ) {
$sep = ' | ';
$sitetitle = get_bloginfo();
if ( is_wc_endpoint_url( 'view-order' ) ) {
$title = 'View Order: ' . $sep . $sitetitle;
}
if ( is_w... |
193,721 | <p>I'm trying to hidden or remove the price on each variable products inside dropdown menu on a single product page. Please see image attached below.</p>
<p><a href="https://imgur.com/IlNkEyZ" rel="nofollow noreferrer"><img src="https://i.imgur.com/IlNkEyZ.png" title="source: imgur.com" /></a></p>
<p>I believe here i... | [
{
"answer_id": 193729,
"author": "Vee",
"author_id": 44979,
"author_profile": "https://wordpress.stackexchange.com/users/44979",
"pm_score": 1,
"selected": false,
"text": "<p>By using hook</p>\n\n<pre><code>remove_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193721",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm trying to hidden or remove the price on each variable products inside dropdown menu on a single product page. Please see image attached below.
[](https://imgur.com/IlNkEyZ)
I believe here is the codes that needs to be edited. Any help is appreciated. Thanks ... | By using hook
```
remove_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop_price',10);
```
or CSS
```
span.price
{
display: none !important;
}
```
\*Tag May be different as per your theme.
Thanks, Vee |
193,737 | <p>I am attempting to display the latest x posts from all categories using a custom taxonomy called 'case-studies' in WordPress.</p>
<p>I have managed to output all the category names as heading links I have also outputted some posts from the standard posts taxonomy which are in the correct categories, but I can't get... | [
{
"answer_id": 193729,
"author": "Vee",
"author_id": 44979,
"author_profile": "https://wordpress.stackexchange.com/users/44979",
"pm_score": 1,
"selected": false,
"text": "<p>By using hook</p>\n\n<pre><code>remove_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193737",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75779/"
] | I am attempting to display the latest x posts from all categories using a custom taxonomy called 'case-studies' in WordPress.
I have managed to output all the category names as heading links I have also outputted some posts from the standard posts taxonomy which are in the correct categories, but I can't get this to d... | By using hook
```
remove_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop_price',10);
```
or CSS
```
span.price
{
display: none !important;
}
```
\*Tag May be different as per your theme.
Thanks, Vee |
193,743 | <p>I have a parent theme that creates a number of custom meta boxes that are added to the "post" and "pages" post types as well as a number of post types also created by the theme.</p>
<p>In my child theme, I have created some new custom post types, so I would like to add a function somewhere in my child theme to add ... | [
{
"answer_id": 193757,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>This depends on how your parent theme hooks in the meta_boxes. If the callbacks are hooked to <code>add_meta... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193743",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63580/"
] | I have a parent theme that creates a number of custom meta boxes that are added to the "post" and "pages" post types as well as a number of post types also created by the theme.
In my child theme, I have created some new custom post types, so I would like to add a function somewhere in my child theme to add these pre-... | This depends on how your parent theme hooks in the meta\_boxes. If the callbacks are hooked to `add_meta_boxes` and written similar to the following from the Codex:
```
function myplugin_add_meta_box() {
$screens = array( 'post', 'page' );
foreach ( $screens as $screen ) {
add_meta_box(
... |
193,751 | <p>I develop a plugin that searches for a duplicates of WooCommerce products in a very specific way. It works great in our test environment, but on the client's original setup it does not execute. It just reloads the page as if nothing happened. The most obvious difference between our setup and the original website is ... | [
{
"answer_id": 193753,
"author": "Hari Om Gupta",
"author_id": 68792,
"author_profile": "https://wordpress.stackexchange.com/users/68792",
"pm_score": 0,
"selected": false,
"text": "<p>Yeah I think it works with limited no of items, I have also find similar issue with <strong>wp_query</s... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57654/"
] | I develop a plugin that searches for a duplicates of WooCommerce products in a very specific way. It works great in our test environment, but on the client's original setup it does not execute. It just reloads the page as if nothing happened. The most obvious difference between our setup and the original website is the... | >
> I think the query we run is maybe limited in some way...
>
>
>
So far as I know, your query and the processing you do of the results is going to be limited by server resources-- memory, etc-- not by WordPress other than the [WordPress defined PHP memory limit](https://codex.wordpress.org/Editing_wp-config.php#... |
193,755 | <p>In WordPress 4.2 it included a nice feature which labeled what page was the Front-Page and which page was the Blog ( Latest Posts ). Unfortunately, it also removes the default editor on the page assigned to show the latest posts and instead shows this message:</p>
<blockquote>
<p>You are currently editing the pag... | [
{
"answer_id": 193756,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 5,
"selected": true,
"text": "<p>In WordPress 4.2 the editor was removed on whichever page was assigned to show Latest Posts for whatever rea... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193755",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | In WordPress 4.2 it included a nice feature which labeled what page was the Front-Page and which page was the Blog ( Latest Posts ). Unfortunately, it also removes the default editor on the page assigned to show the latest posts and instead shows this message:
>
> You are currently editing the page that shows your la... | In WordPress 4.2 the editor was removed on whichever page was assigned to show Latest Posts for whatever reason. The following function below
( [original solution found here](https://wordpress.org/support/topic/you-are-currently-editing-the-page-that-shows-your-latest-posts) by [crgeary](https://wordpress.org/support/p... |
193,766 | <p>The challenge is the following:
How to set the output price converted in local currency in frontend site shop? We need to have base price in USD in admin area, but on the site shop we need to use local currency without possibility to select any other currencies, just strictly show prices converted in local currency.... | [
{
"answer_id": 194337,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": -1,
"selected": false,
"text": "<p>There are many plugin provide these kind of functionality. You need to research for the same some plugin whic... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193766",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75792/"
] | The challenge is the following:
How to set the output price converted in local currency in frontend site shop? We need to have base price in USD in admin area, but on the site shop we need to use local currency without possibility to select any other currencies, just strictly show prices converted in local currency.
I... | I've just ran into your question, and of course it was almost a year, so, I'm not sure if you've solved the issue. I'll put an answer here in case you still didn't (which I doubt), and for other people may be searching for an answer.
My suggestion is to go with JQuery on the Front End to replace the price and the curre... |
193,776 | <p>I'm using html5 support for input formats and custom comment form fields with this code:</p>
<pre><code><?php
$commenter = wp_get_current_commenter();
$args = wp_parse_args( $args );
if ( ! isset( $args['format'] ) )
$args['format'] = current_theme_supports( 'html5', 'comment... | [
{
"answer_id": 203482,
"author": "pdme",
"author_id": 35726,
"author_profile": "https://wordpress.stackexchange.com/users/35726",
"pm_score": 2,
"selected": false,
"text": "<p>It seems WP core adds the novlidate attribute to the comment form when your theme has HTML5 support enabled for ... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193776",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71254/"
] | I'm using html5 support for input formats and custom comment form fields with this code:
```
<?php
$commenter = wp_get_current_commenter();
$args = wp_parse_args( $args );
if ( ! isset( $args['format'] ) )
$args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5... | It seems WP core adds the novlidate attribute to the comment form when your theme has HTML5 support enabled for comment forms (see includes/comment-template.php).
To disable it, use
```
remove_theme_support('html5', 'comment-form');
``` |
193,791 | <p>I know I can use REGEXP in WP_Query like this:</p>
<pre><code>$query = new WP_Query(array(
'posts_per_page' => -1,
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'custom_fields',
'value' => 'foo[(][0-9][)]', // with regex stuff
'co... | [
{
"answer_id": 193841,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>Here's one experimental idea:</p>\n\n<p>Assume we got: </p>\n\n<blockquote>\n <p>post <strong>A</strong> with... | 2015/07/07 | [
"https://wordpress.stackexchange.com/questions/193791",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21207/"
] | I know I can use REGEXP in WP\_Query like this:
```
$query = new WP_Query(array(
'posts_per_page' => -1,
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'custom_fields',
'value' => 'foo[(][0-9][)]', // with regex stuff
'compare' => 'REGEXP',
),
... | Here's one experimental idea:
Assume we got:
>
> post **A** with the custom field `location1` as *UK - London*
>
>
> post **B** with the custom field `location2` as *France - Paris*
>
>
> post **C** with the custom field `location3` as *USA - New York*
>
>
>
Then we could use, for example:
```
$args = [
... |
193,825 | <p>I have recently finished developing my latest WordPress theme for my own site and as usual I was going to use maxcdn and w3tc to make it faster!</p>
<p>However my Hosting company have started up their own cdn service and I have got 3 months free to test it out! However it is not as easy to set up as Maxcdn and have... | [
{
"answer_id": 193834,
"author": "Phillip Dews",
"author_id": 75827,
"author_profile": "https://wordpress.stackexchange.com/users/75827",
"pm_score": 1,
"selected": false,
"text": "<p>I Finally figure it out!</p>\n\n<p>By selecting the General settings under W3TC I selected CDN and CDN T... | 2015/07/08 | [
"https://wordpress.stackexchange.com/questions/193825",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75827/"
] | I have recently finished developing my latest WordPress theme for my own site and as usual I was going to use maxcdn and w3tc to make it faster!
However my Hosting company have started up their own cdn service and I have got 3 months free to test it out! However it is not as easy to set up as Maxcdn and have been told... | To dinamically change the stylesheet and template URI you can use `stylesheet_uri` filter and `template_directory_uri` filter.
For example:
```
add_filter( 'stylesheet_uri', function( $stylesheet_uri ) {
$stylesheet_uri = 'your new stylesheet URI here';
return $stylesheet_uri;
} );
```
But, as you are us... |
193,828 | <p>I have a piece of JS code that I use show/hide customizer control groups depending on a select item value.</p>
<p>The code was working fine until recent wp update (not sure which version first broke this). </p>
<p>Here is the code for enqueuing the js file.</p>
<pre><code>add_action('customize_controls_print_scri... | [
{
"answer_id": 195031,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>Seems like a timing problem to me, maybe/probably I'm oversimplifying this, but what about making u... | 2015/07/08 | [
"https://wordpress.stackexchange.com/questions/193828",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3094/"
] | I have a piece of JS code that I use show/hide customizer control groups depending on a select item value.
The code was working fine until recent wp update (not sure which version first broke this).
Here is the code for enqueuing the js file.
```
add_action('customize_controls_print_scripts', 'ppl_customize_control... | So, far the problem was with the initial loading of the JS file. As i couldn't find any solution using the JS. The problem was not about the script loading rather then the execution timing.
Anyways, The theme customizer looks into the global variable for which Panel/Section/Control it will show as active when it load... |
193,845 | <p>I am looking for a way to edit the link that get inserted in the editor when the user choose to add a media. The goal would be to add a class with the media type (pdf) in the link.</p>
<p>I know how to get the mime type but I am not sure which hook to use to retrieve the link before it gets inserted. Could you poin... | [
{
"answer_id": 193847,
"author": "terminator",
"author_id": 55034,
"author_profile": "https://wordpress.stackexchange.com/users/55034",
"pm_score": 1,
"selected": false,
"text": "<p><strong>This is not the answer but just the hint.</strong></p>\n\n<p><code>media_send_to_editor</code> \ns... | 2015/07/08 | [
"https://wordpress.stackexchange.com/questions/193845",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54879/"
] | I am looking for a way to edit the link that get inserted in the editor when the user choose to add a media. The goal would be to add a class with the media type (pdf) in the link.
I know how to get the mime type but I am not sure which hook to use to retrieve the link before it gets inserted. Could you point me in th... | So thanks to @amritanshu and @wycks [github's code](https://gist.github.com/wycks/2176359), here is the solution for those in need to add a class with the media type to the attachment url before it gets inserted in the editor :
```
if ( ! function_exists( 'epc_add_class_pdf' ) ) :
function epc_add_class_pdf( $htm... |
193,850 | <p>Original question: <a href="https://wordpress.stackexchange.com/questions/14881/seperating-custom-post-search-results">Seperating Custom Post Search Results</a></p>
<p>I've tried to implement this code to my website, but i have some problem with it.
What i've changed is i've added another switch for third post type... | [
{
"answer_id": 193884,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>Here is an idea, sort your your loop before it executes. Your current issue is just this. You will see t... | 2015/07/08 | [
"https://wordpress.stackexchange.com/questions/193850",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55153/"
] | Original question: [Seperating Custom Post Search Results](https://wordpress.stackexchange.com/questions/14881/seperating-custom-post-search-results)
I've tried to implement this code to my website, but i have some problem with it.
What i've changed is i've added another switch for third post type, as follows:
```
<?... | Here is an idea, sort your your loop before it executes. Your current issue is just this. You will see that the type of sorting (*if I'm correct where I believe your order is not alphabetical according to post type*) is not possible natively, so we need a work-around (*even if you just need post types sorted alphabetic... |
193,851 | <p>This is my code </p>
<pre><code><?php
global $wpdb;
$rows = $wpdb->get_results("SELECT `submit_time` AS 'Submitted', max( if( `field_name` = 'Salutation', `field_value` , NULL ) ) AS 'Salutation', max( if( `field_name` = 'First Name', `field_value` , NULL ) ) AS 'First Name', max( if( `field_name` = 'Last Nam... | [
{
"answer_id": 193884,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>Here is an idea, sort your your loop before it executes. Your current issue is just this. You will see t... | 2015/07/08 | [
"https://wordpress.stackexchange.com/questions/193851",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75547/"
] | This is my code
```
<?php
global $wpdb;
$rows = $wpdb->get_results("SELECT `submit_time` AS 'Submitted', max( if( `field_name` = 'Salutation', `field_value` , NULL ) ) AS 'Salutation', max( if( `field_name` = 'First Name', `field_value` , NULL ) ) AS 'First Name', max( if( `field_name` = 'Last Name', `field_value` , ... | Here is an idea, sort your your loop before it executes. Your current issue is just this. You will see that the type of sorting (*if I'm correct where I believe your order is not alphabetical according to post type*) is not possible natively, so we need a work-around (*even if you just need post types sorted alphabetic... |
193,852 | <p>I've made a function to hook after the_content. This is only working on certain pages/posts. It's working on the default template but not on my custom one's.</p>
<pre><code>function insertFootNote($content) {
$content.= "<div>";
$content.="additional content";
$content.= "</div>";
return $co... | [
{
"answer_id": 193855,
"author": "M-R",
"author_id": 17061,
"author_profile": "https://wordpress.stackexchange.com/users/17061",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"https://codex.wordpress.org/Function_Reference/get_the_content\" rel=\"nofollow\">get_the_content</a> do... | 2015/07/08 | [
"https://wordpress.stackexchange.com/questions/193852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31706/"
] | I've made a function to hook after the\_content. This is only working on certain pages/posts. It's working on the default template but not on my custom one's.
```
function insertFootNote($content) {
$content.= "<div>";
$content.="additional content";
$content.= "</div>";
return $content;
}
add_filter ('th... | [get\_the\_content](https://codex.wordpress.org/Function_Reference/get_the_content) do not apply the\_content filter. You have to apply it after receiving contents like following
```
<?php apply_filters('the_content',get_the_content( $more_link_text, $stripteaser, $more_file )) ?>
```
It is also detailed at the bott... |
193,880 | <p>how do you get the author's username?
I'm using this code
"get_the_author()"
I wanted to change this into author's username, instead of author's name.</p>
<p>Thankyou</p>
| [
{
"answer_id": 193925,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>In the Loop, it would be:</p>\n\n<pre><code>$authorname = get_the_author_meta('user_nicename');\n</code></pr... | 2015/07/08 | [
"https://wordpress.stackexchange.com/questions/193880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75855/"
] | how do you get the author's username?
I'm using this code
"get\_the\_author()"
I wanted to change this into author's username, instead of author's name.
Thankyou | In the Loop, it would be:
```
$authorname = get_the_author_meta('user_nicename');
```
Or:
```
$authorname = get_the_author_meta('displayname');
```
Or:
```
$authorname = get_the_author_meta('nickname');
```
Or any field that [`get_the_author_meta()`](https://codex.wordpress.org/Function_Reference/get_the_autho... |
193,894 | <p>I don't know what I'm doing wrong here. I created a page with accordians, the jquery script loads just fine but when I link the CSS stylesheet, no CSS shows up. It is not an external stylesheet, I posted the CSS in the same stylesheet used for all pages which is styles.css</p>
<p>The page </p>
<p><a href="http://... | [
{
"answer_id": 193896,
"author": "jpburn",
"author_id": 75868,
"author_profile": "https://wordpress.stackexchange.com/users/75868",
"pm_score": -1,
"selected": false,
"text": "<p>Please try this instead. Replace your css by : <code><link rel=\"stylesheet\" type=\"text/css\" href=\"<... | 2015/07/08 | [
"https://wordpress.stackexchange.com/questions/193894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74889/"
] | I don't know what I'm doing wrong here. I created a page with accordians, the jquery script loads just fine but when I link the CSS stylesheet, no CSS shows up. It is not an external stylesheet, I posted the CSS in the same stylesheet used for all pages which is styles.css
The page
<http://scarincihollenbeck.com/law... | Add the CSS to your child themes style.css file or load it using wp\_enqueue\_scripts
```
add_action( 'wp_enqueue_scripts', 'wpsites_load_custom_styles' );
function wpsites_load_custom_styles() {
wp_register_style( 'custom-css', get_stylesheet_directory_uri() . '/your-style.css', false, '1.0.0' );
wp_enqueue_... |
193,904 | <p>My company is working on a project that will have to display Events based on a the Office they are located in and the Event Leader associated with that Office. </p>
<p>What we need is to build a system that allows Events, Offices and Event Leaders to be custom post types with an inheritance between them. </p>
<p>T... | [
{
"answer_id": 193896,
"author": "jpburn",
"author_id": 75868,
"author_profile": "https://wordpress.stackexchange.com/users/75868",
"pm_score": -1,
"selected": false,
"text": "<p>Please try this instead. Replace your css by : <code><link rel=\"stylesheet\" type=\"text/css\" href=\"<... | 2015/07/08 | [
"https://wordpress.stackexchange.com/questions/193904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75869/"
] | My company is working on a project that will have to display Events based on a the Office they are located in and the Event Leader associated with that Office.
What we need is to build a system that allows Events, Offices and Event Leaders to be custom post types with an inheritance between them.
To display them, I... | Add the CSS to your child themes style.css file or load it using wp\_enqueue\_scripts
```
add_action( 'wp_enqueue_scripts', 'wpsites_load_custom_styles' );
function wpsites_load_custom_styles() {
wp_register_style( 'custom-css', get_stylesheet_directory_uri() . '/your-style.css', false, '1.0.0' );
wp_enqueue_... |
193,907 | <p>I am trying to modify the head and foot of my WooCommerce pages. I have an <code>if</code> statement that is supposed to target the shop and cart of WooCommerce, but it isn't. If I modify the PHP after the <code>if</code> statement nothing changes. But if I modify the PHP in the <code>else</code> statement is works:... | [
{
"answer_id": 193908,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 6,
"selected": true,
"text": "<p>Your edit got me to this idea, there indeed is no function called »woocommerce«, there is a class »<... | 2015/07/08 | [
"https://wordpress.stackexchange.com/questions/193907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62370/"
] | I am trying to modify the head and foot of my WooCommerce pages. I have an `if` statement that is supposed to target the shop and cart of WooCommerce, but it isn't. If I modify the PHP after the `if` statement nothing changes. But if I modify the PHP in the `else` statement is works:
This doesn't work:
```
<?php if (... | Your edit got me to this idea, there indeed is no function called »woocommerce«, there is a class »`WooCommerce`« though. One thing to be aware of is, that the check has to late enough, so that plug-ins are actually initialized, otherwise - obviously - the class won't exists and the check returns `false`. So your check... |
193,930 | <p>I'm using <strong>WordPress 4.2.2</strong> and the "Contact Form 7" plugin <strong>version 4.2.1</strong>. But when my contact form shortcode outputs the html code the <code>name=""</code> attribute is blank and W3C html validator is giving me errors because of this. How can I fix this?</p>
| [
{
"answer_id": 193932,
"author": "Shiv Singh",
"author_id": 50897,
"author_profile": "https://wordpress.stackexchange.com/users/50897",
"pm_score": 0,
"selected": false,
"text": "<p>i think you have some mistake on form creation</p>\n\n<p>it should be like</p>\n\n<pre><code>[text* text-1... | 2015/07/09 | [
"https://wordpress.stackexchange.com/questions/193930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56854/"
] | I'm using **WordPress 4.2.2** and the "Contact Form 7" plugin **version 4.2.1**. But when my contact form shortcode outputs the html code the `name=""` attribute is blank and W3C html validator is giving me errors because of this. How can I fix this? | **UPDATE:** This has been fixed in [Contact Form 7 - v4.2.2](http://contactform7.com/2015/07/30/contact-form-7-422/)
The issue is that whenever Contact Form 7 generates the form shortcode it doesn't create a name attribute and it doesn't seem to fallback to using the title attribute of the shortcode. HTML 5 doesn't li... |
193,991 | <p>I am new to ACF , so far I managed to add a new custom field and did this</p>
<p><img src="https://i.stack.imgur.com/di01x.png" alt="enter image description here"></p>
<p><img src="https://i.stack.imgur.com/yuAJc.png" alt="enter image description here"></p>
<p>Visitor can enter application no. and password to get... | [
{
"answer_id": 193952,
"author": "Shuvo Habib",
"author_id": 64429,
"author_profile": "https://wordpress.stackexchange.com/users/64429",
"pm_score": 0,
"selected": false,
"text": "<p>One of the easiest way you need to do is install and activate the <a href=\"http://wordpress.org/plugins/... | 2015/07/09 | [
"https://wordpress.stackexchange.com/questions/193991",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48184/"
] | I am new to ACF , so far I managed to add a new custom field and did this


Visitor can enter application no. and password to get its application statuses which admin has added.
I ... | this are the steps you need to care when you setup wordpress locally from server.
1. Download wordpress folder and database.(keep back up)
2. setup db and change on wp\_option table for "home\_url" and "site\_url".
3. change permalink and and reset .htaccess.
4. change on custom menu link which you have added
5. resta... |
194,010 | <p>I am doing a <code>WP_Query</code> trying to filter out the posts by Metadata. </p>
<pre><code> $args = array(
'ignore_sticky_posts'=> 1,
'post_type' => 'post_projects',
'post_status' => 'publish',
'posts_per_page' => $nr_posts,
'meta_query' => array(
'relatio... | [
{
"answer_id": 193952,
"author": "Shuvo Habib",
"author_id": 64429,
"author_profile": "https://wordpress.stackexchange.com/users/64429",
"pm_score": 0,
"selected": false,
"text": "<p>One of the easiest way you need to do is install and activate the <a href=\"http://wordpress.org/plugins/... | 2015/07/09 | [
"https://wordpress.stackexchange.com/questions/194010",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73346/"
] | I am doing a `WP_Query` trying to filter out the posts by Metadata.
```
$args = array(
'ignore_sticky_posts'=> 1,
'post_type' => 'post_projects',
'post_status' => 'publish',
'posts_per_page' => $nr_posts,
'meta_query' => array(
'relation' => 'OR',
array(
'ke... | this are the steps you need to care when you setup wordpress locally from server.
1. Download wordpress folder and database.(keep back up)
2. setup db and change on wp\_option table for "home\_url" and "site\_url".
3. change permalink and and reset .htaccess.
4. change on custom menu link which you have added
5. resta... |
194,024 | <p>I'm trying to list out all the child pages of a custom page I've made.</p>
<p>In my custom page, I'm doing this to list out the pages:</p>
<pre><code><?php get_header(); ?>
<?php
$subpages = new WP_Query( array(
'post_type' => 'page',
'post_parent' => $post->ID,
'posts_per_page' =&g... | [
{
"answer_id": 194025,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 2,
"selected": true,
"text": "<p>I tested the query and it does work so the only thing I can spot that is misleading but not right is directl... | 2015/07/09 | [
"https://wordpress.stackexchange.com/questions/194024",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43933/"
] | I'm trying to list out all the child pages of a custom page I've made.
In my custom page, I'm doing this to list out the pages:
```
<?php get_header(); ?>
<?php
$subpages = new WP_Query( array(
'post_type' => 'page',
'post_parent' => $post->ID,
'posts_per_page' => -1,
'orderby' => 'menu_order'
));
... | I tested the query and it does work so the only thing I can spot that is misleading but not right is directly after you `while()` statement you have `the_post()`. This doesn't work in secondary queries, it should look like:
```
<?php if( $subpages->have_posts() ) : ?>
<?php while( $subpages->have_posts() ) : $sub... |
194,028 | <p>I am trying to run some custom jquery function every time the colorpicker's color change. The colorpicker is include as part of the WP core. I have been looking at the JS code, but I can't figure out what's the trigger that updates the color.</p>
<p>I have tried listening for several classes, and also listening for... | [
{
"answer_id": 194034,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 3,
"selected": false,
"text": "<p>I hate answering my own question, but hopefully this can help someone else with similar issues:</p>\n\n<p>Wor... | 2015/07/09 | [
"https://wordpress.stackexchange.com/questions/194028",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30984/"
] | I am trying to run some custom jquery function every time the colorpicker's color change. The colorpicker is include as part of the WP core. I have been looking at the JS code, but I can't figure out what's the trigger that updates the color.
I have tried listening for several classes, and also listening for changes o... | I hate answering my own question, but hopefully this can help someone else with similar issues:
Wordpress uses Iris color picker.
<http://automattic.github.io/Iris/#>
Wordpress also creates a jquery widget with default settings for Iris.
The file can be found under wp-admin/js/color-picker.js
At first I was trying t... |
194,064 | <p>I'm using Godaddy Hosting, PHP 5, and Wordpress 4.2.1</p>
<p>I have 34,000 + posts that need outdated href tags removed. I am able to remove tags, one post at a time, by using this code in a page template and changing the post_id manually. Thank you @ialocin for the wp-kses addition. The wp_postmeta table has 347,... | [
{
"answer_id": 194073,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": false,
"text": "<p>Firstly, I would consider using one of WordPress' <a href=\"http://codex.wordpress.org/Data_Validat... | 2015/07/10 | [
"https://wordpress.stackexchange.com/questions/194064",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75960/"
] | I'm using Godaddy Hosting, PHP 5, and Wordpress 4.2.1
I have 34,000 + posts that need outdated href tags removed. I am able to remove tags, one post at a time, by using this code in a page template and changing the post\_id manually. Thank you @ialocin for the wp-kses addition. The wp\_postmeta table has 347,602 rows ... | Finally, I was able to iterate through all 34,788 entries, but only by running the job in smaller batches based on the post date. Here is the final code that I used on a page template. Thank you @ialocin for setting me on the right path. The job is done, but there has to be a better, more automatic, way to iterate thro... |
194,090 | <p>After the <a href="http://docs.woothemes.com/document/importing-woocommerce-dummy-data/" rel="noreferrer">Woocommerce dummy products</a> are imported, I notice that in the database, there are different records in different tables but point to THE SAME photo attachment.</p>
<p>The question is why? What are the diffe... | [
{
"answer_id": 194092,
"author": "Vee",
"author_id": 44979,
"author_profile": "https://wordpress.stackexchange.com/users/44979",
"pm_score": 1,
"selected": false,
"text": "<p>First is showing the attachment file path, second is file attributes size, type, height, width etc.</p>\n\n<p>Th... | 2015/07/10 | [
"https://wordpress.stackexchange.com/questions/194090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/992/"
] | After the [Woocommerce dummy products](http://docs.woothemes.com/document/importing-woocommerce-dummy-data/) are imported, I notice that in the database, there are different records in different tables but point to THE SAME photo attachment.
The question is why? What are the differences between those records? Is that ... | An attachment *is* a Post
=========================
The posts table contains information on the attachment *post*.
In WordPress every uploaded media has it's own post entry, where `post_type` is `'attachment'` and `post_status` is `'inherit'`.
In fact, you can get attachment post types using functions used to get ot... |
194,134 | <p>I don't know when or why but this tags are inserted on my wordpress head automatically and they are adding style that disturb my layout:</p>
<pre><code><meta name="generator" content="WordPress 4.2.2">
<style type="text/css" media="screen">
html { margin-top: ... | [
{
"answer_id": 194092,
"author": "Vee",
"author_id": 44979,
"author_profile": "https://wordpress.stackexchange.com/users/44979",
"pm_score": 1,
"selected": false,
"text": "<p>First is showing the attachment file path, second is file attributes size, type, height, width etc.</p>\n\n<p>Th... | 2015/07/10 | [
"https://wordpress.stackexchange.com/questions/194134",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75995/"
] | I don't know when or why but this tags are inserted on my wordpress head automatically and they are adding style that disturb my layout:
```
<meta name="generator" content="WordPress 4.2.2">
<style type="text/css" media="screen">
html { margin-top: 32px !important; }
* html body { margin-top: 32px !important;... | An attachment *is* a Post
=========================
The posts table contains information on the attachment *post*.
In WordPress every uploaded media has it's own post entry, where `post_type` is `'attachment'` and `post_status` is `'inherit'`.
In fact, you can get attachment post types using functions used to get ot... |
194,146 | <p>My WordPress site displays featured images at the top of each post. Here's the PHP code from <code>post.php</code> that generates the featured image.</p>
<pre><code><?php if ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'link_to... | [
{
"answer_id": 194092,
"author": "Vee",
"author_id": 44979,
"author_profile": "https://wordpress.stackexchange.com/users/44979",
"pm_score": 1,
"selected": false,
"text": "<p>First is showing the attachment file path, second is file attributes size, type, height, width etc.</p>\n\n<p>Th... | 2015/07/10 | [
"https://wordpress.stackexchange.com/questions/194146",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76000/"
] | My WordPress site displays featured images at the top of each post. Here's the PHP code from `post.php` that generates the featured image.
```
<?php if ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'link_to_post' => false, 'image_class' => ... | An attachment *is* a Post
=========================
The posts table contains information on the attachment *post*.
In WordPress every uploaded media has it's own post entry, where `post_type` is `'attachment'` and `post_status` is `'inherit'`.
In fact, you can get attachment post types using functions used to get ot... |
194,156 | <p>I have script to show list tags from category and works very well. </p>
<pre><code><ul class="inline-list">
<?php
query_posts('category_name=lain-lain');
if (have_posts()) : while (have_posts()) : the_post();
if( get_the_tag_list() ){
... | [
{
"answer_id": 194092,
"author": "Vee",
"author_id": 44979,
"author_profile": "https://wordpress.stackexchange.com/users/44979",
"pm_score": 1,
"selected": false,
"text": "<p>First is showing the attachment file path, second is file attributes size, type, height, width etc.</p>\n\n<p>Th... | 2015/07/11 | [
"https://wordpress.stackexchange.com/questions/194156",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45645/"
] | I have script to show list tags from category and works very well.
```
<ul class="inline-list">
<?php
query_posts('category_name=lain-lain');
if (have_posts()) : while (have_posts()) : the_post();
if( get_the_tag_list() ){
echo $p... | An attachment *is* a Post
=========================
The posts table contains information on the attachment *post*.
In WordPress every uploaded media has it's own post entry, where `post_type` is `'attachment'` and `post_status` is `'inherit'`.
In fact, you can get attachment post types using functions used to get ot... |
194,171 | <p>I'm creating one wordpress template. Required information added in wordpress header.php, footer.php and everything was fine. Then i added one page. But while viewing the page there was a small problem just above the footer. After checking i found following code creating all the problems</p>
<pre><code><br class=... | [
{
"answer_id": 194197,
"author": "emilushi",
"author_id": 63983,
"author_profile": "https://wordpress.stackexchange.com/users/63983",
"pm_score": -1,
"selected": false,
"text": "<p>at your theme functions add this line: <code>remove_filter('the_content', 'wpautop');</code></p>\n"
},
... | 2015/07/11 | [
"https://wordpress.stackexchange.com/questions/194171",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75994/"
] | I'm creating one wordpress template. Required information added in wordpress header.php, footer.php and everything was fine. Then i added one page. But while viewing the page there was a small problem just above the footer. After checking i found following code creating all the problems
```
<br class="clear">
```
Bu... | I afraid that added by some custom function or JavaScript because WordPress never add that tag by default. So use CSS to hide that element if you don't find that script |
194,203 | <p>I am using the following code in functions.php of the child theme to include a file</p>
<pre><code>require_once(get_stylesheet_directory_uri().'/functions/taxonomy-images.php');
</code></pre>
<p>But i get these warnings and fatal error</p>
<pre><code>Warning: require_once(): http:// wrapper is disabled in the ser... | [
{
"answer_id": 194206,
"author": "kanenas",
"author_id": 45047,
"author_profile": "https://wordpress.stackexchange.com/users/45047",
"pm_score": 2,
"selected": false,
"text": "<pre><code>get_stylesheet_directory_uri()\n</code></pre>\n\n<p>Note that this returns a properly-formed URI; in ... | 2015/07/11 | [
"https://wordpress.stackexchange.com/questions/194203",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55034/"
] | I am using the following code in functions.php of the child theme to include a file
```
require_once(get_stylesheet_directory_uri().'/functions/taxonomy-images.php');
```
But i get these warnings and fatal error
```
Warning: require_once(): http:// wrapper is disabled in the server configuration by allow_url_includ... | ```
get_stylesheet_directory_uri()
```
Note that this returns a properly-formed URI; in other words, it will be a web-address (starting with http:// or https:// for SSL). As such, it is most appropriately used for links, referencing additional stylesheets, or probably most commonly, images.
```
get_stylesheet_direct... |
194,204 | <p>I have a news system with a thumbnail and a box on it that show the category related to the news, using <code><?php the_category(', '); ?></code>
This worked fine using only one category for each news, but since I downloaded SEO by Yoast, I added a breadcrumb at the top of my page.php and single.php and did a ... | [
{
"answer_id": 194206,
"author": "kanenas",
"author_id": 45047,
"author_profile": "https://wordpress.stackexchange.com/users/45047",
"pm_score": 2,
"selected": false,
"text": "<pre><code>get_stylesheet_directory_uri()\n</code></pre>\n\n<p>Note that this returns a properly-formed URI; in ... | 2015/07/11 | [
"https://wordpress.stackexchange.com/questions/194204",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76033/"
] | I have a news system with a thumbnail and a box on it that show the category related to the news, using `<?php the_category(', '); ?>`
This worked fine using only one category for each news, but since I downloaded SEO by Yoast, I added a breadcrumb at the top of my page.php and single.php and did a hierarchy for my new... | ```
get_stylesheet_directory_uri()
```
Note that this returns a properly-formed URI; in other words, it will be a web-address (starting with http:// or https:// for SSL). As such, it is most appropriately used for links, referencing additional stylesheets, or probably most commonly, images.
```
get_stylesheet_direct... |
194,267 | <p>I am making by wonderful page and I want to query a given custom post type called accommodations and display the number of posts in that given location and this what I have e.g (1,110) Accommodation in Newyork</p>
<pre><code><?php
$args = array(
'post_type' => 'accommodations',
'taxonomy' => 'location',
'f... | [
{
"answer_id": 194269,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 1,
"selected": false,
"text": "<p>Your query is completely wrong. You should use a proper <code>tax_query</code>. Also note, your query i... | 2015/07/12 | [
"https://wordpress.stackexchange.com/questions/194267",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76073/"
] | I am making by wonderful page and I want to query a given custom post type called accommodations and display the number of posts in that given location and this what I have e.g (1,110) Accommodation in Newyork
```
<?php
$args = array(
'post_type' => 'accommodations',
'taxonomy' => 'location',
'field' => 'NewYork'
);
$... | Your query is completely wrong. You should use a proper `tax_query`. Also note, your query is quite expensive to run to just count posts. Set the `fields` paremeter to only return post ID's. This saves up to 99.9% on resources.
Just a note, the field parameter inside a `tax_query` is important. The valid values are `s... |
194,273 | <p>I have created a WP plugin which uses the query string to pull in page data based on what the visitor has selected. Obviously this 'simulates' additional pages but the page title does not change from the title set in WP Admin.</p>
<p>I have been trying to hook into <code>wp_title</code> to change the title tag on f... | [
{
"answer_id": 194284,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>I believe you can alter that with a filter on <code>wp_title</code> but you don't provide enough detail abou... | 2015/07/12 | [
"https://wordpress.stackexchange.com/questions/194273",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74399/"
] | I have created a WP plugin which uses the query string to pull in page data based on what the visitor has selected. Obviously this 'simulates' additional pages but the page title does not change from the title set in WP Admin.
I have been trying to hook into `wp_title` to change the title tag on fly but can't get this... | As of WP 4.4, wp\_title is deprecated. If you simply need to override your title tag, pre\_get\_document\_title is the filter you want to use.
```
add_filter( 'pre_get_document_title', 'generate_custom_title', 10 );
```
and the function would look something like this
```
function generate_custom_title($title) {
/* ... |
194,289 | <p>How to view orders for a specific product in WooCommerce using sku or product name?
What I have so far is that, but it does not work..
Does anyone know how to do?</p>
<pre><code><?php
$args = array(
'post_type' =>'shop_order',
'post_status' => 'publish',
'posts_per_page' => 50,
... | [
{
"answer_id": 194657,
"author": "Ericc Antunes",
"author_id": 76267,
"author_profile": "https://wordpress.stackexchange.com/users/76267",
"pm_score": -1,
"selected": false,
"text": "<p>Feito!</p>\n\n<p>Realmente com o WP_Query não dá... pra saber essa informação é necessário utilizar 2 ... | 2015/07/13 | [
"https://wordpress.stackexchange.com/questions/194289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76088/"
] | How to view orders for a specific product in WooCommerce using sku or product name?
What I have so far is that, but it does not work..
Does anyone know how to do?
```
<?php
$args = array(
'post_type' =>'shop_order',
'post_status' => 'publish',
'posts_per_page' => 50,
'order' => 'D... | Eric based on your code I wrote to meet my needs, for those who want to follow:
Eric com base em seu código eu escrevi o para atender as minhas necessidades, para quem quiser segue abaixo:
```
<?php
global $wpdb;
$produto_id = 22777; // ID do produto
$consulta = "SELECT order_id FROM {$wpdb->prefix}woocommerce_ord... |
194,291 | <p>I've setup a brand new CentOS 7 VPS; everything configured by me. LAMP installation and the Apache virtual host configurations are all done. I've checked them before installing Wordpress and the HTML sites were being showed as well as the PHP info and everything else.</p>
<p>After that I went on to setup Wordpress ... | [
{
"answer_id": 194302,
"author": "Nick",
"author_id": 65003,
"author_profile": "https://wordpress.stackexchange.com/users/65003",
"pm_score": 3,
"selected": true,
"text": "<p>Add this in your .htaccess file at website root folder.\nIf you deleted it then create it again and paste this.</... | 2015/07/13 | [
"https://wordpress.stackexchange.com/questions/194291",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76091/"
] | I've setup a brand new CentOS 7 VPS; everything configured by me. LAMP installation and the Apache virtual host configurations are all done. I've checked them before installing Wordpress and the HTML sites were being showed as well as the PHP info and everything else.
After that I went on to setup Wordpress as usual. ... | Add this in your .htaccess file at website root folder.
If you deleted it then create it again and paste this.
```
DirectoryIndex index.html index.php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILE... |
194,309 | <p>I know it sounds like a Basic Question and I did google first. Google lead me to edit /wp-admin/edit-form-advanced.php to put target='_blank' there. I did that, but this doesn't seem to affect the 'view page' button on the top of the edit page site.
I want it to open in a new tab every time.</p>
<p>In what file/whe... | [
{
"answer_id": 194302,
"author": "Nick",
"author_id": 65003,
"author_profile": "https://wordpress.stackexchange.com/users/65003",
"pm_score": 3,
"selected": true,
"text": "<p>Add this in your .htaccess file at website root folder.\nIf you deleted it then create it again and paste this.</... | 2015/07/13 | [
"https://wordpress.stackexchange.com/questions/194309",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76102/"
] | I know it sounds like a Basic Question and I did google first. Google lead me to edit /wp-admin/edit-form-advanced.php to put target='\_blank' there. I did that, but this doesn't seem to affect the 'view page' button on the top of the edit page site.
I want it to open in a new tab every time.
In what file/where can I ... | Add this in your .htaccess file at website root folder.
If you deleted it then create it again and paste this.
```
DirectoryIndex index.html index.php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILE... |