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 |
|---|---|---|---|---|---|---|
273,844 | <p>How do I add a custom post type to what I'm assuming is a table in WP's underlying database.</p>
<p>I.e. I don't want to have this loading on every page and I want to be able to use slug and post-type queries on it.</p>
<pre><code>function cptui_register_my_cpts_app() {
$labels = array();
$args = array();... | [
{
"answer_id": 273828,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 0,
"selected": false,
"text": "<p>Your function <code>get_instance</code> will never create an instance of the class because of ... | 2017/07/19 | [
"https://wordpress.stackexchange.com/questions/273844",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124145/"
] | How do I add a custom post type to what I'm assuming is a table in WP's underlying database.
I.e. I don't want to have this loading on every page and I want to be able to use slug and post-type queries on it.
```
function cptui_register_my_cpts_app() {
$labels = array();
$args = array();
register_post_ty... | You are just doing it wrong. The problem starts with using a singleton, just never do it.
You have a class of loggers which logs into some internal buffer. All loggers log into the same buffer, therefor the buffer (`trace` in your case) a static array in the class.
No more `get_intance`, just instantiate a new logger ... |
273,870 | <p>I have develop a wordpress website consulting and I have different user role </p>
<p>and I want to have different content according to user role </p>
<p>so I have a landing page with authentification and according the user role login , the homepage is different </p>
<p>so I would like to say if plugin who make so... | [
{
"answer_id": 273872,
"author": "danbrellis",
"author_id": 34540,
"author_profile": "https://wordpress.stackexchange.com/users/34540",
"pm_score": 1,
"selected": false,
"text": "<p>Two options come to mind. Which one will depend on how different your content is for logged in/not logged ... | 2017/07/19 | [
"https://wordpress.stackexchange.com/questions/273870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124159/"
] | I have develop a wordpress website consulting and I have different user role
and I want to have different content according to user role
so I have a landing page with authentification and according the user role login , the homepage is different
so I would like to say if plugin who make something like this exist ... | To use a different page's content on the homepage based on a logged-in user's role you can do this:
In your functions.php file add this code:
```
function wpse_273872_pre_get_posts( $query ) {
if ( $query->is_main_query() && is_user_logged_in() ) {
//work-around for using is_front_page() in pre_get_posts
//... |
273,878 | <p>I created some code to return attachment categories, that looks like:</p>
<pre><code><?php
// Attachment Categories
$categories = get_the_category($attachment->ID);
if ($categories) {
?>
<ul>
<?php foreach ($categories as $category) { ?>
<?php if ($categor... | [
{
"answer_id": 273872,
"author": "danbrellis",
"author_id": 34540,
"author_profile": "https://wordpress.stackexchange.com/users/34540",
"pm_score": 1,
"selected": false,
"text": "<p>Two options come to mind. Which one will depend on how different your content is for logged in/not logged ... | 2017/07/19 | [
"https://wordpress.stackexchange.com/questions/273878",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9820/"
] | I created some code to return attachment categories, that looks like:
```
<?php
// Attachment Categories
$categories = get_the_category($attachment->ID);
if ($categories) {
?>
<ul>
<?php foreach ($categories as $category) { ?>
<?php if ($category->name !== 'Slides') if ($category->n... | To use a different page's content on the homepage based on a logged-in user's role you can do this:
In your functions.php file add this code:
```
function wpse_273872_pre_get_posts( $query ) {
if ( $query->is_main_query() && is_user_logged_in() ) {
//work-around for using is_front_page() in pre_get_posts
//... |
273,907 | <p>I would like to write a little script that does a check whenever an order is created in WooCommerce (right after checkout) and then conditionally changes the Shipping Address of the customer.</p>
<p>I think I need a filter hook that 'fires' as soon as an order is created. I tried several things in the <a href="http... | [
{
"answer_id": 309707,
"author": "Madebymartin",
"author_id": 31520,
"author_profile": "https://wordpress.stackexchange.com/users/31520",
"pm_score": 4,
"selected": true,
"text": "<p>Stumbled on this looking for the same thing which I've now figured out (Woocommerce 3.x)...</p>\n\n<pre><... | 2017/07/19 | [
"https://wordpress.stackexchange.com/questions/273907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86827/"
] | I would like to write a little script that does a check whenever an order is created in WooCommerce (right after checkout) and then conditionally changes the Shipping Address of the customer.
I think I need a filter hook that 'fires' as soon as an order is created. I tried several things in the [WooCommerce Hook refer... | Stumbled on this looking for the same thing which I've now figured out (Woocommerce 3.x)...
```
add_filter( 'woocommerce_checkout_create_order', 'mbm_alter_shipping', 10, 1 );
function mbm_alter_shipping ($order) {
if ($something == $condition) {
$address = array(
'first_name' => 'Martin',
'last_nam... |
273,910 | <p>I have followed the solution given <a href="https://wordpress.stackexchange.com/questions/58932/how-do-i-remove-a-pre-existing-customizer-setting">here</a> by Krupal Patel.</p>
<pre><code>add_action( "customize_register", "ruth_sherman_theme_customize_register" );
function ruth_sherman_theme_customize_register( $w... | [
{
"answer_id": 273921,
"author": "Weston Ruter",
"author_id": 8521,
"author_profile": "https://wordpress.stackexchange.com/users/8521",
"pm_score": 2,
"selected": false,
"text": "<p>The first thing to try is to increase the priority of your <code>customize_register</code> action from the... | 2017/07/19 | [
"https://wordpress.stackexchange.com/questions/273910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4612/"
] | I have followed the solution given [here](https://wordpress.stackexchange.com/questions/58932/how-do-i-remove-a-pre-existing-customizer-setting) by Krupal Patel.
```
add_action( "customize_register", "ruth_sherman_theme_customize_register" );
function ruth_sherman_theme_customize_register( $wp_customize ) {
//=====... | The first thing to try is to increase the priority of your `customize_register` action from the default of `10` to something like `100`. The reason for this is other components add their sections and controls in the same action and some after `10`, so the things you are trying to remove may simply not have been added y... |
273,920 | <p>I am trying to make one specific page on my wordpress installation to have a different text on the "Upload" button.</p>
<p>So i tried:</p>
<pre><code>function change_settingspage_publish_button( $translation, $text ) {
if ( '567' == get_the_ID() && $text == 'Publish' ) {
return 'Save Settings... | [
{
"answer_id": 273929,
"author": "Nuno Sarmento",
"author_id": 75461,
"author_profile": "https://wordpress.stackexchange.com/users/75461",
"pm_score": 0,
"selected": false,
"text": "<p>You can tried this code below, it works for me.</p>\n\n<pre><code>function change_publish_button( $tran... | 2017/07/19 | [
"https://wordpress.stackexchange.com/questions/273920",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124115/"
] | I am trying to make one specific page on my wordpress installation to have a different text on the "Upload" button.
So i tried:
```
function change_settingspage_publish_button( $translation, $text ) {
if ( '567' == get_the_ID() && $text == 'Publish' ) {
return 'Save Settings';
} else {
ret... | I wanted to change the Publish button's text in the Block Editor and came across this question. With the answers given it wasn't changing the text. With the Gutenberg update, I realized it would have to be done with JavaScript. I found this response: [Changing text within the Block Editor](https://wordpress.stackexchan... |
273,941 | <p>Trying to create a template that places a custom post UI image between the navigation bar and the title like this:</p>
<p><a href="https://i.stack.imgur.com/ZuIYa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZuIYa.png" alt="Intended outcome"></a></p>
<p>However, I am unable to override the he... | [
{
"answer_id": 273929,
"author": "Nuno Sarmento",
"author_id": 75461,
"author_profile": "https://wordpress.stackexchange.com/users/75461",
"pm_score": 0,
"selected": false,
"text": "<p>You can tried this code below, it works for me.</p>\n\n<pre><code>function change_publish_button( $tran... | 2017/07/19 | [
"https://wordpress.stackexchange.com/questions/273941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124196/"
] | Trying to create a template that places a custom post UI image between the navigation bar and the title like this:
[](https://i.stack.imgur.com/ZuIYa.png)
However, I am unable to override the header-extensions.php in my child folder to the parent
The page is di... | I wanted to change the Publish button's text in the Block Editor and came across this question. With the answers given it wasn't changing the text. With the Gutenberg update, I realized it would have to be done with JavaScript. I found this response: [Changing text within the Block Editor](https://wordpress.stackexchan... |
273,958 | <p>I'm working on a site that uses two different pages to filter lists of posts associated with the same custom post type ("media"), and both pages have their own templates-- a more general page named <code>page-media.php</code> and one that's more narrowly focused via taxonomy, <code>page-music-library.php</code>. Whi... | [
{
"answer_id": 273929,
"author": "Nuno Sarmento",
"author_id": 75461,
"author_profile": "https://wordpress.stackexchange.com/users/75461",
"pm_score": 0,
"selected": false,
"text": "<p>You can tried this code below, it works for me.</p>\n\n<pre><code>function change_publish_button( $tran... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/273958",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89753/"
] | I'm working on a site that uses two different pages to filter lists of posts associated with the same custom post type ("media"), and both pages have their own templates-- a more general page named `page-media.php` and one that's more narrowly focused via taxonomy, `page-music-library.php`. While both of these pages fi... | I wanted to change the Publish button's text in the Block Editor and came across this question. With the answers given it wasn't changing the text. With the Gutenberg update, I realized it would have to be done with JavaScript. I found this response: [Changing text within the Block Editor](https://wordpress.stackexchan... |
273,977 | <p>I'm new to wordpress, and I want to edit the <strong>homepage</strong> of a theme. I just could not find out which file should I be editing with. I've tried to remove <em>page.php</em>, <em>index.php</em>, <em>single.php</em> under /wp-content/themes/mytheme, but my site is still working after I removed all these fi... | [
{
"answer_id": 273929,
"author": "Nuno Sarmento",
"author_id": 75461,
"author_profile": "https://wordpress.stackexchange.com/users/75461",
"pm_score": 0,
"selected": false,
"text": "<p>You can tried this code below, it works for me.</p>\n\n<pre><code>function change_publish_button( $tran... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/273977",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113712/"
] | I'm new to wordpress, and I want to edit the **homepage** of a theme. I just could not find out which file should I be editing with. I've tried to remove *page.php*, *index.php*, *single.php* under /wp-content/themes/mytheme, but my site is still working after I removed all these files, so which file is the theme actua... | I wanted to change the Publish button's text in the Block Editor and came across this question. With the answers given it wasn't changing the text. With the Gutenberg update, I realized it would have to be done with JavaScript. I found this response: [Changing text within the Block Editor](https://wordpress.stackexchan... |
273,986 | <p>I'm having a tough time including jquery-ui scripts and styles in my plugin. It seems that my <code>wp_enqueue_script</code> calls are simply ignored.</p>
<p>There are already many questions similar to this one, but all answers I've found so far boil down to call <code>wp_enqueue_script</code> inside the <code>wp_e... | [
{
"answer_id": 273993,
"author": "umesh.nevase",
"author_id": 9279,
"author_profile": "https://wordpress.stackexchange.com/users/9279",
"pm_score": 1,
"selected": false,
"text": "<p>I've modified your script. try with this, it is working.</p>\n\n<pre><code>add_action( 'wp_enqueue_scripts... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/273986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84622/"
] | I'm having a tough time including jquery-ui scripts and styles in my plugin. It seems that my `wp_enqueue_script` calls are simply ignored.
There are already many questions similar to this one, but all answers I've found so far boil down to call `wp_enqueue_script` inside the `wp_enqueue_scripts` action hook, which I'... | First of all, WordPress registers jQuery UI via [`wp_default_scripts()`](https://stackoverflow.com/questions/8849684/wordpress-jquery-ui-css-files). Dependencies are already set, so you only need to enqueue the script you really need (and not the core). Since you're not changing version number or anything, it is ok to ... |
274,016 | <p>I would like to add content to the end of <a href="https://www.horizonhomes-samui.com/contact/" rel="nofollow noreferrer">this page</a> (below the form), immediately before the footer. Can I do this with a custom function, via a hook? Adding the content to the WordPress editor does not insert it at the bottom of t... | [
{
"answer_id": 274024,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<p>Unless that template that you don't want to edit has a <code>do_action()</code> function where you want ... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/274016",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51204/"
] | I would like to add content to the end of [this page](https://www.horizonhomes-samui.com/contact/) (below the form), immediately before the footer. Can I do this with a custom function, via a hook? Adding the content to the WordPress editor does not insert it at the bottom of the page as desired.
I've tried two differ... | Unless that template that you don't want to edit has a `do_action()` function where you want to add the content, then no, you can't. |
274,017 | <p>I'm a WordPress beginner and I'm working on a travel directory that user can register and have a front end control panel and have a front end submission form where user can add property description and of course images . </p>
<p>I have a multi site installation but upload settings do not work for front end(max up... | [
{
"answer_id": 274019,
"author": "Cesar Henrique Damascena",
"author_id": 109804,
"author_profile": "https://wordpress.stackexchange.com/users/109804",
"pm_score": 0,
"selected": false,
"text": "<p>You have some ways to do that:</p>\n\n<p>In your <strong>functions.php</strong> or <strong... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/274017",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123557/"
] | I'm a WordPress beginner and I'm working on a travel directory that user can register and have a front end control panel and have a front end submission form where user can add property description and of course images .
I have a multi site installation but upload settings do not work for front end(max upload file si... | You have some ways to do that:
In your **functions.php** or **wp-config.php**
```
@ini_set( 'upload_max_size' , '15M' );
@ini_set( 'post_max_size', '15M');
@ini_set( 'max_execution_time', '300' );
```
In your **.htaccess** (if you use apache2)
```
php_value upload_max_filesize 15M
php_value post_max_size 15M
php_v... |
274,034 | <p>I have setup a small website using LAMP (Raspbian) and Wordpress.<br>
No domain name will be registered for the website.<br>
For the moment I am accessing the site from inside the local network.<br>
To access the site I just hit the IP address of the server (internal).<br>
I want to access the site from outside the ... | [
{
"answer_id": 274066,
"author": "user42826",
"author_id": 42826,
"author_profile": "https://wordpress.stackexchange.com/users/42826",
"pm_score": 2,
"selected": true,
"text": "<p>When installing WP onto an IP address (or hostname), WP will only respond to requests on that IP address. A... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/274034",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63180/"
] | I have setup a small website using LAMP (Raspbian) and Wordpress.
No domain name will be registered for the website.
For the moment I am accessing the site from inside the local network.
To access the site I just hit the IP address of the server (internal).
I want to access the site from outside the local n... | When installing WP onto an IP address (or hostname), WP will only respond to requests on that IP address. Any request from another IP address even if it resolves to the same server, will result in a redirect to a WP error page.
In this situation, I would do this:
1. Install WP on the public IP address. This will work... |
274,038 | <p>I am using <em>pre_get_posts hook</em> in order to filter posts by custom terms. All working fine, but if i want to filter posts by 2 custom terms, the query only filters by the last term given. See my code below. I hook this into <em>pre_get_posts</em> but when both if statements are TRUE, only the last $query->set... | [
{
"answer_id": 274040,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this, you just need to get the original value of the tax query, add the additional query, th... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/274038",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124244/"
] | I am using *pre\_get\_posts hook* in order to filter posts by custom terms. All working fine, but if i want to filter posts by 2 custom terms, the query only filters by the last term given. See my code below. I hook this into *pre\_get\_posts* but when both if statements are TRUE, only the last $query->set is done, mea... | Think of this pseudo code
```
if sky == blue
set a = 5
if grass == green
set a = 7
```
What value will `a` have? Not 12.
This is the exact same situation. You are setting a specific parameter to a specific value. In the second call, you are overwriting your previous value. To avoid this, you can build the value... |
274,039 | <p>I have mt theme folder in my computer, where I did all the updates. Now I want to upload the new version of my theme with the changes I did. My question here: Do I just upload the theme folder via FTP and overwrite the existing one? Will this damage or change my posts or it will just update the theme design? I did t... | [
{
"answer_id": 274040,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this, you just need to get the original value of the tax query, add the additional query, th... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/274039",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114684/"
] | I have mt theme folder in my computer, where I did all the updates. Now I want to upload the new version of my theme with the changes I did. My question here: Do I just upload the theme folder via FTP and overwrite the existing one? Will this damage or change my posts or it will just update the theme design? I did this... | Think of this pseudo code
```
if sky == blue
set a = 5
if grass == green
set a = 7
```
What value will `a` have? Not 12.
This is the exact same situation. You are setting a specific parameter to a specific value. In the second call, you are overwriting your previous value. To avoid this, you can build the value... |
274,042 | <p>i want to display a div on every single page, but not on the frontpage. For that i used the following code in the functions.php</p>
<pre><code> if (! is_front_page()) :
'<div class="button-kontakt"> <a href="/kontakt"><p>ANFRAGE</p></a></div>';
endif;
</code></pre>
<p>But ... | [
{
"answer_id": 274045,
"author": "James",
"author_id": 122472,
"author_profile": "https://wordpress.stackexchange.com/users/122472",
"pm_score": 2,
"selected": true,
"text": "<p>You need to tell the PHP to echo the div. </p>\n\n<p><code>if (! is_front_page()) : \n echo '<div class=\... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/274042",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82174/"
] | i want to display a div on every single page, but not on the frontpage. For that i used the following code in the functions.php
```
if (! is_front_page()) :
'<div class="button-kontakt"> <a href="/kontakt"><p>ANFRAGE</p></a></div>';
endif;
```
But my code is not working? The div is not shown. Somebody could h... | You need to tell the PHP to echo the div.
`if (! is_front_page()) :
echo '<div class="button-kontakt"> <a href="/kontakt"><p>ANFRAGE</p></a></div>';
endif;`
Unless you just want it on the top of the page, you need to add that code to a template file, not the functions file. If it is something that appears at the ... |
274,049 | <p>I'm using gulp & browserSync for server in WP development: </p>
<pre><code>gulp.task('browser-sync', function () {
browserSync.init({
proxy: projectURL
});
});
</code></pre>
<p>WordPress runs on <code>localhost:3000/mysite</code></p>
<p>There is also a watch task that detects changes in php an... | [
{
"answer_id": 290771,
"author": "tpaksu",
"author_id": 14452,
"author_profile": "https://wordpress.stackexchange.com/users/14452",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe it may be late, but I recently have found a solution with a filter:</p>\n\n<pre><code>function theme_set... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/274049",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121208/"
] | I'm using gulp & browserSync for server in WP development:
```
gulp.task('browser-sync', function () {
browserSync.init({
proxy: projectURL
});
});
```
WordPress runs on `localhost:3000/mysite`
There is also a watch task that detects changes in php and reloads browser.
For some reason though WP cu... | Found a work around by adding ' localhost:3000' to the 'Content-Security-Policy' header:
```
function edit_customizer_headers () {
function edit_csp_header ($headers) {
$headers['Content-Security-Policy'] .= ' localhost:3000';
return $headers;
}
add_filter('wp_headers', 'edit_csp_header');
}
add_action('... |
274,056 | <p><a href="https://i.stack.imgur.com/a91zO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a91zO.jpg" alt="SearchResultsPage"></a></p>
<p>I have designed and developed a responsive Wordpress site that is almost ready for launch for a client who is an actor and producer. I have been stuck on my requ... | [
{
"answer_id": 274065,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>Use str_replace to replace all occurances of the word to highlight with a around the word. Something ... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/274056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124257/"
] | [](https://i.stack.imgur.com/a91zO.jpg)
I have designed and developed a responsive Wordpress site that is almost ready for launch for a client who is an actor and producer. I have been stuck on my requirements for the search results page for three days.
My EXCE... | This will helpful for you...
Use this code at function.php
```
function wps_highlight_results($text){
if(is_search()){
$sr = get_query_var('s');
$keys = explode(" ",$sr);
$text = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt">'.$sr.'</strong>', $text)... |
274,097 | <p>Right now my domain <code>www.example.com</code> is setup to force HTTPS and it works. The site also correctly links everything to HTTPS. (there are no occurences of HTTP in the database anywhere).</p>
<p>But if you are visiting a subpage, you can change the url to HTTP again, for example <code>http://example.com/s... | [
{
"answer_id": 274098,
"author": "Junaid",
"author_id": 66571,
"author_profile": "https://wordpress.stackexchange.com/users/66571",
"pm_score": 0,
"selected": false,
"text": "<p>Try this <code>htaccess</code> rule</p>\n\n<pre><code>RewriteCond %{HTTPS} !=on\nRewriteRule ^ https://%{HTTP_... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/274097",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124277/"
] | Right now my domain `www.example.com` is setup to force HTTPS and it works. The site also correctly links everything to HTTPS. (there are no occurences of HTTP in the database anywhere).
But if you are visiting a subpage, you can change the url to HTTP again, for example `http://example.com/subpage/` and it will not e... | To globally redirect all your pages to HTTPS add the following lines to your `.htaccess`:
```
# Globally force SSL.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
```
This should be placed directly after `RewriteEngine on` if you ... |
274,103 | <p>I'm wondering how I could change the menu in the twenty twelve theme to show the submenu items on click rather than hover?</p>
| [
{
"answer_id": 274106,
"author": "Cedon",
"author_id": 80069,
"author_profile": "https://wordpress.stackexchange.com/users/80069",
"pm_score": -1,
"selected": false,
"text": "<p>You add a <code>:focus</code> pseudoclass to the same rule as <code>:hover</code>.</p>\n\n<pre><code>a:hover {... | 2017/07/20 | [
"https://wordpress.stackexchange.com/questions/274103",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121004/"
] | I'm wondering how I could change the menu in the twenty twelve theme to show the submenu items on click rather than hover? | Menus can be slightly confusing since there's often JS and CSS interacting with different things.
Looking at the twentytwelve theme, a quick method of achieving this would be to remove the CSS that is adding :hover display of the submenus.
In [style.css you would see .main-navigation ul li:hover > ul, on line 1,567](... |
274,116 | <p>Due to the setup of my template (and layout), I need to be able to place 4 different posts in 4 different divs.</p>
<p>For example, my structure would be like this</p>
<pre><code><div>Post 1</div>
<div>
<div>Post 2</div>
<div>
<div>Post 3</div>
... | [
{
"answer_id": 274119,
"author": "While1",
"author_id": 111798,
"author_profile": "https://wordpress.stackexchange.com/users/111798",
"pm_score": 2,
"selected": false,
"text": "<p>Take it to your provinces</p>\n\n<pre><code><?php foreach ($posts as $post) : setup_postdata( $post ); ?&... | 2017/07/21 | [
"https://wordpress.stackexchange.com/questions/274116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17561/"
] | Due to the setup of my template (and layout), I need to be able to place 4 different posts in 4 different divs.
For example, my structure would be like this
```
<div>Post 1</div>
<div>
<div>Post 2</div>
<div>
<div>Post 3</div>
<div>Post 4</div>
</div>
</div>
```
But I'm having some troub... | Your problem is that the variable passed to `setup_postdata()` *must* be the global `$post` variable, like this:
```
// Reference global $post variable.
global $post;
// Get posts.
$posts = get_posts(array(
'post_type' => 'post',
'post_count' => 4
));
// Set global post variable to first post.
$post = $pos... |
274,145 | <p>I have a taxonomy page called <code>taxonomy-hotels.php</code> I need to get all posts related to particular <code>taxonomy-term</code>. Assume I have a term <code>5 star hotel</code> and it has 15 posts. But ony 10 returning/showing.</p>
<p>Pleasa let me know how to get all posts ? Here is my current code.</p>
<p... | [
{
"answer_id": 274119,
"author": "While1",
"author_id": 111798,
"author_profile": "https://wordpress.stackexchange.com/users/111798",
"pm_score": 2,
"selected": false,
"text": "<p>Take it to your provinces</p>\n\n<pre><code><?php foreach ($posts as $post) : setup_postdata( $post ); ?&... | 2017/07/21 | [
"https://wordpress.stackexchange.com/questions/274145",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85766/"
] | I have a taxonomy page called `taxonomy-hotels.php` I need to get all posts related to particular `taxonomy-term`. Assume I have a term `5 star hotel` and it has 15 posts. But ony 10 returning/showing.
Pleasa let me know how to get all posts ? Here is my current code.
```
<?php
if(have_pos... | Your problem is that the variable passed to `setup_postdata()` *must* be the global `$post` variable, like this:
```
// Reference global $post variable.
global $post;
// Get posts.
$posts = get_posts(array(
'post_type' => 'post',
'post_count' => 4
));
// Set global post variable to first post.
$post = $pos... |
274,206 | <p>The following loop works great for me in getting posts with a given date with the use of the_time(...):</p>
<pre><code><?php
$myPost = new WP_Query( array(
'posts_per_page' => '50',
'orderby' => 'modified',
'order' => 'DESC'
));
while ($myPost->have_posts()): $myPost->the_p... | [
{
"answer_id": 274211,
"author": "dbeja",
"author_id": 9585,
"author_profile": "https://wordpress.stackexchange.com/users/9585",
"pm_score": 1,
"selected": false,
"text": "<p>You can save the last date on a variable and on each iteration you compare the current date with the last date, a... | 2017/07/21 | [
"https://wordpress.stackexchange.com/questions/274206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98671/"
] | The following loop works great for me in getting posts with a given date with the use of the\_time(...):
```
<?php
$myPost = new WP_Query( array(
'posts_per_page' => '50',
'orderby' => 'modified',
'order' => 'DESC'
));
while ($myPost->have_posts()): $myPost->the_post();
?>
<div class="timeline... | Just use `the_date()`, it has this as a built-in feature.
See the [dev docs](https://developer.wordpress.org/reference/functions/the_date/) for more info. |
274,259 | <p>I am developing a wordpress page template exactly like <a href="https://blog.squarespace.com/blog/introducing-promotional-pop-ups" rel="nofollow noreferrer">this</a>.
I have completed the design and have loaded the template once user goes to this page which using my template. I want to all posts in more article list... | [
{
"answer_id": 274284,
"author": "Abdul Awal Uzzal",
"author_id": 31449,
"author_profile": "https://wordpress.stackexchange.com/users/31449",
"pm_score": -1,
"selected": false,
"text": "<p>You can simply put your code in single.php if you want all the posts to use this template style.</p... | 2017/07/22 | [
"https://wordpress.stackexchange.com/questions/274259",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123788/"
] | I am developing a wordpress page template exactly like [this](https://blog.squarespace.com/blog/introducing-promotional-pop-ups).
I have completed the design and have loaded the template once user goes to this page which using my template. I want to all posts in more article list open in this template without refreshin... | What you are looking for is AJAX navigation. It's not that complicated, however it's not very easy too. I've written a simple example for you, I hope it helps you in your case.
An AJAX request has 2 steps, first a front-end request that is sent out by browser when for example a user clicks a link or an element, then a... |
274,261 | <p>I want my theme to have an 'about' page available by default when a user uses my theme.</p>
<p>Is there a way to auto create a page when a user selects your template?</p>
<p>Or some other way of achieving this?</p>
| [
{
"answer_id": 274269,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 2,
"selected": false,
"text": "<p>The wp_insert_post() function is where to start <a href=\"https://developer.wordpress.org/reference/fu... | 2017/07/22 | [
"https://wordpress.stackexchange.com/questions/274261",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105958/"
] | I want my theme to have an 'about' page available by default when a user uses my theme.
Is there a way to auto create a page when a user selects your template?
Or some other way of achieving this? | There is a hook specifically for this purpose, called [`after_switch_theme`](https://codex.wordpress.org/Plugin_API/Action_Reference/after_switch_theme). You can hook into it and create your personal page after theme activation. Have a look at this:
```
add_action( 'after_switch_theme', 'create_page_on_theme_activatio... |
274,277 | <p>Someone made a website for me using wordpress.org. They said that they used "Wordpress Framework".</p>
<p>Although I haven't changed anything, the logo of the website (which was an image near the top of the homepage is now missing. Not sure how it could disappear without me changing anything, but I am trying to rec... | [
{
"answer_id": 274269,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 2,
"selected": false,
"text": "<p>The wp_insert_post() function is where to start <a href=\"https://developer.wordpress.org/reference/fu... | 2017/07/22 | [
"https://wordpress.stackexchange.com/questions/274277",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123873/"
] | Someone made a website for me using wordpress.org. They said that they used "Wordpress Framework".
Although I haven't changed anything, the logo of the website (which was an image near the top of the homepage is now missing. Not sure how it could disappear without me changing anything, but I am trying to rectify this ... | There is a hook specifically for this purpose, called [`after_switch_theme`](https://codex.wordpress.org/Plugin_API/Action_Reference/after_switch_theme). You can hook into it and create your personal page after theme activation. Have a look at this:
```
add_action( 'after_switch_theme', 'create_page_on_theme_activatio... |
274,278 | <p>I have a <code>page.php</code> in which I am defining a custom sub-menu to pass to <code>header.php</code>.</p>
<p>I've tried using a constant (clumsy, I know): </p>
<pre><code>define("CUSTOM_MENU", "<ul><li>Test</li></ul>");
</code></pre>
<p>right after this, the code is including the hea... | [
{
"answer_id": 274322,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>There is most likely an issue of load order. The <code>get_header()</code> function does included your <cod... | 2017/07/22 | [
"https://wordpress.stackexchange.com/questions/274278",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2161/"
] | I have a `page.php` in which I am defining a custom sub-menu to pass to `header.php`.
I've tried using a constant (clumsy, I know):
```
define("CUSTOM_MENU", "<ul><li>Test</li></ul>");
```
right after this, the code is including the header:
```
get_header();
```
In the header.php file, where the sub menu is, I ... | There is most likely an issue of load order. The `get_header()` function does included your `header.php` file, so I'm not sure what's happening inside that template. One way to figure out is to include it using `include()` and check if the behavior is the same.
I would suggest you hook into the `wp_head` or `init` and... |
274,294 | <p>I have some code that returns the latest 5 images from the WordPress Media Library:</p>
<pre><code><?php
$excluded = array(1,35,37);
$args = array(
'post_type' => 'attachment',
'numberposts' => '5',
'category__not_in' => $excluded
);
$images = get_posts($args);
... | [
{
"answer_id": 274322,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>There is most likely an issue of load order. The <code>get_header()</code> function does included your <cod... | 2017/07/23 | [
"https://wordpress.stackexchange.com/questions/274294",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9820/"
] | I have some code that returns the latest 5 images from the WordPress Media Library:
```
<?php
$excluded = array(1,35,37);
$args = array(
'post_type' => 'attachment',
'numberposts' => '5',
'category__not_in' => $excluded
);
$images = get_posts($args);
if (!empty($images)) {
?... | There is most likely an issue of load order. The `get_header()` function does included your `header.php` file, so I'm not sure what's happening inside that template. One way to figure out is to include it using `include()` and check if the behavior is the same.
I would suggest you hook into the `wp_head` or `init` and... |
274,295 | <p>I try to change WordPress Twenty-sixteen them.</p>
<p>I check the CSS carefully, can't finger out how could be the main menu display on the right of logo(and name of website).</p>
<p>No float, no inline-block.</p>
<p>I try to add float or display as block to menu and logo, doesn't work at all.How they do it?</p>
| [
{
"answer_id": 274301,
"author": "Rajendra",
"author_id": 107649,
"author_profile": "https://wordpress.stackexchange.com/users/107649",
"pm_score": -1,
"selected": false,
"text": "<p>In my suggestion, start a child theme of Twenty-sixteen theme,preferred way to Override parent theme func... | 2017/07/23 | [
"https://wordpress.stackexchange.com/questions/274295",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18787/"
] | I try to change WordPress Twenty-sixteen them.
I check the CSS carefully, can't finger out how could be the main menu display on the right of logo(and name of website).
No float, no inline-block.
I try to add float or display as block to menu and logo, doesn't work at all.How they do it? | The header of Twenty-Sixteen uses flexbox for alignment. You can set the flex direction of the site-header-main class to column to display the menu under the title/tagline/logo area:
```
.site-header-main {
flex-direction: column;
}
``` |
274,296 | <p>How can I make it so only members see post summaries on category pages? Currently only members can access them, but they still show up on category pages for non members. </p>
<p>Note: I now made a plugin for this, you can get it at: <a href="https://github.com/NerdOfLinux/MemberOnly" rel="nofollow noreferrer">https... | [
{
"answer_id": 274301,
"author": "Rajendra",
"author_id": 107649,
"author_profile": "https://wordpress.stackexchange.com/users/107649",
"pm_score": -1,
"selected": false,
"text": "<p>In my suggestion, start a child theme of Twenty-sixteen theme,preferred way to Override parent theme func... | 2017/07/23 | [
"https://wordpress.stackexchange.com/questions/274296",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123649/"
] | How can I make it so only members see post summaries on category pages? Currently only members can access them, but they still show up on category pages for non members.
Note: I now made a plugin for this, you can get it at: <https://github.com/NerdOfLinux/MemberOnly> | The header of Twenty-Sixteen uses flexbox for alignment. You can set the flex direction of the site-header-main class to column to display the menu under the title/tagline/logo area:
```
.site-header-main {
flex-direction: column;
}
``` |
274,311 | <pre><code><?php
query_posts(
array(
'showposts' => $number,
'nopaging' => 0,
'download_category' => $term->name,
'orderby' => 'meta_value_num',
'meta_key' => 'post_views_count',
'or... | [
{
"answer_id": 274315,
"author": "ClemC",
"author_id": 73239,
"author_profile": "https://wordpress.stackexchange.com/users/73239",
"pm_score": 0,
"selected": false,
"text": "<p>For executing this query only on user's click action, you can use URL params.</p>\n\n<p>In your template:</p>\n... | 2017/07/23 | [
"https://wordpress.stackexchange.com/questions/274311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124411/"
] | ```
<?php
query_posts(
array(
'showposts' => $number,
'nopaging' => 0,
'download_category' => $term->name,
'orderby' => 'meta_value_num',
'meta_key' => 'post_views_count',
'order' => 'DES... | You can add a query string to your URL and then alter the query if that string is set. What I'm going to do is to use `pre_get_posts` to modify the main query.
```
function sort_by_views($query) {
if (
!is_admin() &&
$query->is_main_query() &&
$query->is_home() &&
isset( $_REQUEST... |
274,318 | <p>Here are the arguments for my query.</p>
<p>The query always shows the same order after every refresh.</p>
<p>Explanation to the query:
it show only 4 posts of the custom post type <code>projekte</code>. The post has a custom meta field called <code>ecpt_skills</code> and it should check if there is a string in i... | [
{
"answer_id": 274315,
"author": "ClemC",
"author_id": 73239,
"author_profile": "https://wordpress.stackexchange.com/users/73239",
"pm_score": 0,
"selected": false,
"text": "<p>For executing this query only on user's click action, you can use URL params.</p>\n\n<p>In your template:</p>\n... | 2017/07/23 | [
"https://wordpress.stackexchange.com/questions/274318",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124414/"
] | Here are the arguments for my query.
The query always shows the same order after every refresh.
Explanation to the query:
it show only 4 posts of the custom post type `projekte`. The post has a custom meta field called `ecpt_skills` and it should check if there is a string in it which is stored in the variable `$por... | You can add a query string to your URL and then alter the query if that string is set. What I'm going to do is to use `pre_get_posts` to modify the main query.
```
function sort_by_views($query) {
if (
!is_admin() &&
$query->is_main_query() &&
$query->is_home() &&
isset( $_REQUEST... |
274,321 | <p>I'm using the ACF plugin and overall it's working great. </p>
<p>Expect for one small part:</p>
<p>I've got a WYSIWYG text box on a page where I add a few enters, but when I look at the console I get an unexpected token < error:</p>
<pre><code><?php the_field('correctoutput'); ?>
</code></pre>
<p>WHen I... | [
{
"answer_id": 274315,
"author": "ClemC",
"author_id": 73239,
"author_profile": "https://wordpress.stackexchange.com/users/73239",
"pm_score": 0,
"selected": false,
"text": "<p>For executing this query only on user's click action, you can use URL params.</p>\n\n<p>In your template:</p>\n... | 2017/07/23 | [
"https://wordpress.stackexchange.com/questions/274321",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114176/"
] | I'm using the ACF plugin and overall it's working great.
Expect for one small part:
I've got a WYSIWYG text box on a page where I add a few enters, but when I look at the console I get an unexpected token < error:
```
<?php the_field('correctoutput'); ?>
```
WHen I try to use the below part is just breaks:
```
<... | You can add a query string to your URL and then alter the query if that string is set. What I'm going to do is to use `pre_get_posts` to modify the main query.
```
function sort_by_views($query) {
if (
!is_admin() &&
$query->is_main_query() &&
$query->is_home() &&
isset( $_REQUEST... |
274,368 | <p>I am trying to show the featured posts in my theme, with a custom field <code>mytheme_featured_post</code> which is 1 on the featured posts. </p>
<p>However it does not seem to filter the posts down to only the posts in the meta query. </p>
<pre><code>// WP_Query arguments.
$featured = array(
'posts_per_page' =>... | [
{
"answer_id": 274315,
"author": "ClemC",
"author_id": 73239,
"author_profile": "https://wordpress.stackexchange.com/users/73239",
"pm_score": 0,
"selected": false,
"text": "<p>For executing this query only on user's click action, you can use URL params.</p>\n\n<p>In your template:</p>\n... | 2017/07/23 | [
"https://wordpress.stackexchange.com/questions/274368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107055/"
] | I am trying to show the featured posts in my theme, with a custom field `mytheme_featured_post` which is 1 on the featured posts.
However it does not seem to filter the posts down to only the posts in the meta query.
```
// WP_Query arguments.
$featured = array(
'posts_per_page' => '5',
'meta_query' => array(
a... | You can add a query string to your URL and then alter the query if that string is set. What I'm going to do is to use `pre_get_posts` to modify the main query.
```
function sort_by_views($query) {
if (
!is_admin() &&
$query->is_main_query() &&
$query->is_home() &&
isset( $_REQUEST... |
274,382 | <p>I just finished my blog I made locally and I would like to upload it to the server as it is in my computer, including the posts and the plugins. Is it possible to do it? </p>
<p>I already have a WordPress installation in my server.</p>
| [
{
"answer_id": 274315,
"author": "ClemC",
"author_id": 73239,
"author_profile": "https://wordpress.stackexchange.com/users/73239",
"pm_score": 0,
"selected": false,
"text": "<p>For executing this query only on user's click action, you can use URL params.</p>\n\n<p>In your template:</p>\n... | 2017/07/24 | [
"https://wordpress.stackexchange.com/questions/274382",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114684/"
] | I just finished my blog I made locally and I would like to upload it to the server as it is in my computer, including the posts and the plugins. Is it possible to do it?
I already have a WordPress installation in my server. | You can add a query string to your URL and then alter the query if that string is set. What I'm going to do is to use `pre_get_posts` to modify the main query.
```
function sort_by_views($query) {
if (
!is_admin() &&
$query->is_main_query() &&
$query->is_home() &&
isset( $_REQUEST... |
274,383 | <p>I'm trying to put a line break in my input text field in customizer.
I'm using a sanitization function like this</p>
<pre><code>function sanitize_text( $input ) {
$allowed_html = array(
'br' => array(),
);
return wp_kses( $input, $allowed_html );
}
</code></pre>
<p>I also using php strip_tags but... | [
{
"answer_id": 274386,
"author": "Tim Elsass",
"author_id": 80375,
"author_profile": "https://wordpress.stackexchange.com/users/80375",
"pm_score": 0,
"selected": false,
"text": "<p>I tried the code you shared above and everything appears to be working as intended.</p>\n\n<p>Are you sure... | 2017/07/24 | [
"https://wordpress.stackexchange.com/questions/274383",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124443/"
] | I'm trying to put a line break in my input text field in customizer.
I'm using a sanitization function like this
```
function sanitize_text( $input ) {
$allowed_html = array(
'br' => array(),
);
return wp_kses( $input, $allowed_html );
}
```
I also using php strip\_tags but neither of them works.
T... | The only way I was able to make it work was that:
functions.php
```
function test_customizer( $wp_customize ) {
$wp_customize->add_setting( 'themeslug_text_setting_id', array(
'capability' => 'edit_theme_options',
'default' => 'Lorem Ipsum',
'sanitize_callback' => 'sanitize_textarea_field'... |
274,408 | <p><code>the_tags</code> by default is displaying as URL. I need to display it as plain text to insert inside HTML attribute.</p>
<pre><code><?php
$tag = the_tags('');
?>
<div class="image-portfolio" data-section="<?php echo $tag ?>">
</code></pre>
| [
{
"answer_id": 274409,
"author": "Viktor",
"author_id": 81006,
"author_profile": "https://wordpress.stackexchange.com/users/81006",
"pm_score": 2,
"selected": false,
"text": "<p>Ok i figure it out</p>\n\n<pre><code>$tag = get_the_tags();\nforeach($tag as $tags) {\n echo $tags->name... | 2017/07/24 | [
"https://wordpress.stackexchange.com/questions/274408",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81006/"
] | `the_tags` by default is displaying as URL. I need to display it as plain text to insert inside HTML attribute.
```
<?php
$tag = the_tags('');
?>
<div class="image-portfolio" data-section="<?php echo $tag ?>">
``` | I'm glad you figured it out, but below is a quick semantic alteration (swapping your use of `$tag` singular and `$tags` plural will help it read closer to what it is doing; functionally it is no different).
I also added cases for inside and outside the Loop, and a conditional so you don't end up trying to foreach loo... |
274,430 | <p>I need to get posts belongs to few categories, but it should match following rule.</p>
<p>let say I have category ids 100,105 & 106. </p>
<p>then I need <code>100 && ( 105 || 106 )</code> this rule.</p>
<p>I know following rules for separate <code>OR</code> & <code>AND</code>, </p>
<pre><code>$qu... | [
{
"answer_id": 274435,
"author": "Janith Chinthana",
"author_id": 68403,
"author_profile": "https://wordpress.stackexchange.com/users/68403",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure this is the best way, but I have managed to get the desired result set with following <code... | 2017/07/24 | [
"https://wordpress.stackexchange.com/questions/274430",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68403/"
] | I need to get posts belongs to few categories, but it should match following rule.
let say I have category ids 100,105 & 106.
then I need `100 && ( 105 || 106 )` this rule.
I know following rules for separate `OR` & `AND`,
```
$query = new WP_Query( array( 'cat' => '100,105,106' ) ); // 100 || 105 || 106
$query ... | Not sure this is the best way, but I have managed to get the desired result set with following `$args` parameters.
```
$args['tax_query'] = array(
'relation' => 'AND',
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => array(100),
),
array(
'taxonomy'... |
274,451 | <p>I am very new to wordpress. I installed it on my linux server lately and uploaded a them on it. Everything looks good on my browser however if I try to access the website outside my network I am only getting the Text and not the CSS. I have read all different forum for the fix bt my problem still there.
Here is my ... | [
{
"answer_id": 274456,
"author": "Chris Pink",
"author_id": 57686,
"author_profile": "https://wordpress.stackexchange.com/users/57686",
"pm_score": 0,
"selected": false,
"text": "<p>Check you are addressing the CSS file correctly. How is it being called?</p>\n\n<p>The url should be along... | 2017/07/24 | [
"https://wordpress.stackexchange.com/questions/274451",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124482/"
] | I am very new to wordpress. I installed it on my linux server lately and uploaded a them on it. Everything looks good on my browser however if I try to access the website outside my network I am only getting the Text and not the CSS. I have read all different forum for the fix bt my problem still there.
Here is my .ht... | Check you are addressing the CSS file correctly. How is it being called?
The url should be along the lines of `ht|tp://yoursite.com/wordpress/wp-content/themes/yourtheme/style.css` you'll find somewhere that it's loading as `ht|tp://localhost/`and so it will load correctly on your machine but not on anyone else's.
Ha... |
274,465 | <p>I want to be able to create a shortcode that will return the post title when I pass in the ID of the post. I.E. [myshortcode_title ID=1234]</p>
<p>I have a shortcode that pulls the post title from the current post: </p>
<pre><code>function myshortcode_title( ){
return get_the_title();
}
add_shortcode( 'page_tit... | [
{
"answer_id": 274456,
"author": "Chris Pink",
"author_id": 57686,
"author_profile": "https://wordpress.stackexchange.com/users/57686",
"pm_score": 0,
"selected": false,
"text": "<p>Check you are addressing the CSS file correctly. How is it being called?</p>\n\n<p>The url should be along... | 2017/07/24 | [
"https://wordpress.stackexchange.com/questions/274465",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124490/"
] | I want to be able to create a shortcode that will return the post title when I pass in the ID of the post. I.E. [myshortcode\_title ID=1234]
I have a shortcode that pulls the post title from the current post:
```
function myshortcode_title( ){
return get_the_title();
}
add_shortcode( 'page_title', 'myshortcode_ti... | Check you are addressing the CSS file correctly. How is it being called?
The url should be along the lines of `ht|tp://yoursite.com/wordpress/wp-content/themes/yourtheme/style.css` you'll find somewhere that it's loading as `ht|tp://localhost/`and so it will load correctly on your machine but not on anyone else's.
Ha... |
274,493 | <p>How can you ensure a given plugin is run <em>last</em> before the page finishes rendering?</p>
<p>Can it be ensured?</p>
<p>Specifically, I am writing a plugin that I want to post-process all content of a given post/page (after any formatting, extra links, ad injections, etc). The rest of the blog doesn't need to ... | [
{
"answer_id": 274495,
"author": "WPExplorer",
"author_id": 68694,
"author_profile": "https://wordpress.stackexchange.com/users/68694",
"pm_score": 3,
"selected": true,
"text": "<p>You'll want to hook into \"the_content\" filter at a very high priority. Example:</p>\n\n<pre><code>functio... | 2017/07/24 | [
"https://wordpress.stackexchange.com/questions/274493",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5173/"
] | How can you ensure a given plugin is run *last* before the page finishes rendering?
Can it be ensured?
Specifically, I am writing a plugin that I want to post-process all content of a given post/page (after any formatting, extra links, ad injections, etc). The rest of the blog doesn't need to be processed - just post... | You'll want to hook into "the\_content" filter at a very high priority. Example:
```
function my_alter_the_content( $content ) {
if ( in_array( get_post_type(), array( 'post', 'page' ) ) ) {
// Do stuff here for posts and pages
}
return $content;
}
add_action( 'the_content', 'my_alter_the_content',... |
274,496 | <p>I'm using the following to add specific classes to my odd/even posts but I also need to add a class to all posts except the first one. Is there a quick, semantic way to do this minus the first post?</p>
<pre><code><?php $homenews_query = new WP_Query( 'posts_per_page=4' ); ?>
<?php while ($hom... | [
{
"answer_id": 274498,
"author": "Cesar Henrique Damascena",
"author_id": 109804,
"author_profile": "https://wordpress.stackexchange.com/users/109804",
"pm_score": 2,
"selected": true,
"text": "<p>You can do this in multiple ways, but you will need something commom to all posts, exemple:... | 2017/07/24 | [
"https://wordpress.stackexchange.com/questions/274496",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7662/"
] | I'm using the following to add specific classes to my odd/even posts but I also need to add a class to all posts except the first one. Is there a quick, semantic way to do this minus the first post?
```
<?php $homenews_query = new WP_Query( 'posts_per_page=4' ); ?>
<?php while ($homenews_query -> have_pos... | You can do this in multiple ways, but you will need something commom to all posts, exemple:
```
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
```
then in your **css**:
```
.post:not(:first-child) {
// add the rules of the class you wan... |
274,515 | <p>I have a simple columns shortcode. (How) can this be adjusted to output a containing div around multiple columns? </p>
<p>Really don't want to nest shortcodes in the frontend. Perhaps some kind of filter?</p>
<p>My <code>functions.php</code> looks like this:</p>
<pre><code>// Columns shortcode
function abc_custo... | [
{
"answer_id": 274498,
"author": "Cesar Henrique Damascena",
"author_id": 109804,
"author_profile": "https://wordpress.stackexchange.com/users/109804",
"pm_score": 2,
"selected": true,
"text": "<p>You can do this in multiple ways, but you will need something commom to all posts, exemple:... | 2017/07/24 | [
"https://wordpress.stackexchange.com/questions/274515",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have a simple columns shortcode. (How) can this be adjusted to output a containing div around multiple columns?
Really don't want to nest shortcodes in the frontend. Perhaps some kind of filter?
My `functions.php` looks like this:
```
// Columns shortcode
function abc_custom_column( $atts, $content = null ) {
... | You can do this in multiple ways, but you will need something commom to all posts, exemple:
```
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
```
then in your **css**:
```
.post:not(:first-child) {
// add the rules of the class you wan... |
274,518 | <p>Whenever I search something on my wordpress site, I get the error:</p>
<pre><code>Fatal error: Uncaught Error: Call to undefined function get_exID() in
/var/www/html/wp-content/themes/twentyseventeen/functions.php:360
Stack trace: #0 /var/www/html/wp-includes/class-wp-hook.php(298):
twentyseventeen_excerpt_more(... | [
{
"answer_id": 274498,
"author": "Cesar Henrique Damascena",
"author_id": 109804,
"author_profile": "https://wordpress.stackexchange.com/users/109804",
"pm_score": 2,
"selected": true,
"text": "<p>You can do this in multiple ways, but you will need something commom to all posts, exemple:... | 2017/07/24 | [
"https://wordpress.stackexchange.com/questions/274518",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123649/"
] | Whenever I search something on my wordpress site, I get the error:
```
Fatal error: Uncaught Error: Call to undefined function get_exID() in
/var/www/html/wp-content/themes/twentyseventeen/functions.php:360
Stack trace: #0 /var/www/html/wp-includes/class-wp-hook.php(298):
twentyseventeen_excerpt_more(' […]')... | You can do this in multiple ways, but you will need something commom to all posts, exemple:
```
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
```
then in your **css**:
```
.post:not(:first-child) {
// add the rules of the class you wan... |
274,553 | <p>I am new to WordPress development. After develops a simple from the scratch everything works fine. Now I want to create a custom page template to show case all e-books with a just thumbnail of the cover and the price. To brief description, I want to redirect to a particular page. It's all like from the Blog list to ... | [
{
"answer_id": 274498,
"author": "Cesar Henrique Damascena",
"author_id": 109804,
"author_profile": "https://wordpress.stackexchange.com/users/109804",
"pm_score": 2,
"selected": true,
"text": "<p>You can do this in multiple ways, but you will need something commom to all posts, exemple:... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274553",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124542/"
] | I am new to WordPress development. After develops a simple from the scratch everything works fine. Now I want to create a custom page template to show case all e-books with a just thumbnail of the cover and the price. To brief description, I want to redirect to a particular page. It's all like from the Blog list to par... | You can do this in multiple ways, but you will need something commom to all posts, exemple:
```
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
```
then in your **css**:
```
.post:not(:first-child) {
// add the rules of the class you wan... |
274,559 | <p>I'm coding a plugin that adds a filter to <code>single_template</code>. The filter function successfully returns the path to my <code>show-post-in-a-lightbox.php</code> template.</p>
<p>As you can guess from its name, my template is intended to show a single post in a lightbox. Therefore I need to show only the pos... | [
{
"answer_id": 274562,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the <code>wp_head()</code> function, you just need to add the opening <code>html</code> and... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84622/"
] | I'm coding a plugin that adds a filter to `single_template`. The filter function successfully returns the path to my `show-post-in-a-lightbox.php` template.
As you can guess from its name, my template is intended to show a single post in a lightbox. Therefore I need to show only the post content and avoid the title ba... | I've finally ended up with something similar to what Mark Kaplun had suggested in his answer, but, instead of using JS code, I opted for a CSS solution instead.
When my code creates the `<iframe>` link, it appends a extra HTTP parameter:
```
$lightboxlink = '/?p='.$postid.'&use-lightbox-css=1';
```
Then the plugin ... |
274,561 | <p>I created text widget and wordpress created some default styles it uses h2 tag and class "widgettitle". How can i change tag to h1 and remove class from it.</p>
<p>This is my function.php file</p>
<pre><code>function home_consultation_init() {
register_sidebar(array(
"name" => "Home Consulatation",
... | [
{
"answer_id": 274566,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<p>The <code>before-title</code> and <code>after-title</code> arguments passed to <code>register_sidebar()<... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274561",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124458/"
] | I created text widget and wordpress created some default styles it uses h2 tag and class "widgettitle". How can i change tag to h1 and remove class from it.
This is my function.php file
```
function home_consultation_init() {
register_sidebar(array(
"name" => "Home Consulatation",
"id" => "home_co... | The `before-title` and `after-title` arguments passed to `register_sidebar()` need to use underscores:
```
register_sidebar(array(
"name" => "Home Consulatation",
"id" => "home_consult",
"before_widget" => "",
"after_widget" => "",
"before_title" => "",
"after_title" => ""
));
```
If you use ... |
274,569 | <p>I want to add custom PHP code to ensure that whenever a page on my site loads in my browser, the URL of that page is echoed to the screen. I can use <code>echo get_permalink()</code>, but that does not work on all pages. Some pages (e.g. <a href="https://www.horizonhomes-samui.com/" rel="noreferrer">my homepage</a... | [
{
"answer_id": 274572,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 9,
"selected": true,
"text": "<p><code>get_permalink()</code> is only really useful for single pages and posts, and only works inside the... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51204/"
] | I want to add custom PHP code to ensure that whenever a page on my site loads in my browser, the URL of that page is echoed to the screen. I can use `echo get_permalink()`, but that does not work on all pages. Some pages (e.g. [my homepage](https://www.horizonhomes-samui.com/)) display several posts, and if I use `get_... | `get_permalink()` is only really useful for single pages and posts, and only works inside the loop.
The simplest way I've seen is this:
```
global $wp;
echo home_url( $wp->request )
```
`$wp->request` includes the path part of the URL, eg. `/path/to/page` and `home_url()` outputs the URL in Settings > General, but ... |
274,576 | <p>I am having a problem when creating scheduled posts. I create the posts as normal, click edit, set a scheduled time and click ok then the shedual button. Soon as i do this i check the website and the post has been published immediately. I looked back in the view all posts page and the post says its still scheduled. ... | [
{
"answer_id": 274572,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 9,
"selected": true,
"text": "<p><code>get_permalink()</code> is only really useful for single pages and posts, and only works inside the... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274576",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122305/"
] | I am having a problem when creating scheduled posts. I create the posts as normal, click edit, set a scheduled time and click ok then the shedual button. Soon as i do this i check the website and the post has been published immediately. I looked back in the view all posts page and the post says its still scheduled. It ... | `get_permalink()` is only really useful for single pages and posts, and only works inside the loop.
The simplest way I've seen is this:
```
global $wp;
echo home_url( $wp->request )
```
`$wp->request` includes the path part of the URL, eg. `/path/to/page` and `home_url()` outputs the URL in Settings > General, but ... |
274,589 | <p>I have a code for display recent posts: </p>
<p><code><?php
$args = array( 'numberposts' => '5' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo '<h2><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"].'</a>... | [
{
"answer_id": 274591,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": true,
"text": "<p>You can use <a href=\"https://codex.wordpress.org/Function_Reference/get_the_category_list\" rel=\"nofol... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274589",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116847/"
] | I have a code for display recent posts:
`<?php
$args = array( 'numberposts' => '5' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo '<h2><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"].'</a> </h2> ';
echo '<p>' . date_i18n('d F Y', strtotime($rec... | You can use [`get_the_category_list()`](https://codex.wordpress.org/Function_Reference/get_the_category_list) to output a comma-separated list of links to categories:
```
<?php
$args = array( 'numberposts' => '5' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
... |
274,592 | <p>I am trying to create some kind of repeated fields and for that, I want to create a new wp editor with some unique ID. </p>
<p>So my question is there any way to create <code>wp_editor</code> using any js? same as we get using <code><?php wp_editor() ?></code> WordPress function.</p>
<p>I have tried using </... | [
{
"answer_id": 274608,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 4,
"selected": true,
"text": "<p>Thanks to <a href=\"https://wordpress.stackexchange.com/questions/274592/how-to-create-wp-editor-using-javascri... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114894/"
] | I am trying to create some kind of repeated fields and for that, I want to create a new wp editor with some unique ID.
So my question is there any way to create `wp_editor` using any js? same as we get using `<?php wp_editor() ?>` WordPress function.
I have tried using
```
tinyMCE .init( { mode : "exact" , element... | Thanks to [Jacob Peattie's comment](https://wordpress.stackexchange.com/questions/274592/how-to-create-wp-editor-using-javascript#comment407500_274592) I can answer this using JS only. Actually we did something similar, but prior 4.8 and it wasn't this easy, so we did use `wp_editor()` in the end. But now, you can do s... |
274,594 | <p>i am getting various casino links on my site, i have searched everywhere in the files in my database, but i can't locate the issue, these links come and go they mostly appear in the header and the footer.
After clicking on the link they linked to:</p>
<pre><code>http://my/sitehollywood-casino-columbus-jobs/
</code>... | [
{
"answer_id": 274602,
"author": "Tony Cecala",
"author_id": 124435,
"author_profile": "https://wordpress.stackexchange.com/users/124435",
"pm_score": 1,
"selected": false,
"text": "<p>Your site is almost definitely compromised. Doing your own cleanup may not be worth the time and effort... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274594",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114702/"
] | i am getting various casino links on my site, i have searched everywhere in the files in my database, but i can't locate the issue, these links come and go they mostly appear in the header and the footer.
After clicking on the link they linked to:
```
http://my/sitehollywood-casino-columbus-jobs/
```
I have attached... | Your site is almost definitely compromised. Doing your own cleanup may not be worth the time and effort because reinfection is likely if you miss a single infected file.
At this point I recommend to my clients that they get professional help. You may be able to get more details from a site scan by Sucuri. They have a ... |
274,624 | <p>With a plugin I'm trying to develop, I'm trying to place some content on the front-page of the website after the header.</p>
<p>In my plugin PHP file I have this (I've cut the html content out to save space):</p>
<pre><code>add_action( '__after_header' , 'add_promotional_text', 4 );
function add_promotional_text()... | [
{
"answer_id": 274629,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>This code appears wrong. Your version was doing a return if the front page or home was true. Change th... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274624",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15447/"
] | With a plugin I'm trying to develop, I'm trying to place some content on the front-page of the website after the header.
In my plugin PHP file I have this (I've cut the html content out to save space):
```
add_action( '__after_header' , 'add_promotional_text', 4 );
function add_promotional_text() {
// If we're on... | After turning on WP\_DEBUG,
```
define('WP_DEBUG', true);
```
I was receiving the error: **Conditional query tags do not work before the query is run. Before then, they always return false.**
After googling that error, I found a solution that works:
```
add_action( 'template_redirect', 'check_for_frontpage' );
f... |
274,650 | <p>In WordPress, I use a function in functions.php to only not show certain posts(by category) if a user is not signed in:</p>
<pre><code> function my_filter( $content ) {
$categories = array(
'news',
'opinions',
'sports',
'other',
);
if ( in_category( $categories ) ) {
... | [
{
"answer_id": 274651,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>You can do a conditional and return the post's URL by using a <code>get_the_permalink()</code> in conjuncti... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274650",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123649/"
] | In WordPress, I use a function in functions.php to only not show certain posts(by category) if a user is not signed in:
```
function my_filter( $content ) {
$categories = array(
'news',
'opinions',
'sports',
'other',
);
if ( in_category( $categories ) ) {
if ( i... | I figured out how to do it with the `get_the_permalink()` function:
```
/* Protect Member Only Posts*/
function post_filter( $content ) {
$categories = array(
'coding',
'python',
'linux-tutorials',
'swift',
'premium',
);
if ( in_category( $categories ) ) {
i... |
274,659 | <p>I apologize for asking such a simple question, but I am having a world of struggle in trying to convert the following echo statement to HTML with php tags inside of it. I am trying to get my custom metabox to work correctly, but it will not save my data unless I use the following format as an echo string (very frus... | [
{
"answer_id": 274651,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>You can do a conditional and return the post's URL by using a <code>get_the_permalink()</code> in conjuncti... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274659",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98671/"
] | I apologize for asking such a simple question, but I am having a world of struggle in trying to convert the following echo statement to HTML with php tags inside of it. I am trying to get my custom metabox to work correctly, but it will not save my data unless I use the following format as an echo string (very frustrat... | I figured out how to do it with the `get_the_permalink()` function:
```
/* Protect Member Only Posts*/
function post_filter( $content ) {
$categories = array(
'coding',
'python',
'linux-tutorials',
'swift',
'premium',
);
if ( in_category( $categories ) ) {
i... |
274,663 | <p>I'm writing a query that switches to the main blog of a MU site using switch_to_blog(). All is well except i'm attempting to write a wp_query that includes a variable needed from the previous blog. All the content being pulled from the main blog is stored in a CPT with a taxonomy that corresponds to the various sub-... | [
{
"answer_id": 274651,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>You can do a conditional and return the post's URL by using a <code>get_the_permalink()</code> in conjuncti... | 2017/07/25 | [
"https://wordpress.stackexchange.com/questions/274663",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16111/"
] | I'm writing a query that switches to the main blog of a MU site using switch\_to\_blog(). All is well except i'm attempting to write a wp\_query that includes a variable needed from the previous blog. All the content being pulled from the main blog is stored in a CPT with a taxonomy that corresponds to the various sub-... | I figured out how to do it with the `get_the_permalink()` function:
```
/* Protect Member Only Posts*/
function post_filter( $content ) {
$categories = array(
'coding',
'python',
'linux-tutorials',
'swift',
'premium',
);
if ( in_category( $categories ) ) {
i... |
274,668 | <p>I have a handful of products in my WooCommerce Store set to <code>Catalog & Search</code> and a bunch more just set to a visibility of just <code>Search</code>.</p>
<p>I put a lot of work into making sure my Catalog was nice and clean, but now I need to do some additional work on them and am trying to retrieve ... | [
{
"answer_id": 274651,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>You can do a conditional and return the post's URL by using a <code>get_the_permalink()</code> in conjuncti... | 2017/07/26 | [
"https://wordpress.stackexchange.com/questions/274668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121874/"
] | I have a handful of products in my WooCommerce Store set to `Catalog & Search` and a bunch more just set to a visibility of just `Search`.
I put a lot of work into making sure my Catalog was nice and clean, but now I need to do some additional work on them and am trying to retrieve the IDs of products that are ONLY in... | I figured out how to do it with the `get_the_permalink()` function:
```
/* Protect Member Only Posts*/
function post_filter( $content ) {
$categories = array(
'coding',
'python',
'linux-tutorials',
'swift',
'premium',
);
if ( in_category( $categories ) ) {
i... |
274,676 | <p>I created a search for my site using attachments. Each attachment is in category "Pictures", so my search form looks like:</p>
<pre><code><form method="get" id="searchform" action="<?php bloginfo('url'); ?>">
<input type="text" name="s" id="s" value="Search..." onfocus="if (this.value=='Search...... | [
{
"answer_id": 274651,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>You can do a conditional and return the post's URL by using a <code>get_the_permalink()</code> in conjuncti... | 2017/07/26 | [
"https://wordpress.stackexchange.com/questions/274676",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9820/"
] | I created a search for my site using attachments. Each attachment is in category "Pictures", so my search form looks like:
```
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>">
<input type="text" name="s" id="s" value="Search..." onfocus="if (this.value=='Search...') this.value='';" onblur="if... | I figured out how to do it with the `get_the_permalink()` function:
```
/* Protect Member Only Posts*/
function post_filter( $content ) {
$categories = array(
'coding',
'python',
'linux-tutorials',
'swift',
'premium',
);
if ( in_category( $categories ) ) {
i... |
274,677 | <p>I am trying to display a function using AJAX using a custom plugin. But doesn't seem to work.</p>
<p>My Javascript</p>
<pre><code>(function($) {
$(document).on( 'click', 'a.mylink', function( event ) {
$.ajax({
url: testing.ajax_url,
data : {
action : 'diplay_user_table'
},
success ... | [
{
"answer_id": 274680,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<p>You're not hooking the function to wp_ajax correctly. You need to replace the <code>my_action</code> par... | 2017/07/26 | [
"https://wordpress.stackexchange.com/questions/274677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105139/"
] | I am trying to display a function using AJAX using a custom plugin. But doesn't seem to work.
My Javascript
```
(function($) {
$(document).on( 'click', 'a.mylink', function( event ) {
$.ajax({
url: testing.ajax_url,
data : {
action : 'diplay_user_table'
},
success : function( response ... | You're not hooking the function to wp\_ajax correctly. You need to replace the `my_action` part with your action name that you're using the in AJAX request. In your case it's `display_user_table`. You also need to hook it on to `wp_ajax_nopriv` so that it works for logged out users. Here's your hook with those changes:... |
274,683 | <p>This is the bottom half of my child theme's functions.php.</p>
<pre><code>function register_my_scripts(){
if (is_shop() || is_product_category()){
wp_enqueue_style( 'shop-style', get_stylesheet_directory_uri() .
'/shop.css');
}
if (is_product()){
wp_enqueue_style( 'shop-style', get_stylesheet_directo... | [
{
"answer_id": 274680,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<p>You're not hooking the function to wp_ajax correctly. You need to replace the <code>my_action</code> par... | 2017/07/26 | [
"https://wordpress.stackexchange.com/questions/274683",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124596/"
] | This is the bottom half of my child theme's functions.php.
```
function register_my_scripts(){
if (is_shop() || is_product_category()){
wp_enqueue_style( 'shop-style', get_stylesheet_directory_uri() .
'/shop.css');
}
if (is_product()){
wp_enqueue_style( 'shop-style', get_stylesheet_directory_uri() .
'/... | You're not hooking the function to wp\_ajax correctly. You need to replace the `my_action` part with your action name that you're using the in AJAX request. In your case it's `display_user_table`. You also need to hook it on to `wp_ajax_nopriv` so that it works for logged out users. Here's your hook with those changes:... |
274,696 | <p>I want to change the registration form of WooCommerce a little bit. I'm fine with the normal form which comes from WooCommerce but I want to add the following fields and functions:</p>
<p>If a person enters the email and the password and press register, the person should be redirected to another page where the pers... | [
{
"answer_id": 275011,
"author": "dbdesigns",
"author_id": 119686,
"author_profile": "https://wordpress.stackexchange.com/users/119686",
"pm_score": 0,
"selected": false,
"text": "<p>I've been trying out the same code snippet from Cloudways as well. If you don't use the snippet in functi... | 2017/07/26 | [
"https://wordpress.stackexchange.com/questions/274696",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123952/"
] | I want to change the registration form of WooCommerce a little bit. I'm fine with the normal form which comes from WooCommerce but I want to add the following fields and functions:
If a person enters the email and the password and press register, the person should be redirected to another page where the person is forc... | I've been trying out the same code snippet from Cloudways as well. If you don't use the snippet in functions.php, but instead create a copy of the woocommerce file form-login.php in your child theme's folder/woocommerce/myaccount. Then the fields from the Couldways snippet can be used before the line containing:
```
<... |
274,701 | <p>I want to modify the WooCommerce "My Account" left side navigation menu.</p>
<p>For that, I have made changes in the <code>woocommerce/templates/myaccount/navigation.php</code>.
The problems with this approach are:</p>
<ul>
<li>I can add the new items <strong>only</strong> at the first or last position in the menu... | [
{
"answer_id": 277080,
"author": "ClemC",
"author_id": 73239,
"author_profile": "https://wordpress.stackexchange.com/users/73239",
"pm_score": 6,
"selected": true,
"text": "<p>For that, you do <strong>not</strong> need to modify the <a href=\"https://github.com/woocommerce/woocommerce/bl... | 2017/07/26 | [
"https://wordpress.stackexchange.com/questions/274701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124605/"
] | I want to modify the WooCommerce "My Account" left side navigation menu.
For that, I have made changes in the `woocommerce/templates/myaccount/navigation.php`.
The problems with this approach are:
* I can add the new items **only** at the first or last position in the menu. I'd need them at the 2nd and 3rd position i... | For that, you do **not** need to modify the [`woocommerce/templates/myaccount/navigation.php`](https://github.com/woocommerce/woocommerce/blob/master/templates/myaccount/navigation.php).
The best way to customize the "My Account" navigation menu items is to use:
* [`woocommerce_account_menu_items`](https://github.com... |
274,719 | <p>I have created my site with pure PHP-code, and now started to migrate it to Wordpress platform. Changing authentication from own system to WP-user meta was quite easy. But when i use user session data for site functions, i have to query now user meta instead of simple MySqli-queries.</p>
<p>My old query is like bel... | [
{
"answer_id": 277080,
"author": "ClemC",
"author_id": 73239,
"author_profile": "https://wordpress.stackexchange.com/users/73239",
"pm_score": 6,
"selected": true,
"text": "<p>For that, you do <strong>not</strong> need to modify the <a href=\"https://github.com/woocommerce/woocommerce/bl... | 2017/07/26 | [
"https://wordpress.stackexchange.com/questions/274719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124612/"
] | I have created my site with pure PHP-code, and now started to migrate it to Wordpress platform. Changing authentication from own system to WP-user meta was quite easy. But when i use user session data for site functions, i have to query now user meta instead of simple MySqli-queries.
My old query is like below. Page i... | For that, you do **not** need to modify the [`woocommerce/templates/myaccount/navigation.php`](https://github.com/woocommerce/woocommerce/blob/master/templates/myaccount/navigation.php).
The best way to customize the "My Account" navigation menu items is to use:
* [`woocommerce_account_menu_items`](https://github.com... |
274,737 | <p>How to build this menu in WordPress</p>
<pre><code><div class="collapse navbar-collapse" id="collapse-1">
<ul class="nav navbar-nav">
<li><a href="#">our story</a></li>
<li><a href="#">our vision</a></li... | [
{
"answer_id": 274743,
"author": "Elidrissi simo",
"author_id": 83187,
"author_profile": "https://wordpress.stackexchange.com/users/83187",
"pm_score": 0,
"selected": false,
"text": "<p>you can use Walker_Nav_Menu class if you want to modify the default wordpress menu markup.</p>\n\n<p>... | 2017/07/26 | [
"https://wordpress.stackexchange.com/questions/274737",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124623/"
] | How to build this menu in WordPress
```
<div class="collapse navbar-collapse" id="collapse-1">
<ul class="nav navbar-nav">
<li><a href="#">our story</a></li>
<li><a href="#">our vision</a></li>
<li class="dropdown">
<a ... | The easiest way to do this is to use an off-the-shelf solution. There is a WP\_Bootstrap\_Navwalker class which extends WordPress' native Walker\_Nav\_Menu class and makes your Navigation Menus ready for Bootstrap 3 or 4. [Download it from GitHub](https://github.com/wp-bootstrap/wp-bootstrap-navwalker).
Add it to your... |
274,802 | <p>Here is code , basically I want to fetch by Post author but not able to solve this any help regards this . </p>
<pre><code><?php
global $post;
$author = get_the_author();
$args = array(
'author' =>$user_ID,
'posts_per_pag... | [
{
"answer_id": 274771,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>Do <strong>not</strong> rely on changing plugin details to work around this issue. The code that decides a match in... | 2017/07/26 | [
"https://wordpress.stackexchange.com/questions/274802",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112012/"
] | Here is code , basically I want to fetch by Post author but not able to solve this any help regards this .
```
<?php
global $post;
$author = get_the_author();
$args = array(
'author' =>$user_ID,
'posts_per_page' => $per_page,
... | I was able to find out that wordpress does cache available updates in the wp\_options table in an option named `_site_transient_update_plugins`.
By clearing this value I was able to get Wordpress to notice my changes. I used the following query:
`UPDATE wp_options SET option_value='' WHERE option_name='_site_transien... |
274,810 | <p>I'm trying to setup unit tests for a plugin I am developing. I just followed the steps at... <a href="https://make.wordpress.org/cli/handbook/plugin-unit-tests/" rel="nofollow noreferrer">https://make.wordpress.org/cli/handbook/plugin-unit-tests/</a></p>
<p>However, when I run <code>phpunit</code> I get the follow... | [
{
"answer_id": 274811,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>That problem sounds like your code is sending text/characters to the screen, then it sends out a page ... | 2017/07/26 | [
"https://wordpress.stackexchange.com/questions/274810",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28787/"
] | I'm trying to setup unit tests for a plugin I am developing. I just followed the steps at... <https://make.wordpress.org/cli/handbook/plugin-unit-tests/>
However, when I run `phpunit` I get the following...
```
$ phpunit
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
War... | The error is telling you that the code tried to output a HTTP response header with the `header()` function after the response body has already begun to be sent. As you noted, line 68 of `bootstrap.php` is calling that script that outputs `Installing...`. So after that output has already been sent, you can't send a resp... |
274,816 | <p>I have a featured image preview in column view in my Custom Post Types. Now I want to change the size of it. This is my code:</p>
<pre><code>add_filter('manage_posts_columns', 'add_img_column');
add_filter('manage_posts_custom_column', 'manage_img_column', 10, 2);
function add_img_column($columns) {
$columns['... | [
{
"answer_id": 274817,
"author": "Cesar Henrique Damascena",
"author_id": 109804,
"author_profile": "https://wordpress.stackexchange.com/users/109804",
"pm_score": 2,
"selected": false,
"text": "<p>You can create a new size with the funcion <code>add_image_size</code>, example:</p>\n\n<p... | 2017/07/27 | [
"https://wordpress.stackexchange.com/questions/274816",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116847/"
] | I have a featured image preview in column view in my Custom Post Types. Now I want to change the size of it. This is my code:
```
add_filter('manage_posts_columns', 'add_img_column');
add_filter('manage_posts_custom_column', 'manage_img_column', 10, 2);
function add_img_column($columns) {
$columns['img'] = 'Featu... | In functions.php :
Make sure featured images are enabled
```
add_theme_support( 'post-thumbnails' );
```
then add
```
add_image_size( 'thumbnail-news', '100', '75', true );
```
And in the code above change
```
echo get_the_post_thumbnail($post_id, 'thumbnail');
```
to
```
echo get_the_post_thumbnail($post_i... |
274,861 | <p>I've written a function to get products by price range. All works, but now I need add a extra meta key, that will be like 50 - 100 and featured, but code is not returning any products. What is wrong on this code?</p>
<pre><code> function product_price_filter_box($attr) {
$limit = intval($attr['limit']);
... | [
{
"answer_id": 276424,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>The featured product's meta key is <code>_featured</code>, but you are using <code>featured</code> in your ... | 2017/07/27 | [
"https://wordpress.stackexchange.com/questions/274861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44844/"
] | I've written a function to get products by price range. All works, but now I need add a extra meta key, that will be like 50 - 100 and featured, but code is not returning any products. What is wrong on this code?
```
function product_price_filter_box($attr) {
$limit = intval($attr['limit']);
$min = intval(... | The featured product's meta key is `_featured`, but you are using `featured` in your meta query. This will return no products, since the key doesn't exist.
Also, as far as I know, the value of the key is `yes`, so your arguments should be like this:
```
array(
'key' => '_featured',
'value' => 'yes',... |
274,864 | <p>How can I load Google font only if custom logo is not uploaded?</p>
<p>I know how to load resource if we are on this or that page, but not sure how to do this?</p>
| [
{
"answer_id": 274865,
"author": "Nuno Sarmento",
"author_id": 75461,
"author_profile": "https://wordpress.stackexchange.com/users/75461",
"pm_score": 1,
"selected": false,
"text": "<p>The code is not tested but is a good starting point, you may need to add action to enqueue the css or y... | 2017/07/27 | [
"https://wordpress.stackexchange.com/questions/274864",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66784/"
] | How can I load Google font only if custom logo is not uploaded?
I know how to load resource if we are on this or that page, but not sure how to do this? | There is a function for this purpose, called [`has_custom_logo()`](https://developer.wordpress.org/reference/functions/has_custom_logo/). You can check whether the website has a custom logo or not by having this conditional:
```
if ( ! has_custom_logo() ) {
// Enqueue some google fonts
wp_enqueue_style( 'googl... |
274,885 | <p>It would be a right way to enqueue the scripts using foreach loop only for
<code>jquery</code>, <code>jquery-ui-widge</code>t, <code>jquery-UI-accordion</code>, <code>jquery-ui-slider</code>, <code>jquery-ui-tabs</code>, <code>jquery-ui-datepicker</code>, <code>Jquery-ui-dialog</code> and <code>Jquery-ui-button</co... | [
{
"answer_id": 274887,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": true,
"text": "<p>Yes you can. But to make sure the script has not already been registered or enqueued, use <a href=\"https://... | 2017/07/27 | [
"https://wordpress.stackexchange.com/questions/274885",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108146/"
] | It would be a right way to enqueue the scripts using foreach loop only for
`jquery`, `jquery-ui-widge`t, `jquery-UI-accordion`, `jquery-ui-slider`, `jquery-ui-tabs`, `jquery-ui-datepicker`, `Jquery-ui-dialog` and `Jquery-ui-button` because I have to write it many times so
I have make it like this:
```
$jquery_ui =... | Yes you can. But to make sure the script has not already been registered or enqueued, use [`wp_script_is()`](https://codex.wordpress.org/Function_Reference/wp_script_is) as follows:
```
foreach( $jquery_ui as $ui ) {
if( !wp_script_is( $ui ) ) {
wp_enqueue_script( $ui );
}
}
```
This will prevent con... |
274,908 | <p>I have a wordpress site on main.com and a second one on blog.main.com</p>
<p>main.com already had an ssl certificate working.</p>
<p>In cPanel I installed a new wildcard ssl certificate intended for '*.main.com'</p>
<p>(sorry, apparently i don't have enough reputation to post more than 2 links)</p>
<p>At this po... | [
{
"answer_id": 274887,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": true,
"text": "<p>Yes you can. But to make sure the script has not already been registered or enqueued, use <a href=\"https://... | 2017/07/27 | [
"https://wordpress.stackexchange.com/questions/274908",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124714/"
] | I have a wordpress site on main.com and a second one on blog.main.com
main.com already had an ssl certificate working.
In cPanel I installed a new wildcard ssl certificate intended for '\*.main.com'
(sorry, apparently i don't have enough reputation to post more than 2 links)
At this point:
https main.com was conti... | Yes you can. But to make sure the script has not already been registered or enqueued, use [`wp_script_is()`](https://codex.wordpress.org/Function_Reference/wp_script_is) as follows:
```
foreach( $jquery_ui as $ui ) {
if( !wp_script_is( $ui ) ) {
wp_enqueue_script( $ui );
}
}
```
This will prevent con... |
274,941 | <p>Is there a way to set an alias on the meta_query arguments when running a <code>get_posts()</code>? One of my queries is performing poorly. To optimize I just need to be able to reuse the same joined table instead of joining in 3 tables when only one is needed.</p>
<p>My current example...</p>
<pre><code>$args =... | [
{
"answer_id": 274944,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": -1,
"selected": false,
"text": "<p>I'm not really a database guy, but I played one on TV once...</p>\n\n<p>Wouldn't this part</p>\n\n<pr... | 2017/07/27 | [
"https://wordpress.stackexchange.com/questions/274941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28787/"
] | Is there a way to set an alias on the meta\_query arguments when running a `get_posts()`? One of my queries is performing poorly. To optimize I just need to be able to reuse the same joined table instead of joining in 3 tables when only one is needed.
My current example...
```
$args = array(
'meta_query' => array... | You can use the `posts_where` and `posts_join` filters to modify the query. It's not very elegant, but you should be able to mess with these two filters so that your sql is more optimized. It's kind of brute-forcey, but I can't see a better way in the WP\_Query class. That's not saying there isn't though.
```
//* Make... |
274,947 | <p>The AdWords Documentation on how to <a href="https://support.google.com/adwords/answer/6095947?hl=en" rel="nofollow noreferrer">Track transaction-specific conversion values</a> states a PHP code as such:</p>
<pre><code><!-- Google Code for Purchase Conversion Page -->
<script type="text/javascript">
/*... | [
{
"answer_id": 274955,
"author": "Tim Elsass",
"author_id": 80375,
"author_profile": "https://wordpress.stackexchange.com/users/80375",
"pm_score": 1,
"selected": false,
"text": "<p>From the documentation you cited for AdWords: \"When inserting the tag, you'll place it on the static port... | 2017/07/28 | [
"https://wordpress.stackexchange.com/questions/274947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102212/"
] | The AdWords Documentation on how to [Track transaction-specific conversion values](https://support.google.com/adwords/answer/6095947?hl=en) states a PHP code as such:
```
<!-- Google Code for Purchase Conversion Page -->
<script type="text/javascript">
/* < plugin I can give you a few answers to your questions plus some reasons to use a plugin or ours in particular.
Answers to your questions:
1. Your function probably will... |
274,948 | <p>WordPress Devs. I am new to WordPress and Web development. So far WordPress Rest API v2 works well. I was writing a custom API/route/endpoint for my project using the following function. </p>
<pre><code> get_post($postId);
</code></pre>
<p>Here the keys that are return as a response are mainly
<em>ID,
post_author,... | [
{
"answer_id": 274955,
"author": "Tim Elsass",
"author_id": 80375,
"author_profile": "https://wordpress.stackexchange.com/users/80375",
"pm_score": 1,
"selected": false,
"text": "<p>From the documentation you cited for AdWords: \"When inserting the tag, you'll place it on the static port... | 2017/07/28 | [
"https://wordpress.stackexchange.com/questions/274948",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125779/"
] | WordPress Devs. I am new to WordPress and Web development. So far WordPress Rest API v2 works well. I was writing a custom API/route/endpoint for my project using the following function.
```
get_post($postId);
```
Here the keys that are return as a response are mainly
*ID,
post\_author,
post\_date,
post\_date\_gmt... | As the developer of the [WooCommerce AdWords Conversion Tracking](https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/) plugin I can give you a few answers to your questions plus some reasons to use a plugin or ours in particular.
Answers to your questions:
1. Your function probably will... |
274,984 | <p>Wordpress by default already handles the routes to the requested pages but beeing a starter in react and wanting to learn more about it i've found out that you need to create all of your routes. This will extend the app development alot.. What's currently beeing used to overcome this problem?</p>
| [
{
"answer_id": 275014,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 0,
"selected": false,
"text": "<p>You basically have to do it yourself. The REST API is only responsible for returning the data, the fron... | 2017/07/28 | [
"https://wordpress.stackexchange.com/questions/274984",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107897/"
] | Wordpress by default already handles the routes to the requested pages but beeing a starter in react and wanting to learn more about it i've found out that you need to create all of your routes. This will extend the app development alot.. What's currently beeing used to overcome this problem? | You will need to add `react-router-dom` with `npm` or `yarn`. Once you add those, you will need to import some modules into your React app. You will need `BrowserRouter`, `Route`, `NavLink`, & `withRouter`.
`BrowserRouter` is to be on the outmost parent Component that manages the history API. Ideally, you would just ... |
274,986 | <p>I needed to translate strings on another language than the current $locale, so I need to change the locale and restore it later, and I really couldn't repeat all the code for the 30++ strings I had to translate.</p>
<p>So I ended up with this function:</p>
<pre><code>function __2($string, $textdomain, $locale){
... | [
{
"answer_id": 274992,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>No it does not work, people that will need to translate the string will not be able to use the automated ... | 2017/07/28 | [
"https://wordpress.stackexchange.com/questions/274986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10381/"
] | I needed to translate strings on another language than the current $locale, so I need to change the locale and restore it later, and I really couldn't repeat all the code for the 30++ strings I had to translate.
So I ended up with this function:
```
function __2($string, $textdomain, $locale){
global $l10n;
if(is... | The answer is: sometimes. As long as you know what you are doing, there are no problems in terms of bugs. There can be situations where this is possible and safe, and other where it can be necessary or extremely useful.
To complete and share the code above, I add the following:
```
function _e2($string, $textdomain, ... |
274,997 | <p>I am using Woocommerce plugin for my custom product .and I am stuck with a situation .</p>
<p>Does Woo commerce provide any hook or filter when refund is done through admin panel and refund will be manually.<a href="https://i.stack.imgur.com/z8mcA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/z8mcA.png"... | [
{
"answer_id": 296779,
"author": "Tech Dog",
"author_id": 138476,
"author_profile": "https://wordpress.stackexchange.com/users/138476",
"pm_score": 4,
"selected": false,
"text": "<p>Although this answer is little late but anyone else may get benefit from it. The <code>woocommerce_order_... | 2017/07/28 | [
"https://wordpress.stackexchange.com/questions/274997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98958/"
] | I am using Woocommerce plugin for my custom product .and I am stuck with a situation .
Does Woo commerce provide any hook or filter when refund is done through admin panel and refund will be manually.[](https://i.stack.imgur.com/z8mcA.p... | Although this answer is little late but anyone else may get benefit from it. The `woocommerce_order_refunded` hook is called when an order is refunded. Use the following example:
```
// add the action
add_action( 'woocommerce_order_refunded', 'action_woocommerce_order_refunded', 10, 2 );
// Do the magic
function act... |
275,010 | <ol>
<li>On navigation, can a parent-grandchild menu appear? That is, are we able to pick and choose which categories we would like to suppress?</li>
</ol>
<p>Example: if taxonomy shows:
Food>Fruit>Citrus>Oranges>Types of oranges
Can we design the navigation to show:
Fruit>Oranges>Types of oranges</p>
<ol start="... | [
{
"answer_id": 296779,
"author": "Tech Dog",
"author_id": 138476,
"author_profile": "https://wordpress.stackexchange.com/users/138476",
"pm_score": 4,
"selected": false,
"text": "<p>Although this answer is little late but anyone else may get benefit from it. The <code>woocommerce_order_... | 2017/07/28 | [
"https://wordpress.stackexchange.com/questions/275010",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124756/"
] | 1. On navigation, can a parent-grandchild menu appear? That is, are we able to pick and choose which categories we would like to suppress?
Example: if taxonomy shows:
Food>Fruit>Citrus>Oranges>Types of oranges
Can we design the navigation to show:
Fruit>Oranges>Types of oranges
2. How many subcategories are possibl... | Although this answer is little late but anyone else may get benefit from it. The `woocommerce_order_refunded` hook is called when an order is refunded. Use the following example:
```
// add the action
add_action( 'woocommerce_order_refunded', 'action_woocommerce_order_refunded', 10, 2 );
// Do the magic
function act... |
275,018 | <p>In my situation, style.css file has just package information and a comment as: All css files are placed in /css/ folder.</p>
<p>In the css folder, I see a bunch of different styles and I don't exactly know which one controls what! </p>
<p>Any suggestions on overriding the CSS rules from a child theme? </p>
| [
{
"answer_id": 296779,
"author": "Tech Dog",
"author_id": 138476,
"author_profile": "https://wordpress.stackexchange.com/users/138476",
"pm_score": 4,
"selected": false,
"text": "<p>Although this answer is little late but anyone else may get benefit from it. The <code>woocommerce_order_... | 2017/07/28 | [
"https://wordpress.stackexchange.com/questions/275018",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124648/"
] | In my situation, style.css file has just package information and a comment as: All css files are placed in /css/ folder.
In the css folder, I see a bunch of different styles and I don't exactly know which one controls what!
Any suggestions on overriding the CSS rules from a child theme? | Although this answer is little late but anyone else may get benefit from it. The `woocommerce_order_refunded` hook is called when an order is refunded. Use the following example:
```
// add the action
add_action( 'woocommerce_order_refunded', 'action_woocommerce_order_refunded', 10, 2 );
// Do the magic
function act... |
275,023 | <p>I have made a plugin that uses a CPT and a few metadatas. The plugin comes in two versions A and B.</p>
<p>Version A has one post meta less then version B called 'score'.
When users update the plugin from A to B I need the score meta to be created for all custom posts for version B to work properly.</p>
<p>This is... | [
{
"answer_id": 275025,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 0,
"selected": false,
"text": "<p>You only want to <code>INSERT</code> for posts, that do not have this postmeta yet. So you need to change your... | 2017/07/28 | [
"https://wordpress.stackexchange.com/questions/275023",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124757/"
] | I have made a plugin that uses a CPT and a few metadatas. The plugin comes in two versions A and B.
Version A has one post meta less then version B called 'score'.
When users update the plugin from A to B I need the score meta to be created for all custom posts for version B to work properly.
This is the insert query... | To anyone interested this is the query that worked for me:
```
INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value)
SELECT p.ID, 'score' AS meta_key, 0 AS meta_value
FROM $wpdb->posts AS p
WHERE p.post_type = 'my_cpt'
AND p.ID NOT IN (
SELECT p2.ID
FROM $wpdb->posts AS p2
INNER JOIN $wpdb->postmeta A... |
275,030 | <p>My theme has a top menu bar with accessibility shortcuts (jump to content, high contrast mode, etc). I need to include a link to an informational page describing the accessibility features available to visitors.</p>
<p>This is a project for an University multisite network, with a lot of hosted sites, so I need a so... | [
{
"answer_id": 275044,
"author": "Dub Scrib",
"author_id": 75797,
"author_profile": "https://wordpress.stackexchange.com/users/75797",
"pm_score": 0,
"selected": false,
"text": "<p>If a plugin would work - see the WP Accessibility plugin. In Settings, 'Add Skiplinks' section, there's an ... | 2017/07/28 | [
"https://wordpress.stackexchange.com/questions/275030",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68849/"
] | My theme has a top menu bar with accessibility shortcuts (jump to content, high contrast mode, etc). I need to include a link to an informational page describing the accessibility features available to visitors.
This is a project for an University multisite network, with a lot of hosted sites, so I need a solution tha... | I am assuming the following setup from reading your question:
site.network.com
site-2.network.com
site-3.network.com
where the main site exists on network.com (i.e. blog id `1`).
All sites (or at least all subdomain sites) share the same theme.
You need to be able to create a single content page and have that co... |
275,038 | <p>After migrating subdomain to new domain, not sure if the subdomain got left over in any of the settings.</p>
<p>Where in PHPmyAdmin / SQL database should I find those subdomain urls and update them to the new one?</p>
<p>(not even sure if my question makes sense).</p>
<p>Any help will appreciated</p>
| [
{
"answer_id": 275044,
"author": "Dub Scrib",
"author_id": 75797,
"author_profile": "https://wordpress.stackexchange.com/users/75797",
"pm_score": 0,
"selected": false,
"text": "<p>If a plugin would work - see the WP Accessibility plugin. In Settings, 'Add Skiplinks' section, there's an ... | 2017/07/28 | [
"https://wordpress.stackexchange.com/questions/275038",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124762/"
] | After migrating subdomain to new domain, not sure if the subdomain got left over in any of the settings.
Where in PHPmyAdmin / SQL database should I find those subdomain urls and update them to the new one?
(not even sure if my question makes sense).
Any help will appreciated | I am assuming the following setup from reading your question:
site.network.com
site-2.network.com
site-3.network.com
where the main site exists on network.com (i.e. blog id `1`).
All sites (or at least all subdomain sites) share the same theme.
You need to be able to create a single content page and have that co... |
275,112 | <pre><code><button name="button" style="margin: 20px 0 0 796px;padding: 3px 25px; background-color: red;color: white;font-weight: bold;" value="OK" type="button" >HAVE A QUESTIONS</button>
</code></pre>
<p>i make a button in my custom template page(header.php) but its display also my home page but i want... | [
{
"answer_id": 275116,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 1,
"selected": false,
"text": "<p>It's as simple as doing a conditional and check if you are on home.</p>\n\n<p>What you are looking for is <... | 2017/07/29 | [
"https://wordpress.stackexchange.com/questions/275112",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124815/"
] | ```
<button name="button" style="margin: 20px 0 0 796px;padding: 3px 25px; background-color: red;color: white;font-weight: bold;" value="OK" type="button" >HAVE A QUESTIONS</button>
```
i make a button in my custom template page(header.php) but its display also my home page but i want to display only my custom temp... | It's as simple as doing a conditional and check if you are on home.
What you are looking for is `is_page_template( );`. Wrap your button inside it as follows:
```
<?php if( is_page_template( 'your-template-slug.php' ) ){ ?>
<button name="button" style=" ... " value="OK" type="button">HAVE A QUESTIONS</button>
<?p... |
275,120 | <p>I am trying to learn meta's in Wordpress by taking an example of the already existing meta →</p>
<pre><code>function cpmb_display_meta_box( $post ) {
// Define the nonce for security purposes
wp_nonce_field( plugin_basename( __FILE__ ), 'cpmb-nonce-field' );
// Start the HTML string so that all other strings can ... | [
{
"answer_id": 275122,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>The above function is the function to render the markup in the backend?</p>\n</blockquo... | 2017/07/29 | [
"https://wordpress.stackexchange.com/questions/275120",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105791/"
] | I am trying to learn meta's in Wordpress by taking an example of the already existing meta →
```
function cpmb_display_meta_box( $post ) {
// Define the nonce for security purposes
wp_nonce_field( plugin_basename( __FILE__ ), 'cpmb-nonce-field' );
// Start the HTML string so that all other strings can be concatenate... | Post's metadata can not and should not be used for validation. They can be easily manipulated. Post metadata simply stores *"editable"* strings or arrays, nothing more than that.
The code you have copied is trying to fetch a metadata and check if its value is `mp3`. You can change a value of `exe` to `mp3`, and it wil... |
275,128 | <p>I make a site of poetry. I would like to be able to display my text line by line (max 5) while it puts everything continuously.</p>
<blockquote>
<p>Search result:<br> Line 1<br> Line 2<br> Line 3<br> Line 4<br> Line 5</p>
</blockquote>
<p>On my excerpt I get this:<br>
Line 1 Line 2 Line 3 Line 4 Line 5</p>
<p>C... | [
{
"answer_id": 275147,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>An alternative way to look at the issue is that the excerpt is right and the way your post is being displ... | 2017/07/29 | [
"https://wordpress.stackexchange.com/questions/275128",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124824/"
] | I make a site of poetry. I would like to be able to display my text line by line (max 5) while it puts everything continuously.
>
> Search result:
> Line 1
> Line 2
> Line 3
> Line 4
> Line 5
>
>
>
On my excerpt I get this:
Line 1 Line 2 Line 3 Line 4 Line 5
Can you give me a track to follow?
... | If you type your poets like this in the editor and separate them by new lines:
>
> This is a phrase
>
>
> This is another phrase
>
>
>
Then you can divide them by new line, and then return them to the front-end. You can do this by using the `get_the_excerpt` filter. This goes in your theme's `functions.php` fil... |
275,152 | <p>I have a shordcode for Contact Form 7 form. I want use Advanced Custom Fields for ID value. How Can I do that?</p>
<p>the ACF with ID value:</p>
<pre><code>the_field('form');
</code></pre>
<p>shordcode:</p>
<pre><code><?php echo do_shortcode( '[contact-form-7 id="29"]' ); ?>
</code></pre>
<p>Any solution?... | [
{
"answer_id": 275155,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": true,
"text": "<p>Simple as this:</p>\n\n<pre><code><?php echo do_shortcode( '[contact-form-7 id=\"'.get_field('form').'\"]... | 2017/07/29 | [
"https://wordpress.stackexchange.com/questions/275152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116847/"
] | I have a shordcode for Contact Form 7 form. I want use Advanced Custom Fields for ID value. How Can I do that?
the ACF with ID value:
```
the_field('form');
```
shordcode:
```
<?php echo do_shortcode( '[contact-form-7 id="29"]' ); ?>
```
Any solution? :) | Simple as this:
```
<?php echo do_shortcode( '[contact-form-7 id="'.get_field('form').'"]' ); ?>
```
You have to notice, you should use `get_field()` to return the value. `the_field()` will echo it. |
275,205 | <p>I'm new to developing with WordPress. I read <a href="https://tommcfarlin.com/sending-data-post/" rel="nofollow noreferrer">here</a> that a good way to process data posted from forms is to insert an action on the init function like so:</p>
<pre><code>add_action( 'init', 'contact_form_send_email' );
</code></pre>
<... | [
{
"answer_id": 275224,
"author": "hwl",
"author_id": 118366,
"author_profile": "https://wordpress.stackexchange.com/users/118366",
"pm_score": 3,
"selected": true,
"text": "<p>The difference between <code>add_action()</code> and <code>add_filter()</code> is semantic not technical, except... | 2017/07/30 | [
"https://wordpress.stackexchange.com/questions/275205",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122408/"
] | I'm new to developing with WordPress. I read [here](https://tommcfarlin.com/sending-data-post/) that a good way to process data posted from forms is to insert an action on the init function like so:
```
add_action( 'init', 'contact_form_send_email' );
```
My function seems to be processing the data correctly, but I ... | The difference between `add_action()` and `add_filter()` is semantic not technical, except that a filter expects a returned value and an action does/will not.
The question is whether `contact_form_send_email()` **needs** to be called-at /hooked-to `init`.
If not, you can define your filter in the template with `apply_... |
275,218 | <p>i use wp-rest-api v2 plugin. Custom post types doesnt show taxonomy. somebody can tell me whats wrong?</p>
<p>URL: /wp-json/wp/v2/galeri?_embed</p>
<pre><code>{
"id": 275,
"date": "2016-05-07T23:53:17",
"date_gmt": "2016-05-07T20:53:17",
"guid": {
"rendered": "http:\/\/demo.markamiz.com\/?post_type=galeri&... | [
{
"answer_id": 275224,
"author": "hwl",
"author_id": 118366,
"author_profile": "https://wordpress.stackexchange.com/users/118366",
"pm_score": 3,
"selected": true,
"text": "<p>The difference between <code>add_action()</code> and <code>add_filter()</code> is semantic not technical, except... | 2017/07/30 | [
"https://wordpress.stackexchange.com/questions/275218",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93283/"
] | i use wp-rest-api v2 plugin. Custom post types doesnt show taxonomy. somebody can tell me whats wrong?
URL: /wp-json/wp/v2/galeri?\_embed
```
{
"id": 275,
"date": "2016-05-07T23:53:17",
"date_gmt": "2016-05-07T20:53:17",
"guid": {
"rendered": "http:\/\/demo.markamiz.com\/?post_type=galeri&p=275"
},
"modified... | The difference between `add_action()` and `add_filter()` is semantic not technical, except that a filter expects a returned value and an action does/will not.
The question is whether `contact_form_send_email()` **needs** to be called-at /hooked-to `init`.
If not, you can define your filter in the template with `apply_... |
275,263 | <p>I'm making an ajax request from my primary domain to a subdomain. I've solved my cross origin issues so I'm not getting an error. The call is returning <code>data:0</code>. I've checked my response config and the ajax url is correct as well as "action". My <code>functions.php</code> looks like this:</p>
<pre><code>... | [
{
"answer_id": 275264,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>If you want to use Admin-Ajax to output the content, you should use <code>echo</code> instead. There is not... | 2017/07/31 | [
"https://wordpress.stackexchange.com/questions/275263",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8278/"
] | I'm making an ajax request from my primary domain to a subdomain. I've solved my cross origin issues so I'm not getting an error. The call is returning `data:0`. I've checked my response config and the ajax url is correct as well as "action". My `functions.php` looks like this:
```
add_action("wp_ajax_sendhire", "send... | If you want to use Admin-Ajax to output the content, you should use `echo` instead. There is nothing to be viewed when you use `return`, so you'll get a `0`.
This quotation from the codex explains further about the `0` response:
>
> If the Ajax request fails in `wp-admin/admin-ajax.php`, the response
> will be -1 o... |
275,301 | <p>I followed the instructions given in this <a href="https://getflywheel.com/layout/how-to-create-custom-meta-boxes-with-cmb2/" rel="nofollow noreferrer">blog</a> to set the CMB2 plugin, but it is not working in my case.</p>
<p>theme-meta-function.php →</p>
<pre><code> <?php
/**
* Include and set up custom me... | [
{
"answer_id": 275303,
"author": "Nuno Sarmento",
"author_id": 75461,
"author_profile": "https://wordpress.stackexchange.com/users/75461",
"pm_score": 1,
"selected": false,
"text": "<p>Change <code>$prefix = '_yourprefix_';</code> to <code>$prefix = '_wp';</code></p>\n\n<p>or add the c... | 2017/07/31 | [
"https://wordpress.stackexchange.com/questions/275301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105791/"
] | I followed the instructions given in this [blog](https://getflywheel.com/layout/how-to-create-custom-meta-boxes-with-cmb2/) to set the CMB2 plugin, but it is not working in my case.
theme-meta-function.php →
```
<?php
/**
* Include and set up custom metaboxes and fields. (Make sure you copy this file outside the... | the solution →
```
'object_types' => array( 'page', ), // Post type
'show_on' => array( 'id' => array( 10, ) ), // Specific post IDs to display this metabox
```
the above was the reason why it was not working on a post.
I just added post and added it here →
```
'object_types' => array( 'page', ), //... |
275,305 | <p>For some of my larger WordPress sites, I would like to avoid having to copy all the media files from the live site to the development site, but instead point the development site to use the media files from the live site.</p>
<p>On Drupal there is a great module for this called Stage File Proxy: <a href="https://ww... | [
{
"answer_id": 275303,
"author": "Nuno Sarmento",
"author_id": 75461,
"author_profile": "https://wordpress.stackexchange.com/users/75461",
"pm_score": 1,
"selected": false,
"text": "<p>Change <code>$prefix = '_yourprefix_';</code> to <code>$prefix = '_wp';</code></p>\n\n<p>or add the c... | 2017/07/31 | [
"https://wordpress.stackexchange.com/questions/275305",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85504/"
] | For some of my larger WordPress sites, I would like to avoid having to copy all the media files from the live site to the development site, but instead point the development site to use the media files from the live site.
On Drupal there is a great module for this called Stage File Proxy: <https://www.drupal.org/proje... | the solution →
```
'object_types' => array( 'page', ), // Post type
'show_on' => array( 'id' => array( 10, ) ), // Specific post IDs to display this metabox
```
the above was the reason why it was not working on a post.
I just added post and added it here →
```
'object_types' => array( 'page', ), //... |
275,310 | <p>i tried to create a simple function to receive a email when a specify user is logged, i tried with $current_user->ID and also with wp_get_current_user() but not working. This is my code:</p>
<pre><code>function InvioMail() {
global $current_user;
$ID = $current_user->ID;
$user = wp_get_current_user()... | [
{
"answer_id": 275315,
"author": "Nuno Sarmento",
"author_id": 75461,
"author_profile": "https://wordpress.stackexchange.com/users/75461",
"pm_score": 0,
"selected": false,
"text": "<p>Try the code below. </p>\n\n<pre><code>function InvioMail() {\n global $current_user;\n\n if ($curren... | 2017/07/31 | [
"https://wordpress.stackexchange.com/questions/275310",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124940/"
] | i tried to create a simple function to receive a email when a specify user is logged, i tried with $current\_user->ID and also with wp\_get\_current\_user() but not working. This is my code:
```
function InvioMail() {
global $current_user;
$ID = $current_user->ID;
$user = wp_get_current_user();
$name = $... | This should work for you, make sure that the `user_login` or `user_id` matches to the string you're using in the condition. Try to do a `var_dump($user_login);`
And about the function you're using, you don't need to grab the `global` or call `get_current_user();`, because the action you're calling already pass two par... |
275,367 | <p>I am trying to create a form for customers to fill out after they have purchased a subscription and/or when they return to the site and log in. My site has multiple subscription products and I need the form to be conditional based on which product they chose. To see whether they have an active subscription I am usin... | [
{
"answer_id": 313071,
"author": "Aliiiiiiii",
"author_id": 132815,
"author_profile": "https://wordpress.stackexchange.com/users/132815",
"pm_score": 2,
"selected": false,
"text": "<p>Using the Id of a subscription you can get the subscription object :</p>\n\n<pre><code>$subscription_obj... | 2017/07/31 | [
"https://wordpress.stackexchange.com/questions/275367",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124972/"
] | I am trying to create a form for customers to fill out after they have purchased a subscription and/or when they return to the site and log in. My site has multiple subscription products and I need the form to be conditional based on which product they chose. To see whether they have an active subscription I am using t... | Using the Id of a subscription you can get the subscription object :
```
$subscription_obj = wcs_get_subscription($sub_id);
```
wcs\_get\_subscription is a wrapper for the wc\_get\_order() method
Then get items of your subscription :
```
$items = $subscription_obj ->get_items();
``` |
275,370 | <p>I'm trying to develop a theme. but "Display Site Title and Tagline" checkbox not working nothing change when i check or uncheck the site tile and tagline still exist. also the color option not giving any effect?
please help my code for the header text is:</p>
<pre><code><header class="image-bg-fluid-height" id... | [
{
"answer_id": 281513,
"author": "IBRAHIM EZZAT",
"author_id": 120259,
"author_profile": "https://wordpress.stackexchange.com/users/120259",
"pm_score": 3,
"selected": true,
"text": "<p>this peace of code will help you </p>\n\n<pre><code> <?php\n if (display_header_t... | 2017/07/31 | [
"https://wordpress.stackexchange.com/questions/275370",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124857/"
] | I'm trying to develop a theme. but "Display Site Title and Tagline" checkbox not working nothing change when i check or uncheck the site tile and tagline still exist. also the color option not giving any effect?
please help my code for the header text is:
```
<header class="image-bg-fluid-height" id="startchange" styl... | this peace of code will help you
```
<?php
if (display_header_text()==true){
echo '<h1>'.get_bloginfo( 'name' ) .'</h1>';
echo '<h2>'.get_bloginfo('description').'</h2>';
} else{
//do something
}
... |
275,391 | <p>I'm very new to word press having only installed it on the weekend, I'm fine with HTML & CSS but PHP & Wordpress is alien to me.</p>
<p>I'm trying to display a post from a specific category that changes every day, i've searched everywhere and found the below code whihc works to a point.</p>
<p>I just cant ... | [
{
"answer_id": 275394,
"author": "giolliano sulit",
"author_id": 65984,
"author_profile": "https://wordpress.stackexchange.com/users/65984",
"pm_score": 1,
"selected": false,
"text": "<p>You can change your <code>get_posts $args</code></p>\n\n<p>Example:</p>\n\n<pre><code>$args = array(\... | 2017/08/01 | [
"https://wordpress.stackexchange.com/questions/275391",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124991/"
] | I'm very new to word press having only installed it on the weekend, I'm fine with HTML & CSS but PHP & Wordpress is alien to me.
I'm trying to display a post from a specific category that changes every day, i've searched everywhere and found the below code whihc works to a point.
I just cant seem to get it to choose ... | You can change your `get_posts $args`
Example:
```
$args = array(
'orderby' => 'rand',
'category_name' => 'your_category',
'showposts' => 1
);
``` |
275,424 | <pre><code> <?php
foreach($getPostCustom as $name=>$value) {
echo "<strong>".$name."</strong>"." => ";
foreach($value as $nameAr=>$valueAr) {
echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo $nameAr." =&g... | [
{
"answer_id": 275430,
"author": "Cesar Henrique Damascena",
"author_id": 109804,
"author_profile": "https://wordpress.stackexchange.com/users/109804",
"pm_score": 0,
"selected": false,
"text": "<p>If you're in the <code>single_{$post_type_slug}</code> template . you can do this way:</p>... | 2017/08/01 | [
"https://wordpress.stackexchange.com/questions/275424",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97802/"
] | ```
<?php
foreach($getPostCustom as $name=>$value) {
echo "<strong>".$name."</strong>"." => ";
foreach($value as $nameAr=>$valueAr) {
echo "<br /> ";
echo $nameAr." => ";
echo var_dump($valueAr);
}
... | ```
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8 left_column"> <?php
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<h1> <?php the_title();?> </h1> <?php
$post_meta = get_post_meta(get_the_ID());
foreach($post_meta as $key=>$value)
{
echo ... |
275,439 | <p>Thanks in advance for all your help! </p>
<p>I want to display posts (tours) that are in a specific location (city) so in my location_taxonomy.php I have a taxonomy query in the form of:</p>
<pre><code>$args = array(
'post_type' => 'tour',
'meta_key' => 'trav_tour_city',
'meta_value' ... | [
{
"answer_id": 275430,
"author": "Cesar Henrique Damascena",
"author_id": 109804,
"author_profile": "https://wordpress.stackexchange.com/users/109804",
"pm_score": 0,
"selected": false,
"text": "<p>If you're in the <code>single_{$post_type_slug}</code> template . you can do this way:</p>... | 2017/08/01 | [
"https://wordpress.stackexchange.com/questions/275439",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125022/"
] | Thanks in advance for all your help!
I want to display posts (tours) that are in a specific location (city) so in my location\_taxonomy.php I have a taxonomy query in the form of:
```
$args = array(
'post_type' => 'tour',
'meta_key' => 'trav_tour_city',
'meta_value' => $term->term_id, //city ... | ```
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8 left_column"> <?php
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<h1> <?php the_title();?> </h1> <?php
$post_meta = get_post_meta(get_the_ID());
foreach($post_meta as $key=>$value)
{
echo ... |
275,445 | <p>I am using <a href="https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/" rel="nofollow noreferrer">this plugin</a> to create custom fields and custom post-types. I am able to create repeater custom fields in the following format.</p>
<pre><code>1 Dummy Name1 Location1
2 ... | [
{
"answer_id": 275460,
"author": "mrben522",
"author_id": 84703,
"author_profile": "https://wordpress.stackexchange.com/users/84703",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know about that plugin but I know you could easily do that with <a href=\"https://www.advancedcustom... | 2017/08/01 | [
"https://wordpress.stackexchange.com/questions/275445",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99340/"
] | I am using [this plugin](https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/) to create custom fields and custom post-types. I am able to create repeater custom fields in the following format.
```
1 Dummy Name1 Location1
2 Dummy Name2 Location2
..... and so on
```
T... | I don't know about that plugin but I know you could easily do that with [ACF](https://www.advancedcustomfields.com/) repeater fields
<https://www.advancedcustomfields.com/resources/repeater/> |
275,485 | <p>I am trying to use ACF Pro Select field to display a specify social media icons. So I have this code in my theme:</p>
<pre><code><?php if( get_field('social_medias', 'option') == 'facebook' ): ?>
<li>
<a href="#">
<svg viewbox="0 0 6.5 14" xmlns="h... | [
{
"answer_id": 275486,
"author": "Nuuu",
"author_id": 124591,
"author_profile": "https://wordpress.stackexchange.com/users/124591",
"pm_score": 1,
"selected": false,
"text": "<p>I would do this instead:</p>\n\n<pre><code> <?php\n if( have_rows('social_medias', 'option') ):\n ... | 2017/08/01 | [
"https://wordpress.stackexchange.com/questions/275485",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116847/"
] | I am trying to use ACF Pro Select field to display a specify social media icons. So I have this code in my theme:
```
<?php if( get_field('social_medias', 'option') == 'facebook' ): ?>
<li>
<a href="#">
<svg viewbox="0 0 6.5 14" xmlns="http://www.w3.org/2000/svg">
... | You can loop through your ACF options by using the code below.
```
<?php if( have_rows('social_medias', 'option') ):
while ( have_rows('social_medias', 'option') ) : the_row();
$type = get_sub_field('type'); ?>
<?php if ($type == "facebook") { ?>
<li>
<a hr... |
275,491 | <p>please help me: I need to get the parent of the current page, in other words: to get the parent of $direct_parent.Thanks!</p>
<pre><code><?php
global $post;
$direct_parent = $post->post_parent;
$parent = $direct_parent->post_parent;
wp_list_pages( array(
'child_of' => $parent,
'titl... | [
{
"answer_id": 275492,
"author": "Sabbir Hasan",
"author_id": 76587,
"author_profile": "https://wordpress.stackexchange.com/users/76587",
"pm_score": 2,
"selected": false,
"text": "<p>Try using <strong>get_post_ancestors</strong>. Here is how you can apply this in your case:</p>\n\n<pre>... | 2017/08/01 | [
"https://wordpress.stackexchange.com/questions/275491",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125046/"
] | please help me: I need to get the parent of the current page, in other words: to get the parent of $direct\_parent.Thanks!
```
<?php
global $post;
$direct_parent = $post->post_parent;
$parent = $direct_parent->post_parent;
wp_list_pages( array(
'child_of' => $parent,
'title_li' => false,
'... | Try using **get\_post\_ancestors**. Here is how you can apply this in your case:
```
<?php
global $wp_query;
$post = $wp_query->post;
$ancestors = get_post_ancestors($post);
if( empty($post->post_parent) ) {
$parent = $post->ID;
} else {
$parent = end($ancestors);
}
if(wp_l... |