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 |
|---|---|---|---|---|---|---|
259,657 | <p>I'm building a plugin using the <a href="https://github.com/DevinVinson/WordPress-Plugin-Boilerplate" rel="nofollow noreferrer">WordPress Plugin Boilerplate by DevinVinson</a>.</p>
<p>Everything works fine, except one thing:</p>
<p>I'm trying to enqueue scripts and css only when a shortcode is present in the page.... | [
{
"answer_id": 259662,
"author": "nibnut",
"author_id": 111316,
"author_profile": "https://wordpress.stackexchange.com/users/111316",
"pm_score": 0,
"selected": false,
"text": "<p>So the problem is that the first argument to the <code>add_action</code> call needs to be a <em>WordPress</e... | 2017/03/10 | [
"https://wordpress.stackexchange.com/questions/259657",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4155/"
] | I'm building a plugin using the [WordPress Plugin Boilerplate by DevinVinson](https://github.com/DevinVinson/WordPress-Plugin-Boilerplate).
Everything works fine, except one thing:
I'm trying to enqueue scripts and css only when a shortcode is present in the page.
In `define_public_hooks` function, I added a call t... | Why it's not working:
=====================
You need to use the [`wp_enqueue_scripts`](https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/) action hook. You've used `wp_register_script` as an action hook, however, there is no action hook named `wp_register_script` in WordPress core.
If this was just a... |
259,677 | <p>I am a WP beginner and am trying to upload a web module to a wordpress site. The site is a landing page, and a link on the landing page leads to a demoable web app. The web app was custom written in HTML and JS and I need to upload those files to this route in the WP site.</p>
<p>Does anyone have any suggestions/... | [
{
"answer_id": 259684,
"author": "Ben Casey",
"author_id": 114997,
"author_profile": "https://wordpress.stackexchange.com/users/114997",
"pm_score": 0,
"selected": false,
"text": "<p>Welcome to WordPress!</p>\n\n<p>Your best bet would be to setup a localhost server <a href=\"http://www.w... | 2017/03/11 | [
"https://wordpress.stackexchange.com/questions/259677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115201/"
] | I am a WP beginner and am trying to upload a web module to a wordpress site. The site is a landing page, and a link on the landing page leads to a demoable web app. The web app was custom written in HTML and JS and I need to upload those files to this route in the WP site.
Does anyone have any suggestions/insight/advi... | All you need to do is create a custom page for your theme. Here is a very brief example:
Create a file called: page-example.php
```
<?php
/*
Template Name: Example Page
*/
?>
<?php get_header(); ?>
The html code will go here. Don't add the <head> or <body> info.
<?php get_footer(); ?>
```
The next thing to ... |
259,707 | <p>I want to add image from post content in my rss feed but all the tutorials that I find are only for featured image. I want image from post content and not featured image. How can I do this?</p>
| [
{
"answer_id": 259708,
"author": "shpwebhost",
"author_id": 114992,
"author_profile": "https://wordpress.stackexchange.com/users/114992",
"pm_score": -1,
"selected": false,
"text": "<p>If you want to use content images on other website or pages you may use WordPress REST API. This will h... | 2017/03/11 | [
"https://wordpress.stackexchange.com/questions/259707",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/100682/"
] | I want to add image from post content in my rss feed but all the tutorials that I find are only for featured image. I want image from post content and not featured image. How can I do this? | Here is the [link](http://wpcodesnippet.com/display-featured-post-thumbnails-wordpress-feeds/) I found a solution. How to display featured post thumbnails in WordPress feeds
paste this code snippet in your theme functions.php file
```
// display featured post thumbnails in WordPress feeds
function wcs_post_thumbn... |
259,713 | <p>As everyone might be aware that there are many wordpress website builders in the market, Can anyone explain me whats the real difference between Theme Builders and Page Builders? I looked up in google but couldn't find the answer to it.</p>
| [
{
"answer_id": 259708,
"author": "shpwebhost",
"author_id": 114992,
"author_profile": "https://wordpress.stackexchange.com/users/114992",
"pm_score": -1,
"selected": false,
"text": "<p>If you want to use content images on other website or pages you may use WordPress REST API. This will h... | 2017/03/11 | [
"https://wordpress.stackexchange.com/questions/259713",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115217/"
] | As everyone might be aware that there are many wordpress website builders in the market, Can anyone explain me whats the real difference between Theme Builders and Page Builders? I looked up in google but couldn't find the answer to it. | Here is the [link](http://wpcodesnippet.com/display-featured-post-thumbnails-wordpress-feeds/) I found a solution. How to display featured post thumbnails in WordPress feeds
paste this code snippet in your theme functions.php file
```
// display featured post thumbnails in WordPress feeds
function wcs_post_thumbn... |
259,716 | <p>When I call <a href="https://developer.wordpress.org/reference/functions/get_search_form" rel="nofollow noreferrer"><code>get_search_form()</code></a>, it outputs:</p>
<pre><code><form class="search-form">
<meta itemprop="target">
<input type="search">
<input type="submit">
</form&g... | [
{
"answer_id": 259717,
"author": "Faysal Mahamud",
"author_id": 83752,
"author_profile": "https://wordpress.stackexchange.com/users/83752",
"pm_score": 2,
"selected": false,
"text": "<p>Tested and worked fine.</p>\n\n<p>Add this code in functions.php, You will get what you want. Now you ... | 2017/03/11 | [
"https://wordpress.stackexchange.com/questions/259716",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115077/"
] | When I call [`get_search_form()`](https://developer.wordpress.org/reference/functions/get_search_form), it outputs:
```
<form class="search-form">
<meta itemprop="target">
<input type="search">
<input type="submit">
</form>
```
But I wanted it to generate with a `span` inside, like:
```
<form class="search-fo... | If we look at the source code of [`get_search_form()`](https://developer.wordpress.org/reference/functions/get_search_form/), notice that before the form gets rendered, the `search_form_format` filter hook gets fired. We can use that to add another filter attached to `get_search_form` where the callback is dependent up... |
259,811 | <p>I have recently setup a Linode Apache2 Debian server and I am hosting my WordPress site on it. It seems I can only connect to the server with SFTP.</p>
<p>When I attempt to add/update a plugin I am presented with this screen:</p>
<p><a href="https://i.stack.imgur.com/oSyRL.png" rel="nofollow noreferrer"><img src="... | [
{
"answer_id": 259857,
"author": "geraldo",
"author_id": 38096,
"author_profile": "https://wordpress.stackexchange.com/users/38096",
"pm_score": 1,
"selected": false,
"text": "<p>I use <a href=\"https://wordpress.org/plugins/ssh-sftp-updater-support/\" rel=\"nofollow noreferrer\">SSH SFT... | 2017/03/12 | [
"https://wordpress.stackexchange.com/questions/259811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86794/"
] | I have recently setup a Linode Apache2 Debian server and I am hosting my WordPress site on it. It seems I can only connect to the server with SFTP.
When I attempt to add/update a plugin I am presented with this screen:
[](https://i.stack.imgur.com/oS... | Looks like a permissions issue:
```
sudo chown -R www-data:www-data /var/www
``` |
259,834 | <p>I've followed all the steps for migrating my existing wordpress site to another server. However, when I try to login to the migrated site, it keeps redirecting me to the old one, despite whether I use wp-admin.php or wp-login.php.</p>
<p>I have also read about a dozen different pages on migrating worpress accounts,... | [
{
"answer_id": 259836,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 1,
"selected": false,
"text": "<p>First make sure that your wp-config file you've got is connected to the right database.</p>\n\n<p>You need to ... | 2017/03/13 | [
"https://wordpress.stackexchange.com/questions/259834",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115295/"
] | I've followed all the steps for migrating my existing wordpress site to another server. However, when I try to login to the migrated site, it keeps redirecting me to the old one, despite whether I use wp-admin.php or wp-login.php.
I have also read about a dozen different pages on migrating worpress accounts, but not o... | Try to add the following two lines in `wp-config.php` file:
```
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
``` |
259,839 | <p>I decided to integrate several standalone WordPress websites into a single Multisite installation.</p>
<p>I created a brand new Multisite install with subdomains, created a MU network site with subdomain URL, and exported the content from the original standalone site, then imported that content into the subdomain MU... | [
{
"answer_id": 260295,
"author": "Dean Jansen",
"author_id": 114897,
"author_profile": "https://wordpress.stackexchange.com/users/114897",
"pm_score": -1,
"selected": false,
"text": "<p>Please try adding the following to your wp-config.php file</p>\n\n<p>Also remove all cookies from your... | 2017/03/13 | [
"https://wordpress.stackexchange.com/questions/259839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | I decided to integrate several standalone WordPress websites into a single Multisite installation.
I created a brand new Multisite install with subdomains, created a MU network site with subdomain URL, and exported the content from the original standalone site, then imported that content into the subdomain MU site. I ... | First clear your browser's cache (including cookies), and your server's cache (e.g. cache plugins). Then set the following in your `wp-config.php` file:
```
define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');
```
Also, you may checkout the [answer fr... |
259,849 | <p>I try to order a WP_Query of a custom post type 'entry' by a meta value 'votes', but it keeps showing up ordered by date.
My code:</p>
<pre><code>$args = array(
'post_type' => 'entry',
'orderby' => 'votes',
'order' => 'DESC',
'posts_per_page' => 10,
'post_status'... | [
{
"answer_id": 259851,
"author": "dhuyvetter",
"author_id": 86095,
"author_profile": "https://wordpress.stackexchange.com/users/86095",
"pm_score": 2,
"selected": false,
"text": "<p>OK, I figured it pour reading about <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query#Order_.... | 2017/03/13 | [
"https://wordpress.stackexchange.com/questions/259849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86095/"
] | I try to order a WP\_Query of a custom post type 'entry' by a meta value 'votes', but it keeps showing up ordered by date.
My code:
```
$args = array(
'post_type' => 'entry',
'orderby' => 'votes',
'order' => 'DESC',
'posts_per_page' => 10,
'post_status' => 'publish'
);
$loo... | OK, I figured it pour reading about [Orderby Parameters in WP\_Query](https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters) more carefully. I needed to set `votes` to `meta_key` and `orderby` to `meta_value_num`:
```
$args = array(
'post_type' => 'entry',
'meta_key' => 'vot... |
259,883 | <p>I would like to overwrite some content which is located in (<code>inc/</code>) <code>template-tags.php</code> file on parent theme.</p>
<p>Content need to be changed is in function <code>footer_content_widget_area</code> in <code>template-tags.php</code> file and that function is called on <code>functions.php</code... | [
{
"answer_id": 260054,
"author": "Justin",
"author_id": 114945,
"author_profile": "https://wordpress.stackexchange.com/users/114945",
"pm_score": -1,
"selected": false,
"text": "<p>As long as you have a child-theme setup correctly then you just allow the child-theme to replace the parent... | 2017/03/13 | [
"https://wordpress.stackexchange.com/questions/259883",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92020/"
] | I would like to overwrite some content which is located in (`inc/`) `template-tags.php` file on parent theme.
Content need to be changed is in function `footer_content_widget_area` in `template-tags.php` file and that function is called on `functions.php`:
```
add_action( 'page_widgets', 'footer_content_widget_area' ... | In `functions.php` child theme include `template-tags.php` from parent theme:
```
require_once get_theme_file_path( '../parent-theme/inc/template-tags.php' );
```
In the child theme `template-tags.php` remove parent action and add the child action replacing it:
```
remove_action( 'tag', 'parent-function', 0 );
add... |
259,936 | <p>Having practised mirroring an existing wordpress site, I'm ready to migrate my website to a new server. Having simplified the steps necessary to do this, I'm hoping the following will work without having to change any database entries or Wordpress files. The domain name will stay the same, only the host will change.... | [
{
"answer_id": 260054,
"author": "Justin",
"author_id": 114945,
"author_profile": "https://wordpress.stackexchange.com/users/114945",
"pm_score": -1,
"selected": false,
"text": "<p>As long as you have a child-theme setup correctly then you just allow the child-theme to replace the parent... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/259936",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115295/"
] | Having practised mirroring an existing wordpress site, I'm ready to migrate my website to a new server. Having simplified the steps necessary to do this, I'm hoping the following will work without having to change any database entries or Wordpress files. The domain name will stay the same, only the host will change.
1... | In `functions.php` child theme include `template-tags.php` from parent theme:
```
require_once get_theme_file_path( '../parent-theme/inc/template-tags.php' );
```
In the child theme `template-tags.php` remove parent action and add the child action replacing it:
```
remove_action( 'tag', 'parent-function', 0 );
add... |
259,942 | <p>Where is the value for <code>admin_email</code> set?</p>
<pre><code>$email = get_option('admin_email');
</code></pre>
<p>How can I change it?</p>
| [
{
"answer_id": 259944,
"author": "ngearing",
"author_id": 50184,
"author_profile": "https://wordpress.stackexchange.com/users/50184",
"pm_score": 3,
"selected": false,
"text": "<p>In Wordpress backend go to: <strong>Settings > General</strong> and the field <strong>'Email Address'</stron... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/259942",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115340/"
] | Where is the value for `admin_email` set?
```
$email = get_option('admin_email');
```
How can I change it? | In Wordpress backend go to: **Settings > General** and the field **'Email Address'**.
Or in php: update\_option('admin\_email', 'your\_email@abc.com');
<https://codex.wordpress.org/Function_Reference/update_option> |
259,949 | <p>I wanted to exclude <code>pages</code> from the search results, and found many ways to do it, and was wondering why use <code>!is_admin()</code> or <code>is_main_query()</code> and which way would be better.</p>
<pre><code>add_filter('pre_get_posts','search_filter');
function search_filter($query) {
if ($query-... | [
{
"answer_id": 259955,
"author": "Ben Casey",
"author_id": 114997,
"author_profile": "https://wordpress.stackexchange.com/users/114997",
"pm_score": 2,
"selected": false,
"text": "<p><code>pre_get_posts</code> will run in admin as well as the frontend, you can use it to filter posts that... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/259949",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115018/"
] | I wanted to exclude `pages` from the search results, and found many ways to do it, and was wondering why use `!is_admin()` or `is_main_query()` and which way would be better.
```
add_filter('pre_get_posts','search_filter');
function search_filter($query) {
if ($query->is_search) {
$query->set('post_type', ... | Note that when we use:
```
$query->set( 'post_type', 'post' );
```
then we're overriding all searchable post types, not only the `page` post type.
That may be just fine in some cases, and we're done using some of your `pre_get_posts` snippets that fit our needs.
But sometimes we don't want to hard fix it that way... |
259,958 | <p>I'm building a function within functions.php</p>
<p>Within my function I want to make use of the post id of current post.
How do I do this?</p>
<p>The last thing I tried was this:</p>
<pre><code>global $post ;
$id = $post->id ;
</code></pre>
<p>However, this returns an empty string.</p>
| [
{
"answer_id": 259955,
"author": "Ben Casey",
"author_id": 114997,
"author_profile": "https://wordpress.stackexchange.com/users/114997",
"pm_score": 2,
"selected": false,
"text": "<p><code>pre_get_posts</code> will run in admin as well as the frontend, you can use it to filter posts that... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/259958",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26187/"
] | I'm building a function within functions.php
Within my function I want to make use of the post id of current post.
How do I do this?
The last thing I tried was this:
```
global $post ;
$id = $post->id ;
```
However, this returns an empty string. | Note that when we use:
```
$query->set( 'post_type', 'post' );
```
then we're overriding all searchable post types, not only the `page` post type.
That may be just fine in some cases, and we're done using some of your `pre_get_posts` snippets that fit our needs.
But sometimes we don't want to hard fix it that way... |
259,970 | <p>i've got a question. I created a plugin with a menu and i want to show this under the Dashboard menu-item. In some of my wordpress installations the dashboard item will be overwrited. How can i fix this?</p>
<p>My code to add the menu is:</p>
<pre><code>add_menu_page('pluginname', 'pluginname', 'manage_options', '... | [
{
"answer_id": 259955,
"author": "Ben Casey",
"author_id": 114997,
"author_profile": "https://wordpress.stackexchange.com/users/114997",
"pm_score": 2,
"selected": false,
"text": "<p><code>pre_get_posts</code> will run in admin as well as the frontend, you can use it to filter posts that... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/259970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115020/"
] | i've got a question. I created a plugin with a menu and i want to show this under the Dashboard menu-item. In some of my wordpress installations the dashboard item will be overwrited. How can i fix this?
My code to add the menu is:
```
add_menu_page('pluginname', 'pluginname', 'manage_options', 'pluginname-hello', ''... | Note that when we use:
```
$query->set( 'post_type', 'post' );
```
then we're overriding all searchable post types, not only the `page` post type.
That may be just fine in some cases, and we're done using some of your `pre_get_posts` snippets that fit our needs.
But sometimes we don't want to hard fix it that way... |
259,985 | <p>I have tried is_front_page() but I believe that is the php way of doing it. Perhaps I'm not calling it right because, of course, I'm not getting a response. Maybe I'm just short of my detailed Js ways of accessing the Wordpress classes. </p>
<p>What I'm trying to do is simple. If I am on the front page or home page... | [
{
"answer_id": 259986,
"author": "ferdouswp",
"author_id": 114362,
"author_profile": "https://wordpress.stackexchange.com/users/114362",
"pm_score": 0,
"selected": false,
"text": "<p>You can use page id class. If you add page-id class in your java script file maybe solve your problem. </... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/259985",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64475/"
] | I have tried is\_front\_page() but I believe that is the php way of doing it. Perhaps I'm not calling it right because, of course, I'm not getting a response. Maybe I'm just short of my detailed Js ways of accessing the Wordpress classes.
What I'm trying to do is simple. If I am on the front page or home page add thi... | I just posted [an answer to another question](https://wordpress.stackexchange.com/a/259996/17305) about how to do it.
In your case, assuming you used `body_class()` in your theme, your home page should have a `<body>` with class `home` to it.
So in your JS, you can:
```
if( $('body.home').length ){
// Do stuff
}
... |
259,987 | <p>I have this script that automatically scrolls down to the primary content on page load.</p>
<pre><code>jQuery(document).ready(function($){
if ( $(window).width() < 768 || window.Touch) {
$('html, body').animate({ scrollTop: $("#primary").offset().top}, 2000);}
});
</code></pre>
<p><strong>1.</strong> Ho... | [
{
"answer_id": 259989,
"author": "Dragos Micu",
"author_id": 110131,
"author_profile": "https://wordpress.stackexchange.com/users/110131",
"pm_score": 2,
"selected": false,
"text": "<p>Step 1: save the code as a new js file, say main.js</p>\n\n<p>Step 2: add a conditional function to fun... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/259987",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110570/"
] | I have this script that automatically scrolls down to the primary content on page load.
```
jQuery(document).ready(function($){
if ( $(window).width() < 768 || window.Touch) {
$('html, body').animate({ scrollTop: $("#primary").offset().top}, 2000);}
});
```
**1.** However I would like to *only* apply it to o... | There are two ways you could do that.
1. Using JS only
================
WordPress themes normally use the [`body_class()`](https://developer.wordpress.org/reference/functions/body_class/) function. As a result you'll see that the `<body>` tag will have lots of classes. You can then target pages with a specific class ... |
260,015 | <p>I am trying to make my own language switcher for my WordPress site. I am generating all labels using the <code>_e</code> and similar functions. So I am guessing the only thing I need to do is to change the locale used by WordPress. How can I do this programmatically?</p>
<p>So in the ideal scenario when a user clic... | [
{
"answer_id": 260096,
"author": "maxime schoeni",
"author_id": 81094,
"author_profile": "https://wordpress.stackexchange.com/users/81094",
"pm_score": 1,
"selected": false,
"text": "<p>Actually you need to hook in the 'locale' filter to set the language you want:</p>\n\n<pre><code>add_f... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/260015",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112158/"
] | I am trying to make my own language switcher for my WordPress site. I am generating all labels using the `_e` and similar functions. So I am guessing the only thing I need to do is to change the locale used by WordPress. How can I do this programmatically?
So in the ideal scenario when a user clicks on the desired lan... | Actually you need to hook in the 'locale' filter to set the language you want:
```
add_filter('locale', function($locale) {
return esc_attr($_GET['language']);
});
```
Then in the links of your switch, you need to pass the language variable:
```
<a href="<?php echo add_query_arg('language', 'xx_XX') ?>">XX</a>
... |
260,021 | <p>I have a project where people can enter their details and only they can see those data by log in to there account.
Instead admin can see all data. </p>
<p>How can i achieve this using wordpress? please help me.</p>
| [
{
"answer_id": 260096,
"author": "maxime schoeni",
"author_id": 81094,
"author_profile": "https://wordpress.stackexchange.com/users/81094",
"pm_score": 1,
"selected": false,
"text": "<p>Actually you need to hook in the 'locale' filter to set the language you want:</p>\n\n<pre><code>add_f... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/260021",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115393/"
] | I have a project where people can enter their details and only they can see those data by log in to there account.
Instead admin can see all data.
How can i achieve this using wordpress? please help me. | Actually you need to hook in the 'locale' filter to set the language you want:
```
add_filter('locale', function($locale) {
return esc_attr($_GET['language']);
});
```
Then in the links of your switch, you need to pass the language variable:
```
<a href="<?php echo add_query_arg('language', 'xx_XX') ?>">XX</a>
... |
260,035 | <p>Please look at the picture below. I want to get <code>post_id</code> from <code>meta_value</code> = <strong>93</strong>. How can I do that?</p>
<p><a href="https://i.stack.imgur.com/Haekh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Haekh.png" alt=""></a></p>
| [
{
"answer_id": 260043,
"author": "Thilak",
"author_id": 113208,
"author_profile": "https://wordpress.stackexchange.com/users/113208",
"pm_score": 3,
"selected": false,
"text": "<p>Try this. It will work. </p>\n\n<pre><code>$prepare_guery = $wpdb->prepare( \"SELECT post_id FROM $wpdp-&... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/260035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77080/"
] | Please look at the picture below. I want to get `post_id` from `meta_value` = **93**. How can I do that?
[](https://i.stack.imgur.com/Haekh.png) | Try this. It will work.
```
$prepare_guery = $wpdb->prepare( "SELECT post_id FROM $wpdp->posts where meta_key ='_Wps_crossells' and meta_value like '%%d%'", $meta_value );
$get_values = $wpdb->get_col( $prepare_guery );
```
**Let me know it's working or not.** |
260,053 | <p>I want to offer my clients WordPress websites, but want to use WP multisite. I've read multiple articles on using a plugin, not using a plugin, etc. </p>
<p>My clients own their own domain names and want me to host/manage their sites. So I'll be using my main website as the install <code>abc.com</code>. </p>
<p>Wh... | [
{
"answer_id": 260186,
"author": "Justin",
"author_id": 114945,
"author_profile": "https://wordpress.stackexchange.com/users/114945",
"pm_score": 1,
"selected": false,
"text": "<p>To keep your options open with an open architecture you can create a multisite Network installation with mul... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/260053",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44899/"
] | I want to offer my clients WordPress websites, but want to use WP multisite. I've read multiple articles on using a plugin, not using a plugin, etc.
My clients own their own domain names and want me to host/manage their sites. So I'll be using my main website as the install `abc.com`.
When you visit one of their si... | To keep your options open with an open architecture you can create a multisite Network installation with multiple Networks. This means for each separate client you would give them a new Network. The advantage of this is that you can offer the scalability to Clients and keep your options open. Clients can easily have mo... |
260,070 | <p>I am trying to change pages when I search by category on my website. When I am not searching under a certain category I can switch pages fine but when I am searching for a category I am unable to switch pages. </p>
<pre><code>$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$o... | [
{
"answer_id": 260072,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>The pagination functions work off of the main query, so you'd need to use <code>pre_get_posts</code> instead... | 2017/03/14 | [
"https://wordpress.stackexchange.com/questions/260070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80568/"
] | I am trying to change pages when I search by category on my website. When I am not searching under a certain category I can switch pages fine but when I am searching for a category I am unable to switch pages.
```
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$orderby = ( get... | The pagination functions work off of the main query, so you'd need to use `pre_get_posts` instead of creating a new query for them to work.
But, you're using `WP_User_Query`, so the standard pagination system will never work for you. You're going to have to 'roll your own' pagination system here, and generate your own... |
260,083 | <p>How can I use <code>do_action</code> and <code>add_action</code> to return an array in <code>do_action</code>?</p>
<p>My sample code:</p>
<pre><code>function name_fun_one(){
$namearray[] = array('k1'=> 'text1', 'k2' => 'text1');
$namearray[] = array('k1'=> 'text2', 'k2' => 'text2');
do_acti... | [
{
"answer_id": 260072,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>The pagination functions work off of the main query, so you'd need to use <code>pre_get_posts</code> instead... | 2017/03/15 | [
"https://wordpress.stackexchange.com/questions/260083",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115426/"
] | How can I use `do_action` and `add_action` to return an array in `do_action`?
My sample code:
```
function name_fun_one(){
$namearray[] = array('k1'=> 'text1', 'k2' => 'text1');
$namearray[] = array('k1'=> 'text2', 'k2' => 'text2');
do_action('add_in_namearray');
foreach($namearray as $val)
{
... | The pagination functions work off of the main query, so you'd need to use `pre_get_posts` instead of creating a new query for them to work.
But, you're using `WP_User_Query`, so the standard pagination system will never work for you. You're going to have to 'roll your own' pagination system here, and generate your own... |
260,095 | <p>I need to add a menu to a submenu in admin menu bar. Is it possible to do this in wordpress?</p>
<p>For Example :</p>
<pre><code>A
|
-> B
|
-> C
</code></pre>
<p>Or is there any work-around or hack to accomplish this?</p>
| [
{
"answer_id": 260104,
"author": "Savan Dholu",
"author_id": 108472,
"author_profile": "https://wordpress.stackexchange.com/users/108472",
"pm_score": 1,
"selected": false,
"text": "<p>No, it is not possible to create third level menu in admin panel. If you look at the definition of <str... | 2017/03/15 | [
"https://wordpress.stackexchange.com/questions/260095",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/90559/"
] | I need to add a menu to a submenu in admin menu bar. Is it possible to do this in wordpress?
For Example :
```
A
|
-> B
|
-> C
```
Or is there any work-around or hack to accomplish this? | While the main admin menus (i.e., those on the left-hand side of the screen) can only be 2 deep (A > B), nodes in the [toolbar](https://codex.wordpress.org/Toolbar) can be arbitrarily deep.
I don't know if using the toolbar would be a suitable workaround for you, but if so, then you could do something like:
```
add_a... |
260,105 | <p>This is a question I can't find the answer to:</p>
<p><strong>Can I run two separate Multisite networks under one domain?</strong></p>
<p>Here's the scenario, to better explain, we have a company website that already uses a WordPress Multisite network to run our country sites, like so:</p>
<pre><code>http://www.c... | [
{
"answer_id": 260109,
"author": "Sami",
"author_id": 102593,
"author_profile": "https://wordpress.stackexchange.com/users/102593",
"pm_score": 1,
"selected": false,
"text": "<p>You can install a new wordpress in a sub folder, let's call it \"www2\", so you'll have this URL : </p>\n\n<pr... | 2017/03/15 | [
"https://wordpress.stackexchange.com/questions/260105",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73939/"
] | This is a question I can't find the answer to:
**Can I run two separate Multisite networks under one domain?**
Here's the scenario, to better explain, we have a company website that already uses a WordPress Multisite network to run our country sites, like so:
```
http://www.companysite.com/
http://www.companysite.co... | You can not run different networks or different Multisite installations under one domain in the default possibilities of WP. But you can use one Multiste with multiple networks with the help of a plugin - <https://wordpress.org/plugins/wp-multi-network/>
With this plugin get you the chance to create different networks... |
260,114 | <p>i'm working on a plugin and i got a checkbox with the setting code:</p>
<pre><code> register_setting('plugin551-setting-group', 'livechat_option');
</code></pre>
<p>I want it to be default true, the checkbox in the setting page is now default false.
How can i do this?</p>
| [
{
"answer_id": 260109,
"author": "Sami",
"author_id": 102593,
"author_profile": "https://wordpress.stackexchange.com/users/102593",
"pm_score": 1,
"selected": false,
"text": "<p>You can install a new wordpress in a sub folder, let's call it \"www2\", so you'll have this URL : </p>\n\n<pr... | 2017/03/15 | [
"https://wordpress.stackexchange.com/questions/260114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115020/"
] | i'm working on a plugin and i got a checkbox with the setting code:
```
register_setting('plugin551-setting-group', 'livechat_option');
```
I want it to be default true, the checkbox in the setting page is now default false.
How can i do this? | You can not run different networks or different Multisite installations under one domain in the default possibilities of WP. But you can use one Multiste with multiple networks with the help of a plugin - <https://wordpress.org/plugins/wp-multi-network/>
With this plugin get you the chance to create different networks... |
260,117 | <p>I am new to wordpress, I am trying to develop a theme on localhost, I am trying to load style.css using this code in functions.php</p>
<pre><code>function add_theme_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
</code></pre>
<p>And st... | [
{
"answer_id": 260118,
"author": "Aftab",
"author_id": 64614,
"author_profile": "https://wordpress.stackexchange.com/users/64614",
"pm_score": 4,
"selected": true,
"text": "<p>Are you sure you theme is active?</p>\n\n<p>If you see your style.css code it should not have only the CSS code ... | 2017/03/15 | [
"https://wordpress.stackexchange.com/questions/260117",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114573/"
] | I am new to wordpress, I am trying to develop a theme on localhost, I am trying to load style.css using this code in functions.php
```
function add_theme_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
```
And style.css is
```
body{backg... | Are you sure you theme is active?
If you see your style.css code it should not have only the CSS code but also the Theme defination at header of your style.css.
Please make sure if your theme is active.
The above code for loading CSS file looks good and should work if your theme is active.
**Update** :
Have you a... |
260,134 | <p>I am getting post id from url like this</p>
<pre><code>https://www.example.com/download/?id=241
</code></pre>
<p>and in base of this id i want to get post data from db but it is getting nothing i tried this code</p>
<pre><code> <?php
$id = $_GET['id'];
// WP_Query arguments
$args = array (
'category_name'... | [
{
"answer_id": 260135,
"author": "ehsan",
"author_id": 109403,
"author_profile": "https://wordpress.stackexchange.com/users/109403",
"pm_score": 1,
"selected": false,
"text": "<p>You may use $_GET parameter to get the id.</p>\n\n<pre><code>$id = $_GET['id'];\n</code></pre>\n\n<p>Or try t... | 2017/03/15 | [
"https://wordpress.stackexchange.com/questions/260134",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113134/"
] | I am getting post id from url like this
```
https://www.example.com/download/?id=241
```
and in base of this id i want to get post data from db but it is getting nothing i tried this code
```
<?php
$id = $_GET['id'];
// WP_Query arguments
$args = array (
'category_name' => 'download',
'showposts'... | You may use $\_GET parameter to get the id.
```
$id = $_GET['id'];
```
Or try this:
```
global $post;
echo $post->ID;
```
But it seems you have a problem in the args array. when you know the exact id of requested post you don't need to use it like that. you can use this instead:
```
get_post($id);
```
And then... |
260,141 | <p>i'm try to filter posts by an cascade dropdown categories.
But when i select an option of the cascade, he showing all the posts.
How can i filter ONLY posts through the selected option?</p>
<p>This is my structure:</p>
<p><strong>Functions.php</strong></p>
<pre><code> function ajax_filter_posts_scripts() {
/... | [
{
"answer_id": 260135,
"author": "ehsan",
"author_id": 109403,
"author_profile": "https://wordpress.stackexchange.com/users/109403",
"pm_score": 1,
"selected": false,
"text": "<p>You may use $_GET parameter to get the id.</p>\n\n<pre><code>$id = $_GET['id'];\n</code></pre>\n\n<p>Or try t... | 2017/03/15 | [
"https://wordpress.stackexchange.com/questions/260141",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84579/"
] | i'm try to filter posts by an cascade dropdown categories.
But when i select an option of the cascade, he showing all the posts.
How can i filter ONLY posts through the selected option?
This is my structure:
**Functions.php**
```
function ajax_filter_posts_scripts() {
// Enqueue script
wp_register_script('af... | You may use $\_GET parameter to get the id.
```
$id = $_GET['id'];
```
Or try this:
```
global $post;
echo $post->ID;
```
But it seems you have a problem in the args array. when you know the exact id of requested post you don't need to use it like that. you can use this instead:
```
get_post($id);
```
And then... |
260,180 | <p>When should you use <code>add_action</code> to enqueue or register a script, vs just using <code>wp_register_script</code> and/or <code>wp_enqueue_script</code>? In other words, both <code>example 1</code> and <code>example 2</code> below seem to accomplish the same thing when in <code>functions.php</code>, so why d... | [
{
"answer_id": 260181,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 1,
"selected": false,
"text": "<p>Well it works the same <em>in the case where you tested it</em>.</p>\n\n<p>The answer could actually be some... | 2017/03/15 | [
"https://wordpress.stackexchange.com/questions/260180",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3811/"
] | When should you use `add_action` to enqueue or register a script, vs just using `wp_register_script` and/or `wp_enqueue_script`? In other words, both `example 1` and `example 2` below seem to accomplish the same thing when in `functions.php`, so why do so many resources say that `example 1` is the correct way of loadin... | Well it works the same *in the case where you tested it*.
The answer could actually be somewhat complex, but mainly having it inside an action callback only registers them when needed, just putting it inside the `functions.php` it happens always when the theme is active.
First of all this can be a waste of performanc... |
260,199 | <p>Im using the following to access tables information from my Wordpress DB</p>
<pre><code> require_once(ABSPATH . 'wp-config.php');
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysqli_select_db($conn, DB_NAME);
</code></pre>
<p>It works fine I'm able to connect and display the information. The trouble i... | [
{
"answer_id": 260241,
"author": "user1049961",
"author_id": 47664,
"author_profile": "https://wordpress.stackexchange.com/users/47664",
"pm_score": -1,
"selected": false,
"text": "<p>You are probably just missing the slash in the <code>require_once</code>. Change it to:</p>\n\n<pre><cod... | 2017/03/15 | [
"https://wordpress.stackexchange.com/questions/260199",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115478/"
] | Im using the following to access tables information from my Wordpress DB
```
require_once(ABSPATH . 'wp-config.php');
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysqli_select_db($conn, DB_NAME);
```
It works fine I'm able to connect and display the information. The trouble is when I try to do the sam... | I'm guessing this is a custom "plugin" where you are wanting to run a file externally that connects to the WordPress database, not really as a standard plugin which loads within WordPress environment, as in that case as @belinus says you can just use `$wpdb` class.
Anyway, since `ABSPATH` is defined IN `wp-config.php`... |
260,227 | <p>So I have this theme where there is an about section that is showing in the customizer, but there isn't a specific post type on the admin page that adds post to this section.</p>
<p>How do I add post to the about section with the template code stated below.</p>
<pre><code>if(isset($xt_corporate_lite_opt['xt_about_... | [
{
"answer_id": 260243,
"author": "1naveengiri",
"author_id": 114894,
"author_profile": "https://wordpress.stackexchange.com/users/114894",
"pm_score": 1,
"selected": false,
"text": "<p>You can try this code to show only post.</p>\n\n<pre><code>if(isset($xt_corporate_lite_opt['xt_about_pa... | 2017/03/16 | [
"https://wordpress.stackexchange.com/questions/260227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115499/"
] | So I have this theme where there is an about section that is showing in the customizer, but there isn't a specific post type on the admin page that adds post to this section.
How do I add post to the about section with the template code stated below.
```
if(isset($xt_corporate_lite_opt['xt_about_page']) &&
$xt_corpo... | You can try this code to show only post.
```
if(isset($xt_corporate_lite_opt['xt_about_page']) && $xt_corporate_lite_opt['xt_about_page'] != '') {
$args = array( 'post_type' => 'post');
$xt_query = new WP_Query($args);
if ($xt_query->have_posts()) {
while ($xt_query->have_posts()) {
$xt... |
260,236 | <p>Is there any way that I can log anything in WordPress similar to logs we can do it in Magento?</p>
<p>I am integrating a custom plugin in that I have added few functions with help of hooks, So I need to debug something in it. In this I need if I can enter any text or data into WordPress logs.</p>
<p>If so Please let... | [
{
"answer_id": 260246,
"author": "Ian",
"author_id": 11583,
"author_profile": "https://wordpress.stackexchange.com/users/11583",
"pm_score": 3,
"selected": false,
"text": "<p>WordPress can do logging! Check out the WordPress debugging page here <a href=\"https://codex.wordpress.org/Debug... | 2017/03/16 | [
"https://wordpress.stackexchange.com/questions/260236",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60922/"
] | Is there any way that I can log anything in WordPress similar to logs we can do it in Magento?
I am integrating a custom plugin in that I have added few functions with help of hooks, So I need to debug something in it. In this I need if I can enter any text or data into WordPress logs.
If so Please let me know the pr... | You can enable WordPress logging adding this to `wp-config.php`:
```
// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
```
you can write to the log file using the [`error_log()` function](https://www.php.net/manual/en/funct... |
260,249 | <p>I'm trying to write a plugin that adds a value from a meta box to a post on save_post. But I can't figure out how to get the value from the form field in the meta box This is the relevant code:</p>
<pre><code>function sw_add_document_meta_boxes() {
if (get_current_screen()->id == 'dokument') {
add_me... | [
{
"answer_id": 260246,
"author": "Ian",
"author_id": 11583,
"author_profile": "https://wordpress.stackexchange.com/users/11583",
"pm_score": 3,
"selected": false,
"text": "<p>WordPress can do logging! Check out the WordPress debugging page here <a href=\"https://codex.wordpress.org/Debug... | 2017/03/16 | [
"https://wordpress.stackexchange.com/questions/260249",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115521/"
] | I'm trying to write a plugin that adds a value from a meta box to a post on save\_post. But I can't figure out how to get the value from the form field in the meta box This is the relevant code:
```
function sw_add_document_meta_boxes() {
if (get_current_screen()->id == 'dokument') {
add_meta_box('access_l... | You can enable WordPress logging adding this to `wp-config.php`:
```
// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
```
you can write to the log file using the [`error_log()` function](https://www.php.net/manual/en/funct... |
260,284 | <p>My Server Env for a wordpress site is as follows:</p>
<pre><code>---------- --------- -------------
| Client | <-- HTTPS --> | Proxy | <-- HTTP --> | Wordpress |
---------- --------- -------------
</code></pre>
<p>The Problem is that the Wordpress S... | [
{
"answer_id": 260293,
"author": "hcheung",
"author_id": 111577,
"author_profile": "https://wordpress.stackexchange.com/users/111577",
"pm_score": 3,
"selected": true,
"text": "<p>Please take a look at <a href=\"https://wordpress.org/support/article/administration-over-ssl/\" rel=\"nofol... | 2017/03/16 | [
"https://wordpress.stackexchange.com/questions/260284",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86177/"
] | My Server Env for a wordpress site is as follows:
```
---------- --------- -------------
| Client | <-- HTTPS --> | Proxy | <-- HTTP --> | Wordpress |
---------- --------- -------------
```
The Problem is that the Wordpress Site itself is served internally over H... | Please take a look at [Administation Over SSL](https://wordpress.org/support/article/administration-over-ssl/), particularly the "Using a Reverse Proxy" section. |
260,311 | <p>I'm new to Wordpress theme development. I'd like to make a simple Testimonial page that a non-technical user can add more testimonial later. Here's the example of the page:
<a href="http://heartyjuice.com.au/testimonials/" rel="nofollow noreferrer">Testimonials page</a></p>
<p>I'd like to have a admin screen where ... | [
{
"answer_id": 260316,
"author": "jdm2112",
"author_id": 45202,
"author_profile": "https://wordpress.stackexchange.com/users/45202",
"pm_score": 2,
"selected": true,
"text": "<p>I would suggest a custom post type for your Testimonials. Each will be created as an individual post and you ... | 2017/03/16 | [
"https://wordpress.stackexchange.com/questions/260311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115555/"
] | I'm new to Wordpress theme development. I'd like to make a simple Testimonial page that a non-technical user can add more testimonial later. Here's the example of the page:
[Testimonials page](http://heartyjuice.com.au/testimonials/)
I'd like to have a admin screen where user input the name, upload the picture, and th... | I would suggest a custom post type for your Testimonials. Each will be created as an individual post and you will have the ability to query, sort, categorize, your testimonials just as you can with blog posts, or any other post type. Non-technical site admins can simply "add new testimonial" and edit existing, etc, jus... |
260,315 | <p>I am trying to clean up a DB of 4000+ posts and the editors TAGGED the posts that they want to keep with an "audit2017" tag. Is there a way with SQL to select all posts *without this tag and delete them?</p>
<p>I am not very experienced with SQL but can manage this if I had the right query.</p>
<p>Any help appreci... | [
{
"answer_id": 260383,
"author": "Mihai Apetrei",
"author_id": 115589,
"author_profile": "https://wordpress.stackexchange.com/users/115589",
"pm_score": 0,
"selected": false,
"text": "<p>Was looking into this to help you come with a solution. I'm not able to find one for the sql panel, b... | 2017/03/16 | [
"https://wordpress.stackexchange.com/questions/260315",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115559/"
] | I am trying to clean up a DB of 4000+ posts and the editors TAGGED the posts that they want to keep with an "audit2017" tag. Is there a way with SQL to select all posts \*without this tag and delete them?
I am not very experienced with SQL but can manage this if I had the right query.
Any help appreciated, thanks! | I just created a function that can bulk delete posts that doesn't have specific tag(s).
You need to have the IDs of the tags that you want to keep their posts.
[In case you don't know how to get those IDs: Quick solution is go to tags page on the website admin panel. Click on the tag. In the new page address bar you c... |
260,359 | <p>I'm having a heck of a time with this! I'm trying to force this page to only show a limited amount of words regardless if they insert a readmore tag.</p>
<p>I was going to use the_excerpt, but it doesn't add a readmore link at the end of the excerpt.</p>
<p>I have my index page pulling my blog roll by using this ... | [
{
"answer_id": 260361,
"author": "Ian",
"author_id": 11583,
"author_profile": "https://wordpress.stackexchange.com/users/11583",
"pm_score": 2,
"selected": false,
"text": "<p>Try <code>wp_trim_words()</code> <a href=\"https://codex.wordpress.org/Function_Reference/wp_trim_words\" rel=\"n... | 2017/03/16 | [
"https://wordpress.stackexchange.com/questions/260359",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77767/"
] | I'm having a heck of a time with this! I'm trying to force this page to only show a limited amount of words regardless if they insert a readmore tag.
I was going to use the\_excerpt, but it doesn't add a readmore link at the end of the excerpt.
I have my index page pulling my blog roll by using this code:
```
<div c... | I couldn't get this resolved with the\_content() so i went simple and this works:
```
the_excerpt();
echo '<a href="' . esc_url( get_the_permalink() ) . '"> more...</a>';
``` |
260,371 | <p>I have made a child theme of a themify theme. I used thier example on enqueuing as well as my own. In both cases the child css is loaded after the parent. </p>
<p>Loaded on Line <code>53</code></p>
<pre><code><link rel='stylesheet' id='parent-style-css' href='https://example.com/wp-content/themes/themify-ultra... | [
{
"answer_id": 260390,
"author": "scott",
"author_id": 93587,
"author_profile": "https://wordpress.stackexchange.com/users/93587",
"pm_score": 1,
"selected": false,
"text": "<p>I looked at my child theme's functions.php and I found that I had commented out the line to enqueue the child s... | 2017/03/16 | [
"https://wordpress.stackexchange.com/questions/260371",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70863/"
] | I have made a child theme of a themify theme. I used thier example on enqueuing as well as my own. In both cases the child css is loaded after the parent.
Loaded on Line `53`
```
<link rel='stylesheet' id='parent-style-css' href='https://example.com/wp-content/themes/themify-ultra/style.css?ver=4.7.3' type='text/cs... | Themifies built in minification was inlining the parent CSS after the child. Which is why I could not find it, I was not looking for inline CSS.
Chromes console still showed it as the remote CSS file even though it was inlined.
Disabling the built in minification fixed the issue. |
260,373 | <p>I'm using twentyseventeen theme as base to design my own, but when i use wp_nav_menu to print menus, it adds some unwanted svg elements which break my design. Elements are like:</p>
<pre><code><svg class="icon icon-angle-down" aria-hidden="true" role="img">
<use href="#icon-angle-down" xlink:href="#icon-a... | [
{
"answer_id": 260390,
"author": "scott",
"author_id": 93587,
"author_profile": "https://wordpress.stackexchange.com/users/93587",
"pm_score": 1,
"selected": false,
"text": "<p>I looked at my child theme's functions.php and I found that I had commented out the line to enqueue the child s... | 2017/03/16 | [
"https://wordpress.stackexchange.com/questions/260373",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115587/"
] | I'm using twentyseventeen theme as base to design my own, but when i use wp\_nav\_menu to print menus, it adds some unwanted svg elements which break my design. Elements are like:
```
<svg class="icon icon-angle-down" aria-hidden="true" role="img">
<use href="#icon-angle-down" xlink:href="#icon-angle-down"></use> </s... | Themifies built in minification was inlining the parent CSS after the child. Which is why I could not find it, I was not looking for inline CSS.
Chromes console still showed it as the remote CSS file even though it was inlined.
Disabling the built in minification fixed the issue. |
260,375 | <p>Im working with custom post types - named 'Products'</p>
<p>I have multiple taxonomies registered - 'Category' and 'Dosage'</p>
<p>And I'm trying to setup pages that only display custom post types 'products' IF taxonomy Category='injectors' AND Dosage='1ml, 2ml, 5ml' </p>
<p>I hope that makes sense - manage to g... | [
{
"answer_id": 260390,
"author": "scott",
"author_id": 93587,
"author_profile": "https://wordpress.stackexchange.com/users/93587",
"pm_score": 1,
"selected": false,
"text": "<p>I looked at my child theme's functions.php and I found that I had commented out the line to enqueue the child s... | 2017/03/16 | [
"https://wordpress.stackexchange.com/questions/260375",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115588/"
] | Im working with custom post types - named 'Products'
I have multiple taxonomies registered - 'Category' and 'Dosage'
And I'm trying to setup pages that only display custom post types 'products' IF taxonomy Category='injectors' AND Dosage='1ml, 2ml, 5ml'
I hope that makes sense - manage to get custom post archives w... | Themifies built in minification was inlining the parent CSS after the child. Which is why I could not find it, I was not looking for inline CSS.
Chromes console still showed it as the remote CSS file even though it was inlined.
Disabling the built in minification fixed the issue. |
260,399 | <p>I´m building a child theme for a parent theme that loads in its functions.php <strong>all</strong> its scripts in a single minified JS file. And it does so before the closing body tag by setting the last parameter of <code>wp_enqueue_script()</code> to "true"</p>
<p>However, note that this <strong>single file</stro... | [
{
"answer_id": 260400,
"author": "Cedon",
"author_id": 80069,
"author_profile": "https://wordpress.stackexchange.com/users/80069",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress loads jQuery in noconflict mode. Therefore, but default, you cannot use $(). You can fix this one of ... | 2017/03/17 | [
"https://wordpress.stackexchange.com/questions/260399",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115596/"
] | I´m building a child theme for a parent theme that loads in its functions.php **all** its scripts in a single minified JS file. And it does so before the closing body tag by setting the last parameter of `wp_enqueue_script()` to "true"
However, note that this **single file** includes several libraries before the devel... | change all $ to jQuery and enque script this way so your script will load after loading jQuery and since wordpress do use prototype so we cannt use $ user jQuery
```
wp_enqueue_script('name_of_script','path',array('jquery'));
``` |
260,410 | <p>I am creating a custom admin section. I have the following code:</p>
<pre><code>// Top level menu
add_menu_page('Books', 'Books', 'publish_posts', 'books', 'render_books_page', '', 17);
// Adding this function to make the first submenu have a different name than the main menu
// Details: https://wordpress.stackexc... | [
{
"answer_id": 260415,
"author": "Ian",
"author_id": 11583,
"author_profile": "https://wordpress.stackexchange.com/users/11583",
"pm_score": 2,
"selected": false,
"text": "<p>For your particular situation, where you need to have a menu registered, but not shown unless you click on it fro... | 2017/03/17 | [
"https://wordpress.stackexchange.com/questions/260410",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34253/"
] | I am creating a custom admin section. I have the following code:
```
// Top level menu
add_menu_page('Books', 'Books', 'publish_posts', 'books', 'render_books_page', '', 17);
// Adding this function to make the first submenu have a different name than the main menu
// Details: https://wordpress.stackexchange.com/ques... | The solution is based on the ideas provided by @Ian. Thanks.
```
add_action( 'admin_menu', 'add_the_menus' );
function add_the_menus() {
// Top level menu
add_menu_page ('Books', 'Books', 'publish_posts', 'books', 'render_books_page', '', 17);
// Adding this function to make the first submenu have a diff... |
260,416 | <p>I'm trying to find a way to get my posts with different look depending on their category.</p>
<p>I have first tried to do it using the <a href="https://developer.wordpress.org/files/2014/10/template-hierarchy.png" rel="nofollow noreferrer">template hierarchy</a> but it seems there is no pattern for the category pos... | [
{
"answer_id": 260415,
"author": "Ian",
"author_id": 11583,
"author_profile": "https://wordpress.stackexchange.com/users/11583",
"pm_score": 2,
"selected": false,
"text": "<p>For your particular situation, where you need to have a menu registered, but not shown unless you click on it fro... | 2017/03/17 | [
"https://wordpress.stackexchange.com/questions/260416",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110467/"
] | I'm trying to find a way to get my posts with different look depending on their category.
I have first tried to do it using the [template hierarchy](https://developer.wordpress.org/files/2014/10/template-hierarchy.png) but it seems there is no pattern for the category posts. (ie single-cat-mycategory.php)
So then wit... | The solution is based on the ideas provided by @Ian. Thanks.
```
add_action( 'admin_menu', 'add_the_menus' );
function add_the_menus() {
// Top level menu
add_menu_page ('Books', 'Books', 'publish_posts', 'books', 'render_books_page', '', 17);
// Adding this function to make the first submenu have a diff... |
260,427 | <p>Hi I am trying to understand when and why I should use these esc-alternatives and so far I think I understand that it is needed to secure that input is not containing wrong characters and in that causing errors/security threats.</p>
<p>What I still wonder is should I always use esc_attr in HTML fields, or example t... | [
{
"answer_id": 260430,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>If the values that are in need of escaping are generate fully from your code, as it is usually in admin s... | 2017/03/17 | [
"https://wordpress.stackexchange.com/questions/260427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114853/"
] | Hi I am trying to understand when and why I should use these esc-alternatives and so far I think I understand that it is needed to secure that input is not containing wrong characters and in that causing errors/security threats.
What I still wonder is should I always use esc\_attr in HTML fields, or example the input ... | Yes! You should always be escaping
Escape Late, Escape Often
Escaping is about intent, if you intend to output a URL, use `esc_url`, and it will definately be a URL ( if the data is malicious it will be made safe )
>
> What I still wonder is should I always use esc\_attr in HTML fields, or example the input fields ... |
260,442 | <p>I have several post types. I want to get all custom fields associated with that post type.</p>
<p>Example:</p>
<pre><code>Post
-- image
-- Featured image
-- body
</code></pre>
<p>I need to get all fields or custom fields in array. I found a solution <a href="https://wordpress.stackexchange.com/questions/18318/how... | [
{
"answer_id": 261069,
"author": "Faysal Mahamud",
"author_id": 83752,
"author_profile": "https://wordpress.stackexchange.com/users/83752",
"pm_score": 3,
"selected": true,
"text": "<p>Add the following code in the functions.php</p>\n\n<p><strong>for acf</strong></p>\n\n<pre><code>functi... | 2017/03/17 | [
"https://wordpress.stackexchange.com/questions/260442",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115277/"
] | I have several post types. I want to get all custom fields associated with that post type.
Example:
```
Post
-- image
-- Featured image
-- body
```
I need to get all fields or custom fields in array. I found a solution [from here](https://wordpress.stackexchange.com/questions/18318/how-to-display-all-custom-fields-... | Add the following code in the functions.php
**for acf**
```
function get_all_meta($type){
global $wpdb;
$result = $wpdb->get_results($wpdb->prepare(
"SELECT post_id,meta_key,meta_value FROM wp_posts,wp_postmeta WHERE post_type = %s
AND wp_posts.ID = wp... |
260,445 | <p>I am currently developing a theme where I want to add two permalinks.<br/>
One is redirecting to the index.php with some custom parameters and values (rule stored in the wp_options table), the other is redirecting to a file in my template which offers the admin-ajax.php functionality (rule stored in .htaccess file).... | [
{
"answer_id": 261069,
"author": "Faysal Mahamud",
"author_id": 83752,
"author_profile": "https://wordpress.stackexchange.com/users/83752",
"pm_score": 3,
"selected": true,
"text": "<p>Add the following code in the functions.php</p>\n\n<p><strong>for acf</strong></p>\n\n<pre><code>functi... | 2017/03/17 | [
"https://wordpress.stackexchange.com/questions/260445",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115634/"
] | I am currently developing a theme where I want to add two permalinks.
One is redirecting to the index.php with some custom parameters and values (rule stored in the wp\_options table), the other is redirecting to a file in my template which offers the admin-ajax.php functionality (rule stored in .htaccess file).
``... | Add the following code in the functions.php
**for acf**
```
function get_all_meta($type){
global $wpdb;
$result = $wpdb->get_results($wpdb->prepare(
"SELECT post_id,meta_key,meta_value FROM wp_posts,wp_postmeta WHERE post_type = %s
AND wp_posts.ID = wp... |
260,465 | <p>I'm really new to wordpress and now I have to do a plugin that creates a HTML table from file and prints it to the page, and add more functionality to the table using DataTables jquery addon. This all has to happen when i call shortcode in the page. I have managed to get the html table to the page, but i have no ide... | [
{
"answer_id": 260468,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 0,
"selected": false,
"text": "<pre><code>function your_css_and_js() {\n wp_register_style('your_css_and_js', plugins_url('style.css',__FILE_... | 2017/03/17 | [
"https://wordpress.stackexchange.com/questions/260465",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115640/"
] | I'm really new to wordpress and now I have to do a plugin that creates a HTML table from file and prints it to the page, and add more functionality to the table using DataTables jquery addon. This all has to happen when i call shortcode in the page. I have managed to get the html table to the page, but i have no idea h... | Your question is a little unclear. I'm interpreting it to mean that you want to enqueue a jQuery script to be run by the user's browser only on public pages that contain the shortcode.
There are (at least) three ways of running a jQuery script only on pages that have a specific shortcode. The first way is to use the `... |
260,488 | <p>I have a normal WordPress settings page. It POSTs to options.php.</p>
<p>In options.php it uses wp_get_referer to redirect back to the page it came from.</p>
<p>I need to use remove_query_arg to remove an argument from the URL. Example:</p>
<pre><code>https://www.example.com/wp-admin/admin.php?page=plugin_setting... | [
{
"answer_id": 260468,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 0,
"selected": false,
"text": "<pre><code>function your_css_and_js() {\n wp_register_style('your_css_and_js', plugins_url('style.css',__FILE_... | 2017/03/17 | [
"https://wordpress.stackexchange.com/questions/260488",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112235/"
] | I have a normal WordPress settings page. It POSTs to options.php.
In options.php it uses wp\_get\_referer to redirect back to the page it came from.
I need to use remove\_query\_arg to remove an argument from the URL. Example:
```
https://www.example.com/wp-admin/admin.php?page=plugin_settings_page&tab=90
```
I ne... | Your question is a little unclear. I'm interpreting it to mean that you want to enqueue a jQuery script to be run by the user's browser only on public pages that contain the shortcode.
There are (at least) three ways of running a jQuery script only on pages that have a specific shortcode. The first way is to use the `... |
260,500 | <p>I am trying to insert this meta information into the cart and checkout page for woocommerce. It will hide a specific plugin on those pages. However i know if i edit the plugin files for woocommerce it will be overwritten on woocommerce update.</p>
<p>How would i do that correctly? Jquery? Or even function.php funct... | [
{
"answer_id": 260765,
"author": "TrubinE",
"author_id": 111011,
"author_profile": "https://wordpress.stackexchange.com/users/111011",
"pm_score": 1,
"selected": false,
"text": "<p>Add the code to the file functions.php</p>\n\n<pre><code>/**\n * add data in cart \n * \n */\nfunction add_... | 2017/03/17 | [
"https://wordpress.stackexchange.com/questions/260500",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110570/"
] | I am trying to insert this meta information into the cart and checkout page for woocommerce. It will hide a specific plugin on those pages. However i know if i edit the plugin files for woocommerce it will be overwritten on woocommerce update.
How would i do that correctly? Jquery? Or even function.php function?
```... | If your goal is to put it in the `<head>IM INSIDE THE HEAD</head>` tag than just put it inside the head tag in the `theme_header.php` or `header.php` of your theme – if it's not a child theme.
Place this snippet of code directly above the closing `</head>` tag in your header.php file.
```
<?php
if ( is_checkout() ||... |
260,507 | <p>I have a list of terms I'm displaying using "get_terms". Each term is linked so if the user clicks it, they go to the term archive page. </p>
<pre><code> <?php $terms = get_terms('category');t
echo '<ul>';
foreach ($terms as $term) {
echo '<li><a href="'.get_term_link($term).'">'.$term->n... | [
{
"answer_id": 260508,
"author": "Ian",
"author_id": 11583,
"author_profile": "https://wordpress.stackexchange.com/users/11583",
"pm_score": 3,
"selected": false,
"text": "<p>Run a conditional check in the <code>foreach</code> loop using <code>is_category($term-name)</code></p>\n\n<p>Ass... | 2017/03/18 | [
"https://wordpress.stackexchange.com/questions/260507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21245/"
] | I have a list of terms I'm displaying using "get\_terms". Each term is linked so if the user clicks it, they go to the term archive page.
```
<?php $terms = get_terms('category');t
echo '<ul>';
foreach ($terms as $term) {
echo '<li><a href="'.get_term_link($term).'">'.$term->name.'</a></li>';
}
echo '</ul>';
?... | Run a conditional check in the `foreach` loop using `is_category($term-name)`
Assign a class variable to `active` if it's the same as `$term->name`
```
$terms = get_terms( 'category' );
echo '<ul>';
foreach ( $terms as $term ) {
$class = ( is_category( $term->name ) ) ? 'active' : ''; // assign this class if we'r... |
260,512 | <p>I am somewhat new in WordPress if it is about "deeper" customization.</p>
<p>Now I am having this function:</p>
<pre><code>esc_html_e( 'Dear Guest, with Your information we not find any room at the moment. Please contact us per email info@whitesandsamuiresort.com.', 'awebooking' );
</code></pre>
<p>And the... | [
{
"answer_id": 260513,
"author": "Aftab",
"author_id": 64614,
"author_profile": "https://wordpress.stackexchange.com/users/64614",
"pm_score": -1,
"selected": false,
"text": "<p>If you are using esc_html_e then this function simply says it escapes the HTML tags. So you can't be able to u... | 2017/03/18 | [
"https://wordpress.stackexchange.com/questions/260512",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115691/"
] | I am somewhat new in WordPress if it is about "deeper" customization.
Now I am having this function:
```
esc_html_e( 'Dear Guest, with Your information we not find any room at the moment. Please contact us per email info@whitesandsamuiresort.com.', 'awebooking' );
```
And the text is showing so far.
But what *func... | Since [`esc_html_e`](https://developer.wordpress.org/reference/functions/esc_html_e/) will escape HTML link (hence will show the HTML anchor as plain text), you'll need to segment the text and escape the non-HTML part with `esc_html_e` or [`esc_html__`](https://developer.wordpress.org/reference/functions/esc_html__/), ... |
260,519 | <p>I want to be able to detect if a file at a certain path is a WordPress generated thumbnail. The only distinguishing feature of the WordPress thumbnail, as far as individual files are concerned, is that it would end with two or three numbers, 'x', another two or three numbers and then the file extension. The only w... | [
{
"answer_id": 260543,
"author": "Irene Mitchell",
"author_id": 108769,
"author_profile": "https://wordpress.stackexchange.com/users/108769",
"pm_score": 2,
"selected": false,
"text": "<p>You need to know your site's current thumbnail dimension settings in order for you to detect if the ... | 2017/03/18 | [
"https://wordpress.stackexchange.com/questions/260519",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96964/"
] | I want to be able to detect if a file at a certain path is a WordPress generated thumbnail. The only distinguishing feature of the WordPress thumbnail, as far as individual files are concerned, is that it would end with two or three numbers, 'x', another two or three numbers and then the file extension. The only way I ... | You need to know your site's current thumbnail dimension settings in order for you to detect if the $url is of thumbnail size.
```
$thumbnail_width = get_option( 'thumbnail_size_w' );
$thumbnail_height = get_option( 'thumbnail_size_h' );
// The do detection
// Assuming you have the image $url
$pattern = '%' . $thumb... |
260,523 | <p>It is possible set display name from entered string into nickname registration field? I trying do this with simple hook, but after all it is not work.</p>
<pre><code>function set_default_display_name( $user_id ) {
$user = get_userdata( $user_id );
$name = $user->nickname;
$args = array(
'ID' => $use... | [
{
"answer_id": 260543,
"author": "Irene Mitchell",
"author_id": 108769,
"author_profile": "https://wordpress.stackexchange.com/users/108769",
"pm_score": 2,
"selected": false,
"text": "<p>You need to know your site's current thumbnail dimension settings in order for you to detect if the ... | 2017/03/18 | [
"https://wordpress.stackexchange.com/questions/260523",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84343/"
] | It is possible set display name from entered string into nickname registration field? I trying do this with simple hook, but after all it is not work.
```
function set_default_display_name( $user_id ) {
$user = get_userdata( $user_id );
$name = $user->nickname;
$args = array(
'ID' => $user_id,
'display_n... | You need to know your site's current thumbnail dimension settings in order for you to detect if the $url is of thumbnail size.
```
$thumbnail_width = get_option( 'thumbnail_size_w' );
$thumbnail_height = get_option( 'thumbnail_size_h' );
// The do detection
// Assuming you have the image $url
$pattern = '%' . $thumb... |
260,535 | <p>I am trying to add theme support for custom background using the following code in functions.php file:</p>
<pre><code>function supp_custom_bg() {
$defaults = array(
'default-color' => '',
'default-image' => '',
'wp-head-callback' => '_custom_background_cb... | [
{
"answer_id": 260541,
"author": "Irene Mitchell",
"author_id": 108769,
"author_profile": "https://wordpress.stackexchange.com/users/108769",
"pm_score": 0,
"selected": false,
"text": "<p>If you intend to customize how background image is implemented in your theme then do share the code ... | 2017/03/18 | [
"https://wordpress.stackexchange.com/questions/260535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109616/"
] | I am trying to add theme support for custom background using the following code in functions.php file:
```
function supp_custom_bg() {
$defaults = array(
'default-color' => '',
'default-image' => '',
'wp-head-callback' => '_custom_background_cb',
'admin-head-... | The simplest way to use this feature:
1. Add `add_theme_support( 'custom-background' );` to `functions.php`
2. Use `body_class()` in your `body` tag like this: `<body <?php body_class(); ?>>`
3. use `<?php wp_head(); ?>` in your `head` tag
if you go to the customizer should look like this:
[![enter image description... |
260,553 | <p>I'm trying to add url query parameters to all internal links inside a WordPress blog. For example, client lands on the blog with this link:</p>
<pre><code>www.example.com/?p1=test&p2=test
</code></pre>
<p>I want the links inside the blog, for example a link to a post, to still have the query strings:</p>
<pre... | [
{
"answer_id": 260554,
"author": "AppError",
"author_id": 113811,
"author_profile": "https://wordpress.stackexchange.com/users/113811",
"pm_score": 0,
"selected": false,
"text": "<p>So you want to \"keep\" the variable value? Maybe you're best to set a cookie? This would probably make th... | 2017/03/18 | [
"https://wordpress.stackexchange.com/questions/260553",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115654/"
] | I'm trying to add url query parameters to all internal links inside a WordPress blog. For example, client lands on the blog with this link:
```
www.example.com/?p1=test&p2=test
```
I want the links inside the blog, for example a link to a post, to still have the query strings:
```
www.example.com/post1/?p1=test&p2=... | The following is **not** a *complete* solution (i.e., as @cjbj mentioned, it won't handle links in post content), but it will achieve what you want for any link whose URL is obtained (in WP Core, a theme or a plugin) via [get\_permalink()](https://developer.wordpress.org/reference/functions/get_permalink/) (including t... |
260,586 | <p>I am trying to figure out a way to make a sum of all the posts displayed in a loop. For example:</p>
<pre><code><?php if (have_posts()) :
$total_count = 1;
while (have_posts()) : the_post();
echo $total_count;
endwhile;
endif;
?>
</code></pre>
<p>Returns: 1 1 1 1 1 1 1</p>
<p>Since there are 7 posts in... | [
{
"answer_id": 260587,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>If <code>have_posts()</code> is <code>true</code>, there is a global <code>WP_Query</code> object available. And that... | 2017/03/19 | [
"https://wordpress.stackexchange.com/questions/260586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21245/"
] | I am trying to figure out a way to make a sum of all the posts displayed in a loop. For example:
```
<?php if (have_posts()) :
$total_count = 1;
while (have_posts()) : the_post();
echo $total_count;
endwhile;
endif;
?>
```
Returns: 1 1 1 1 1 1 1
Since there are 7 posts in my loop. However, I would like to make... | If `have_posts()` is `true`, there is a global `WP_Query` object available. And that has a post count already:
```
if ( have_posts() )
{
print $GLOBALS['wp_query']->post_count;
}
```
There is no need for a custom count. |
260,596 | <p>Is this possible with a tinymce plugin? I think other ways to access the iframe are not working or not recommended.</p>
<p>I have <a href="https://www.tinymce.com/docs/api/tinymce.dom/tinymce.dom.domquery/" rel="nofollow noreferrer">found this</a> And tried that in the printing mce plugin <a href="https://plugins.t... | [
{
"answer_id": 262238,
"author": "Abhishek Pandey",
"author_id": 114826,
"author_profile": "https://wordpress.stackexchange.com/users/114826",
"pm_score": 3,
"selected": true,
"text": "<p>Hope You can use fallowing </p>\n\n<pre><code>// Sets class attribute on all paragraphs in the activ... | 2017/03/19 | [
"https://wordpress.stackexchange.com/questions/260596",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38602/"
] | Is this possible with a tinymce plugin? I think other ways to access the iframe are not working or not recommended.
I have [found this](https://www.tinymce.com/docs/api/tinymce.dom/tinymce.dom.domquery/) And tried that in the printing mce plugin [inside the TinyMCE Advanced plugin but it does not work](https://plugins... | Hope You can use fallowing
```
// Sets class attribute on all paragraphs in the active editor
tinymce.activeEditor.dom.setAttrib(tinymce.activeEditor.dom.select('p'), 'class', 'myclass');
// Sets class attribute on a specific element in the current page
tinymce.dom.setAttrib('mydiv', 'class', 'myclass');
```
or Yo... |
260,615 | <p>I have on my page section with randomly selected posts via <code>new WP_Query</code>. The problem is that <code>'posts_per_page'</code> attribute don't work. Here is my code:</p>
<pre><code><div id="featured">
<?php
$args = array(
'post_type' => 'post',
'orderby' ... | [
{
"answer_id": 260617,
"author": "X9DESIGN",
"author_id": 84343,
"author_profile": "https://wordpress.stackexchange.com/users/84343",
"pm_score": 1,
"selected": false,
"text": "<p>I dont why, but after some tests i trying to use also <code>get_posts()</code> function and all is works fin... | 2017/03/19 | [
"https://wordpress.stackexchange.com/questions/260615",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84343/"
] | I have on my page section with randomly selected posts via `new WP_Query`. The problem is that `'posts_per_page'` attribute don't work. Here is my code:
```
<div id="featured">
<?php
$args = array(
'post_type' => 'post',
'orderby' => 'rand',
'posts_per_page' => 4,
... | `nopaging` disables pagination, and `posts_per_page` is a pagination parameter. You are telling it to ignore pagination and return all posts. |
260,620 | <p>I'm trying to add a CSS class to a comment and everything seems to work if the comment id was hard coded in. However it's not working because I don't know how to get the comment id and then from there, get the comment meta stored in the database.</p>
<p>in <code>wp_commentmeta</code> I have the following data:</p>
... | [
{
"answer_id": 260617,
"author": "X9DESIGN",
"author_id": 84343,
"author_profile": "https://wordpress.stackexchange.com/users/84343",
"pm_score": 1,
"selected": false,
"text": "<p>I dont why, but after some tests i trying to use also <code>get_posts()</code> function and all is works fin... | 2017/03/19 | [
"https://wordpress.stackexchange.com/questions/260620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm trying to add a CSS class to a comment and everything seems to work if the comment id was hard coded in. However it's not working because I don't know how to get the comment id and then from there, get the comment meta stored in the database.
in `wp_commentmeta` I have the following data:
```
meta_id
1
comment_i... | `nopaging` disables pagination, and `posts_per_page` is a pagination parameter. You are telling it to ignore pagination and return all posts. |
260,652 | <p>I originally installed wordpress in a subdirectory called /blog. Today I decided to change the URL of my site to remove the /blog element from the URL e.g. from www.mywebsite.com/blog to www.mywebsite.com. Here is what I did:</p>
<ol>
<li>went to settings > general and changed the site address:</li>
</ol>
<p>WordP... | [
{
"answer_id": 260656,
"author": "bynicolas",
"author_id": 99217,
"author_profile": "https://wordpress.stackexchange.com/users/99217",
"pm_score": 0,
"selected": false,
"text": "<p>You need to update all the links in your database as well</p>\n\n<p>You need to use something like <a href=... | 2017/03/20 | [
"https://wordpress.stackexchange.com/questions/260652",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115767/"
] | I originally installed wordpress in a subdirectory called /blog. Today I decided to change the URL of my site to remove the /blog element from the URL e.g. from www.mywebsite.com/blog to www.mywebsite.com. Here is what I did:
1. went to settings > general and changed the site address:
WordPress Address (URL): www.myw... | Please use this query in your Database using PhpMyAdmin
`UPDATE wp_options SET option_value = REPLACE(option_value, 'oldsite.com', 'newsite.com');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'oldsite.com', 'newsite.com');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'oldsite.com', 'newsite.com... |
260,665 | <p>I am working on custom plugin. I need to insert currency names and symbols in table on plugin activation. Right now my database insertion code is :</p>
<pre><code> global $wpdb;
$table_name1 = $wpdb->prefix . "woo_currency";
$curr_name = array('Dollars', 'Ruble', 'Riel');
$curr_symbol = array('$',... | [
{
"answer_id": 260656,
"author": "bynicolas",
"author_id": 99217,
"author_profile": "https://wordpress.stackexchange.com/users/99217",
"pm_score": 0,
"selected": false,
"text": "<p>You need to update all the links in your database as well</p>\n\n<p>You need to use something like <a href=... | 2017/03/20 | [
"https://wordpress.stackexchange.com/questions/260665",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/88892/"
] | I am working on custom plugin. I need to insert currency names and symbols in table on plugin activation. Right now my database insertion code is :
```
global $wpdb;
$table_name1 = $wpdb->prefix . "woo_currency";
$curr_name = array('Dollars', 'Ruble', 'Riel');
$curr_symbol = array('$', 'p.', '៛');
... | Please use this query in your Database using PhpMyAdmin
`UPDATE wp_options SET option_value = REPLACE(option_value, 'oldsite.com', 'newsite.com');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'oldsite.com', 'newsite.com');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'oldsite.com', 'newsite.com... |
260,669 | <p>I would like to limit the +New admin menu to only show the single sub menu Event ("Veranstaltung").
Basically the users are allowed to create other items as well but not from that +New menu. </p>
<p><a href="https://i.stack.imgur.com/mNFRB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mNFRB.png... | [
{
"answer_id": 260671,
"author": "mukto90",
"author_id": 57944,
"author_profile": "https://wordpress.stackexchange.com/users/57944",
"pm_score": 4,
"selected": true,
"text": "<p><strong>To hide everything (menu and submenu)-</strong></p>\n\n<pre><code>function wpse_260669_remove_new_cont... | 2017/03/20 | [
"https://wordpress.stackexchange.com/questions/260669",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115781/"
] | I would like to limit the +New admin menu to only show the single sub menu Event ("Veranstaltung").
Basically the users are allowed to create other items as well but not from that +New menu.
[](https://i.stack.imgur.com/mNFRB.png)
I already tried it with "Admini... | **To hide everything (menu and submenu)-**
```
function wpse_260669_remove_new_content(){
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'new-content' );
}
add_action( 'wp_before_admin_bar_render', 'wpse_260669_remove_new_content' );
```
**To hide specific menu/submenu item(s)-**
```
function wpse_260669... |
260,678 | <p>I have "Color Filters for WooCommerce" plugin and "color" taxonomy.</p>
<p>Each taxonomy have one custom field - color picker.</p>
<p>I want to display on archive page current color picker value of each product's.</p>
<p>I can call </p>
<pre><code>get_option( 'nm_taxonomy_colors' );
</code></pre>
<p>And I'll ge... | [
{
"answer_id": 260711,
"author": "1naveengiri",
"author_id": 114894,
"author_profile": "https://wordpress.stackexchange.com/users/114894",
"pm_score": 0,
"selected": false,
"text": "<p>you can use it like this.</p>\n\n<pre><code>$saved_colors = get_option( 'nm_taxonomy_colors' );\n//just... | 2017/03/20 | [
"https://wordpress.stackexchange.com/questions/260678",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98449/"
] | I have "Color Filters for WooCommerce" plugin and "color" taxonomy.
Each taxonomy have one custom field - color picker.
I want to display on archive page current color picker value of each product's.
I can call
```
get_option( 'nm_taxonomy_colors' );
```
And I'll get all values from this field, but I need only c... | The author of plugin help me with that. Thanks all.
```
global $post;
$product_colors = get_the_terms( $post, 'product_color' );
$saved_colors = get_option( 'nm_taxonomy_colors' );
if(isset($product_colors) && is_array($product_colors)){
foreach($product_colors as $color){
... |
260,682 | <p>Hi I am using a Ubuntu system. I am using a shell script to download wordpress from wget, update config and run it from nginx server. </p>
<p>Now I want to update this shell script so that when we install a fresh copy of WordPress, I get some plugins pre-installed.
So I installed wp-cli and ran the command</p>
<p... | [
{
"answer_id": 260691,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>Caching plugins usually require some additional manual work in moving some files from the plugin director... | 2017/03/20 | [
"https://wordpress.stackexchange.com/questions/260682",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115798/"
] | Hi I am using a Ubuntu system. I am using a shell script to download wordpress from wget, update config and run it from nginx server.
Now I want to update this shell script so that when we install a fresh copy of WordPress, I get some plugins pre-installed.
So I installed wp-cli and ran the command
```
wp plugin in... | Caching plugins usually require some additional manual work in moving some files from the plugin directory to the root of the `wp-content` directory and maybe some `wp-config.php` changes. It is possible that the plugin fails to initialize due to that. |
260,701 | <p>In my theme, jQuery is loaded in the header by default. I even dequed it in my <code>functions.php</code> but still in the header I have the jquery : </p>
<pre><code>function remove_jquery_migrate( &$scripts){
if(!is_admin()){
$scripts->remove( 'jquery');
$scripts->add( 'jquery', false... | [
{
"answer_id": 260704,
"author": "The J",
"author_id": 98010,
"author_profile": "https://wordpress.stackexchange.com/users/98010",
"pm_score": 2,
"selected": true,
"text": "<p>An example on how to deregister a WordPress built-in library and load your own:</p>\n\n<pre><code>function load_... | 2017/03/20 | [
"https://wordpress.stackexchange.com/questions/260701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115810/"
] | In my theme, jQuery is loaded in the header by default. I even dequed it in my `functions.php` but still in the header I have the jquery :
```
function remove_jquery_migrate( &$scripts){
if(!is_admin()){
$scripts->remove( 'jquery');
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.2.1' )... | An example on how to deregister a WordPress built-in library and load your own:
```
function load_custom_scripts() {
wp_deregister_script( 'jquery' );
wp_register_script('jquery', '//code.jquery.com/jquery-2.2.4.min.js', array(), '2.2.4', true); // true will place script in the footer
wp_enqueue_script( 'j... |
260,713 | <p>Working on a site that has a lot of posts, I need to display 3 posts from a particular category, but all of them need to be from the latest 10 published on the site. I can either grab 3 completely random posts (which tends to pull posts that are very old) or grab 10 posts (but I don't know how to then randomize the ... | [
{
"answer_id": 260720,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 5,
"selected": true,
"text": "<p>There's one way with:</p>\n\n<pre><code>$args = [\n 'post_type' => 'post',\n 'posts_per_p... | 2017/03/20 | [
"https://wordpress.stackexchange.com/questions/260713",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102815/"
] | Working on a site that has a lot of posts, I need to display 3 posts from a particular category, but all of them need to be from the latest 10 published on the site. I can either grab 3 completely random posts (which tends to pull posts that are very old) or grab 10 posts (but I don't know how to then randomize the ord... | There's one way with:
```
$args = [
'post_type' => 'post',
'posts_per_page' => 10,
'orderby' => 'date',
'order' => 'DESC',
'no_found_rows' => 'true',
'_shuffle_and_pick' => 3 // <-- our custom argument
];
$query = new \WP_Query( $arg... |
260,739 | <pre><code>$args = array(
//'post_type' => 'article',
'posts_per_page' => 5,
'category' => 'starter',
'meta_query' => array(
array(
'key' => 'recommended_article',
'value' => '1',
'compare' => '=='
... | [
{
"answer_id": 260742,
"author": "Paul 'Sparrow Hawk' Biron",
"author_id": 113496,
"author_profile": "https://wordpress.stackexchange.com/users/113496",
"pm_score": 1,
"selected": false,
"text": "<p>Your question is <strong>very</strong> unclear (given that you don't actually ask a quest... | 2017/03/20 | [
"https://wordpress.stackexchange.com/questions/260739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115834/"
] | ```
$args = array(
//'post_type' => 'article',
'posts_per_page' => 5,
'category' => 'starter',
'meta_query' => array(
array(
'key' => 'recommended_article',
'value' => '1',
'compare' => '=='
)
)
);
$q... | Your question is **very** unclear (given that you don't actually ask a question), but there are 2 problems with your code, both of which are corrected below:
```
$args = array (
//'post_type' => 'article',
'posts_per_page' => 5,
'category_name' => 'starter', // changed from 'category' to 'category_name... |
260,756 | <p>Does anyone know how I would automatically add <code><div class="table-responsive"></code> before every instance of a <code><table></code> on a WordPress site using filter referencing? I would also need to add a <code></div></code> to every instance of <code></table></code> as well.</p>
| [
{
"answer_id": 260758,
"author": "Nathan Johnson",
"author_id": 106269,
"author_profile": "https://wordpress.stackexchange.com/users/106269",
"pm_score": 2,
"selected": false,
"text": "<p>You can filter <code>the_content</code> and use <code>preg_replace()</code> to look for instances of... | 2017/03/20 | [
"https://wordpress.stackexchange.com/questions/260756",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94729/"
] | Does anyone know how I would automatically add `<div class="table-responsive">` before every instance of a `<table>` on a WordPress site using filter referencing? I would also need to add a `</div>` to every instance of `</table>` as well. | You can filter `the_content` and use `preg_replace()` to look for instances of `<table></table>` and then surround them with your `<div>`.
```
add_action( 'the_content', 'wpse_260756_the_content', 10, 1 );
function wpse_260756_the_content( $content ) {
$pattern = "/<table(.*?)>(.*?)<\/table>/i";
$replacement = '<d... |
260,773 | <p>I'm inexperienced with ajax. I'm building a form that will allow the user to grab a custom post type from the first field that will return the value of the post ID. Then, I'd like ajax to take that post ID and build a second dropdown based on some custom fields for that post. </p>
<p>Here's what I have so far, whi... | [
{
"answer_id": 261162,
"author": "scott",
"author_id": 93587,
"author_profile": "https://wordpress.stackexchange.com/users/93587",
"pm_score": 3,
"selected": true,
"text": "<p>In <code>dynamic_dropdown_func()</code>, at the end try <code>echo $event_dates;</code> instead of <code>return ... | 2017/03/20 | [
"https://wordpress.stackexchange.com/questions/260773",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2041/"
] | I'm inexperienced with ajax. I'm building a form that will allow the user to grab a custom post type from the first field that will return the value of the post ID. Then, I'd like ajax to take that post ID and build a second dropdown based on some custom fields for that post.
Here's what I have so far, which was adap... | In `dynamic_dropdown_func()`, at the end try `echo $event_dates;` instead of `return $event_dates;`.
Also, I'm wondering why you declare `global $wpdb;` when you don't seem to use it? |
260,789 | <p>So i'm adding a script into my site via <code>functions.php</code> that lives in the plugins directory. The code is pretty straightforward:</p>
<pre><code>function add_jq_script() {
wp_register_script('r_footer', plugins_url('/responsiveFooter.js', __FILE__), array('jquery'),'1.1', true);
wp_enqueue_scri... | [
{
"answer_id": 260790,
"author": "mukto90",
"author_id": 57944,
"author_profile": "https://wordpress.stackexchange.com/users/57944",
"pm_score": 0,
"selected": false,
"text": "<p>You have used wrong callable function in <code>add_action()</code>. Your code should be something like this-<... | 2017/03/21 | [
"https://wordpress.stackexchange.com/questions/260789",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106975/"
] | So i'm adding a script into my site via `functions.php` that lives in the plugins directory. The code is pretty straightforward:
```
function add_jq_script() {
wp_register_script('r_footer', plugins_url('/responsiveFooter.js', __FILE__), array('jquery'),'1.1', true);
wp_enqueue_script('r_footer');
}
add_... | `plugins_url` will output the absolute file path of the plugins directory in your WordPress install.
This of course won't work for a client (browser) calling a script.
To access scripts from the plugins directory, you'll want to use `plugin_dir_url()` which will get you the url of the plugin directory.
**Some thing... |
260,800 | <p>I want to save my form data via jquery but i can't able to access it in my script.Can anyone help me.
URL access in script: <strong>url: 'admin.php?page=insert.php',</strong></p>
<p>My script</p>
<pre><code>$(function () {
$('form').on('submit', function (e) {
e.preventDefault();
var s... | [
{
"answer_id": 260793,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>Prefixes are used to avoid conflicts. If your framework is used to build a theme, the chances are high that there isn'... | 2017/03/21 | [
"https://wordpress.stackexchange.com/questions/260800",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114992/"
] | I want to save my form data via jquery but i can't able to access it in my script.Can anyone help me.
URL access in script: **url: 'admin.php?page=insert.php',**
My script
```
$(function () {
$('form').on('submit', function (e) {
e.preventDefault();
var schema_key = $("#schema_key").val();... | Prefixes are used to avoid conflicts. If your framework is used to build a theme, the chances are high that there isn't a second theme framework in use at the same time. So there is no conflict, and therefore no need for a prefix.
The exception are CSS classes generated by the WordPress core, for example in the commen... |
260,813 | <p>I'm working to optimize a site that I've recently taken management of, and it appears to me that there are a fair few unused templates. I want to remove all the unused and redundant template files so that we can focus our developments on those templates we do support, however there are 100+ pages and posts on this s... | [
{
"answer_id": 260836,
"author": "Netanel Perez",
"author_id": 114386,
"author_profile": "https://wordpress.stackexchange.com/users/114386",
"pm_score": -1,
"selected": false,
"text": "<p>You mean something like this?</p>\n\n<pre><code>$args = array(\n 'meta_key' => '_wp_page_templ... | 2017/03/21 | [
"https://wordpress.stackexchange.com/questions/260813",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115867/"
] | I'm working to optimize a site that I've recently taken management of, and it appears to me that there are a fair few unused templates. I want to remove all the unused and redundant template files so that we can focus our developments on those templates we do support, however there are 100+ pages and posts on this site... | Here's a rough function I use to handle this, it should work well for anyone out there wanting to do this quick and easy. Add this this your functions.php file and then visit your site with `?template_report` added onto the URL to display a report for every custom theme template.
**It's rough, I'd suggest commenting/u... |
260,826 | <p>Say I have a user meta field that is called "meta1".
I want to get posts (via get_posts or the like) who's author meta1 = true.
Any idea how I should approach this?</p>
| [
{
"answer_id": 260832,
"author": "Netanel Perez",
"author_id": 114386,
"author_profile": "https://wordpress.stackexchange.com/users/114386",
"pm_score": 0,
"selected": false,
"text": "<p>You can define it in the loop's arguments and i believe it will work with other WP functions as well<... | 2017/03/21 | [
"https://wordpress.stackexchange.com/questions/260826",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115876/"
] | Say I have a user meta field that is called "meta1".
I want to get posts (via get\_posts or the like) who's author meta1 = true.
Any idea how I should approach this? | Get for all users / authors with user meta field. `meta1 = true`
```
$args = array(
'meta_key' => 'meta1',
'meta_value' => 'true',
'meta_compare' => '=',
'fields' => 'all',
);
$users = get_users( $args );
```
Store user id and login into an array `authors`
```
$authors = array();
foreac... |
260,828 | <p>I've built a membership site where users can post listings from the frontend, edit those, and ideally also delete them.</p>
<p>For the latter, I'd like to echo a "delete post" link to the frontend. The problem is that <code>get_delete_post_link()</code>.</p>
<p>So from this:
<code>
$theID = get_the_ID(); // inside... | [
{
"answer_id": 260830,
"author": "Netanel Perez",
"author_id": 114386,
"author_profile": "https://wordpress.stackexchange.com/users/114386",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li><p>get_delete_post_link() Should work without parameters if you are using it inside the loop</... | 2017/03/21 | [
"https://wordpress.stackexchange.com/questions/260828",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/104550/"
] | I've built a membership site where users can post listings from the frontend, edit those, and ideally also delete them.
For the latter, I'd like to echo a "delete post" link to the frontend. The problem is that `get_delete_post_link()`.
So from this:
`$theID = get_the_ID(); // inside loop
echo $theID;
<a href="<?php ... | 1. get\_delete\_post\_link() Should work without parameters if you are using it inside the loop
2. I believe that you need to remove your wp\_reset\_query() that is placed before the if( $the\_query->have\_posts().. |
260,850 | <p>I would like to list out the child terms related to the taxonomy archive and then list posts belonging to the child terms below the term name.</p>
<p>I currently have the following code which successfully lists out the child terms.</p>
<pre><code>$this_term = get_queried_object();
$args = array(
'parent' => $t... | [
{
"answer_id": 260858,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 0,
"selected": false,
"text": "<p>You need another query that will find the posts associated with each child term, the post-containing <cod... | 2017/03/21 | [
"https://wordpress.stackexchange.com/questions/260850",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83253/"
] | I would like to list out the child terms related to the taxonomy archive and then list posts belonging to the child terms below the term name.
I currently have the following code which successfully lists out the child terms.
```
$this_term = get_queried_object();
$args = array(
'parent' => $this_term->term_id,
'orde... | I was able to get this working with the following code. I used the relation operator AND, referenced the var ($this\_term) that contained get\_queried\_object(); to set the taxonomy in the tax\_query and adjusted the term field in the tax\_query.
```
$this_term = get_queried_object();
$args = array(
'parent' => $th... |
260,854 | <p>It might be a stupid question, but I can't get it to work..</p>
<p><strong>Problem</strong><br>
I have no idea how to link my image on the frontend with the url from the database.</p>
<p><strong>Situation</strong><br>
I've created a Custom Post Type called 'Banners'. On each post I'm able to add a featured image. ... | [
{
"answer_id": 260855,
"author": "Bruno Cantuaria",
"author_id": 65717,
"author_profile": "https://wordpress.stackexchange.com/users/65717",
"pm_score": 1,
"selected": false,
"text": "<p>You are looking for <code>get_post_meta()</code></p>\n\n<p>Your loop should look like:</p>\n\n<pre><c... | 2017/03/21 | [
"https://wordpress.stackexchange.com/questions/260854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115316/"
] | It might be a stupid question, but I can't get it to work..
**Problem**
I have no idea how to link my image on the frontend with the url from the database.
**Situation**
I've created a Custom Post Type called 'Banners'. On each post I'm able to add a featured image. This will be saved in my database. Also on ea... | Do you need to query only the items that has `banner_link` value set to `https://www.mypage.com` ?
If no, you can remove the `meta_query` part from your query.
```
<?php
// function to show home page banner using query of banner post type
function wptutsplus_home_page_banner() {
// start by setting up the query
$ge... |
260,871 | <p>I'm trying to display content from SQL tables, using <code>$wpdb</code> object.
Problem is, whatever I try using it in my query, it prints a SQL error.
What I tried to do is a little more complex than what I'll show you, but I progressively simplified my query to see where the error could come from, but never found.... | [
{
"answer_id": 260874,
"author": "Anwer AR",
"author_id": 83820,
"author_profile": "https://wordpress.stackexchange.com/users/83820",
"pm_score": 3,
"selected": true,
"text": "<p>its a syntax error according to error message. starements like below might work for you.</p>\n\n<pre><code>gl... | 2017/03/21 | [
"https://wordpress.stackexchange.com/questions/260871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105987/"
] | I'm trying to display content from SQL tables, using `$wpdb` object.
Problem is, whatever I try using it in my query, it prints a SQL error.
What I tried to do is a little more complex than what I'll show you, but I progressively simplified my query to see where the error could come from, but never found.
So here's wh... | its a syntax error according to error message. starements like below might work for you.
```
global $wpdb;
$wpdb->show_errors();
$tableCustom = 'join_users_defis';
$sql = "SELECT * FROM {$wpdb->postmeta}";
$requeteAffichage = $wpdb->get_row( $sql );
//or $requeteAffichage = $wpdb->get_results( $sql );
var_dump($req... |
260,893 | <p>I'm trying to create a dropdown of WordPress authors, with links to their author page.</p>
<p>Here is my current code:</p>
<pre><code><?php wp_dropdown_users(array('who'=>'authors')); ?>
</code></pre>
<p>I've got a similar dropdown for my archives, which is below (and works). </p>
<pre><code><select... | [
{
"answer_id": 260904,
"author": "Sam",
"author_id": 115586,
"author_profile": "https://wordpress.stackexchange.com/users/115586",
"pm_score": 3,
"selected": true,
"text": "<p>I could be wrong as I don't know how Wordpress controls the dropdown menu but looks like it could be only return... | 2017/03/21 | [
"https://wordpress.stackexchange.com/questions/260893",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115915/"
] | I'm trying to create a dropdown of WordPress authors, with links to their author page.
Here is my current code:
```
<?php wp_dropdown_users(array('who'=>'authors')); ?>
```
I've got a similar dropdown for my archives, which is below (and works).
```
<select name="archive-dropdown" id="archives-dropdown--1" onchan... | I could be wrong as I don't know how Wordpress controls the dropdown menu but looks like it could be only returning a name of the author and not a link to their page.
I have tested the below code in a Wordpress site environment and works including linking to the authors page.
```
<select name="author-dropdown" id=... |
260,916 | <p>Sorry to have to ask this, but I have searched and searched and can't seem to figure out how to do this...</p>
<p>I have this code on a custom PHP page:</p>
<pre><code>(code placeholder spot which I will reference later)
$races = $wpdb->get_results("
select r.race_name
,r.race_id
... | [
{
"answer_id": 260904,
"author": "Sam",
"author_id": 115586,
"author_profile": "https://wordpress.stackexchange.com/users/115586",
"pm_score": 3,
"selected": true,
"text": "<p>I could be wrong as I don't know how Wordpress controls the dropdown menu but looks like it could be only return... | 2017/03/21 | [
"https://wordpress.stackexchange.com/questions/260916",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112305/"
] | Sorry to have to ask this, but I have searched and searched and can't seem to figure out how to do this...
I have this code on a custom PHP page:
```
(code placeholder spot which I will reference later)
$races = $wpdb->get_results("
select r.race_name
,r.race_id
,date_format(r.race_date... | I could be wrong as I don't know how Wordpress controls the dropdown menu but looks like it could be only returning a name of the author and not a link to their page.
I have tested the below code in a Wordpress site environment and works including linking to the authors page.
```
<select name="author-dropdown" id=... |
260,924 | <p>I'm trying to clean up a WordPress website that's been hacked. I noticed that the <code>.htaccess</code> file has some suspect looking regular expressions, but my regex skills are pretty weak (time to learn I guess). I've tried replacing the <code>.htaccess</code> file with the default WordPress <code>.htaccess</c... | [
{
"answer_id": 262364,
"author": "Piero",
"author_id": 114816,
"author_profile": "https://wordpress.stackexchange.com/users/114816",
"pm_score": -1,
"selected": false,
"text": "<p>One of the best solution I've found is to install <a href=\"https://it.wordpress.org/plugins/wordfence/\" re... | 2017/03/22 | [
"https://wordpress.stackexchange.com/questions/260924",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115935/"
] | I'm trying to clean up a WordPress website that's been hacked. I noticed that the `.htaccess` file has some suspect looking regular expressions, but my regex skills are pretty weak (time to learn I guess). I've tried replacing the `.htaccess` file with the default WordPress `.htaccess`, but it gets rewritten immediatel... | ### About Hacked sites:
First of all, let's be clear about issues related to hacking:
>
> If your site was genuinely hacked, then in short of completely erasing all the files and then reinstalling the server (not just WordPress) with new passwords, updating all files and identifying and removing previous loop holes ... |
260,933 | <p>In order to increase my theme's accessibility, I want to add the <code>aria-current="page"</code> attribute to the menu item that has the class <code>.current_page_item</code>.</p>
<p>As of right now, I am doing this via jQuery using the following:</p>
<pre><code>var currentitem = $( '.current_page_item > a' );... | [
{
"answer_id": 260934,
"author": "Yoav Kadosh",
"author_id": 25959,
"author_profile": "https://wordpress.stackexchange.com/users/25959",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the filter <code>nav_menu_link_attributes</code> to achieve that:</p>\n\n<pre><code>function ... | 2017/03/22 | [
"https://wordpress.stackexchange.com/questions/260933",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80069/"
] | In order to increase my theme's accessibility, I want to add the `aria-current="page"` attribute to the menu item that has the class `.current_page_item`.
As of right now, I am doing this via jQuery using the following:
```
var currentitem = $( '.current_page_item > a' );
currentitem.attr( 'aria-current', 'page' );
... | You may target the `current_page_item` CSS class or you may target the `current-menu-item` CSS class instead. `current_page_item` class may not be present for all kinds of menu item. Read [the answer here](https://wordpress.stackexchange.com/questions/14978/whats-the-difference-between-current-page-item-and-current-men... |
260,941 | <p>We all know that <code>ignore_sticky_posts</code> is used to exclude sticky post from your custom query.</p>
<p>But why on <a href="https://developer.wordpress.org/themes/functionality/sticky-posts/" rel="nofollow noreferrer">WordPress Theme Development documentation</a>, they use <code>ignore_sticky_posts</code> in... | [
{
"answer_id": 260951,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 6,
"selected": true,
"text": "<blockquote>\n <p>We all know that <code>ignore_sticky_posts</code> is used to exclude sticky post from your cus... | 2017/03/22 | [
"https://wordpress.stackexchange.com/questions/260941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105000/"
] | We all know that `ignore_sticky_posts` is used to exclude sticky post from your custom query.
But why on [WordPress Theme Development documentation](https://developer.wordpress.org/themes/functionality/sticky-posts/), they use `ignore_sticky_posts` in querying sticky posts?
```php
$args = array(
'posts_per_page' ... | >
> We all know that `ignore_sticky_posts` is used to exclude sticky post from your custom query.
>
>
>
### - No, this assumption is wrong.
---
What `ignore_sticky_posts` means:
---------------------------------
Even though in natural English, `ignore_sticky_posts` sounds like WordPress should ignore all sticky... |
260,952 | <p>I would like to have the possibility to create "sub single pages" to display detailed content in a custom post type.
Is there a way to generate pages, with a specific template with a URL of this type:</p>
<pre><code>domain.com/custom-post-type-slug/single-slug/sub-single-slug/
</code></pre>
<p>Note : I need multi... | [
{
"answer_id": 260957,
"author": "Scott",
"author_id": 111485,
"author_profile": "https://wordpress.stackexchange.com/users/111485",
"pm_score": 2,
"selected": false,
"text": "<p>First, you need to register the custom post type so that it has hierarchy, i.e. a post can have a parent post... | 2017/03/22 | [
"https://wordpress.stackexchange.com/questions/260952",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73871/"
] | I would like to have the possibility to create "sub single pages" to display detailed content in a custom post type.
Is there a way to generate pages, with a specific template with a URL of this type:
```
domain.com/custom-post-type-slug/single-slug/sub-single-slug/
```
Note : I need multiple sub-single pages for e... | Here is the solution (origin : <http://www.placementedge.com/blog/create-post-sub-pages/>)
```
// Fake pages' permalinks and titles. Change these to your required sub pages.
$my_fake_pages = array(
'reviews' => 'Reviews',
'purchase' => 'Purchase',
'author' => 'Author Bio'
);
add_filter('rewrite_rules_arra... |
260,998 | <p>I have custom post type of <code>portfolio</code> and I would like to be able to re-use most of the templating, but change to <code>content-portfolio</code> when the page is a custom post type named <code>portfolio</code>.</p>
<p>At present this is not working, so I'm not sure if I need to add Custom Post Types in ... | [
{
"answer_id": 260966,
"author": "Scott",
"author_id": 111485,
"author_profile": "https://wordpress.stackexchange.com/users/111485",
"pm_score": 1,
"selected": false,
"text": "<p>Usually setting a post as sticky post sets it to the featured area. From wp-admin editor, set a post as stick... | 2017/03/22 | [
"https://wordpress.stackexchange.com/questions/260998",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105914/"
] | I have custom post type of `portfolio` and I would like to be able to re-use most of the templating, but change to `content-portfolio` when the page is a custom post type named `portfolio`.
At present this is not working, so I'm not sure if I need to add Custom Post Types in the Main Query or add it inside the while l... | I note you are using the **Minamaze** theme, correct? The problem here is the featured area, is exactly that, an area to manually enter featured content. You cannot automatically add posts to these areas.
To configure them, you need to go into the admin, choose appearance, then customize.
In here, choose Theme Option... |
261,038 | <p>I'd like to limit search to characters used on the English language + numbers.
The reason is that looking at the slowest queries on mysql log i found most come from searches in Arab, Russian and Chinese characters, so i'd like to skip them and display an error message instead.</p>
| [
{
"answer_id": 261303,
"author": "Cedon",
"author_id": 80069,
"author_profile": "https://wordpress.stackexchange.com/users/80069",
"pm_score": 2,
"selected": false,
"text": "<p>You would do this by putting in a validation function in PHP to test the input against a regular expression lik... | 2017/03/22 | [
"https://wordpress.stackexchange.com/questions/261038",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77283/"
] | I'd like to limit search to characters used on the English language + numbers.
The reason is that looking at the slowest queries on mysql log i found most come from searches in Arab, Russian and Chinese characters, so i'd like to skip them and display an error message instead. | This solution filters search strings by applying a regular expression which only matches characters from the Common and Latin Unicode scripts.
---
Matching Latin Characters with Regular Expressions
--------------------------------------------------
I just [had my mind blown over at Stack Overflow](https://stackoverf... |
261,042 | <p>First, I want to clarify - <strong>this is not a CSS question.</strong> </p>
<p>I want to change the data that is showing of the widget, when its in closed / open mode inside the wp-admin, in a sidebar or a page builder. Here is an image to better explain.</p>
<p><a href="https://i.stack.imgur.com/bBXNY.jpg" rel="... | [
{
"answer_id": 261346,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": false,
"text": "<p>Let's first see whether it is possible to change the information that is displayed in the widget titles in admin... | 2017/03/22 | [
"https://wordpress.stackexchange.com/questions/261042",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7990/"
] | First, I want to clarify - **this is not a CSS question.**
I want to change the data that is showing of the widget, when its in closed / open mode inside the wp-admin, in a sidebar or a page builder. Here is an image to better explain.
[](https://i.... | Background:
-----------
The reason why filtering with `dynamic_sidebar_params` doesn't work with `HTML` is because WordPress strips `HTML` from Widget Heading in [`wp_widget_control()`](https://github.com/WordPress/WordPress/blob/4.7/wp-admin/includes/widgets.php#L216) function like this:
```
$widget_title = esc_html... |
261,043 | <p>I am using <a href="https://en-ca.wordpress.org/plugins/custom-list-table-example/" rel="nofollow noreferrer">the Custom List Table Example plugin</a> as a basis to create my own custom list table. Everything is great, except one thorny point.</p>
<p>When I am processing bulk actions via the <code>process_bulk_acti... | [
{
"answer_id": 272339,
"author": "Abhilash Narayan",
"author_id": 123210,
"author_profile": "https://wordpress.stackexchange.com/users/123210",
"pm_score": -1,
"selected": false,
"text": "<p>echo 'document.location=\"'<a href=\"http://url/path.php?update=1&message=some_message\" rel=... | 2017/03/22 | [
"https://wordpress.stackexchange.com/questions/261043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34253/"
] | I am using [the Custom List Table Example plugin](https://en-ca.wordpress.org/plugins/custom-list-table-example/) as a basis to create my own custom list table. Everything is great, except one thorny point.
When I am processing bulk actions via the `process_bulk_action()` method, I would like to redirect using `wp_red... | Understand hierarchy, You don't need to redirect as form are posting values on same page.
```
function process_bulk_action() {
// Some security check code here
// Get the bulk action
$action = $this->current_action();
if ($action == 'bulk_trash') {
// Code for the "delete process"
$... |
261,080 | <p>Does anyone know how I can get rid of index.php in my URL?
Right now if I add a new page, the address will be:</p>
<p>www.mywebsite.com/index.php/page1</p>
<p>But I want it to be:</p>
<p>wwww.mywebsite.com/page1</p>
<p>I surfed the web a lot! Changing the permalink doesn't work. Does anyone know how I can fix th... | [
{
"answer_id": 261081,
"author": "Scott",
"author_id": 111485,
"author_profile": "https://wordpress.stackexchange.com/users/111485",
"pm_score": 3,
"selected": true,
"text": "<p>This is a classical case. All you need to do is to use Rewrite Rules. With Apache, you can do it in .htaccess:... | 2017/03/23 | [
"https://wordpress.stackexchange.com/questions/261080",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116068/"
] | Does anyone know how I can get rid of index.php in my URL?
Right now if I add a new page, the address will be:
www.mywebsite.com/index.php/page1
But I want it to be:
wwww.mywebsite.com/page1
I surfed the web a lot! Changing the permalink doesn't work. Does anyone know how I can fix this? | This is a classical case. All you need to do is to use Rewrite Rules. With Apache, you can do it in .htaccess:
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L... |
261,090 | <p>I was wondering, how do I hide pages from my navbar? </p>
<p>I don't mean hide visibility to private nor do I want to remove the page from appearance -> menus -> MY_MENU (as I have custom CSS on one of the pages). </p>
<p><a href="https://i.stack.imgur.com/E6pJz.png" rel="nofollow noreferrer"><img src="https://i.s... | [
{
"answer_id": 261091,
"author": "pomaaa",
"author_id": 115755,
"author_profile": "https://wordpress.stackexchange.com/users/115755",
"pm_score": 0,
"selected": false,
"text": "<p>First you need to check the class of the item that you want to hide. If it's .menu-item-346, just add this t... | 2017/03/23 | [
"https://wordpress.stackexchange.com/questions/261090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38839/"
] | I was wondering, how do I hide pages from my navbar?
I don't mean hide visibility to private nor do I want to remove the page from appearance -> menus -> MY\_MENU (as I have custom CSS on one of the pages).
[](https://i.stack.imgur.com/E6pJz.png)
just for re... | Instead of writing custom styles like `.menu-item-346` where you are hardcoding some styles...
why not just add a **custom css class** with the editor under `Appearance -> Menus`.
Wordpress has this build in.
Under `Appearance -> Menus` you need to open the `Screen Options` and tick the box `CSS Classes`.
After th... |
261,117 | <p>Devs</p>
<p>I have a WP-cronjob running that is supposed to import some pictures and set them as attachments for a specific post. But I'm apparently unable to do so while running it as a WP-cronjob - it works just fine when i run it on "init" for exampel. But as soon as i try to run it within a WP-cronjob it fails.... | [
{
"answer_id": 261124,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 2,
"selected": false,
"text": "<p>At the top of your cronjob script (for example: <code>my-cron.php</code>), do this:</p>\n<pre><code>if ( ! de... | 2017/03/23 | [
"https://wordpress.stackexchange.com/questions/261117",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116092/"
] | Devs
I have a WP-cronjob running that is supposed to import some pictures and set them as attachments for a specific post. But I'm apparently unable to do so while running it as a WP-cronjob - it works just fine when i run it on "init" for exampel. But as soon as i try to run it within a WP-cronjob it fails.
```
reg... | Some of what is usually admin side functionality is not included as part of the "main" wordpress bootstrap, files containing uploaded file manipulation functions are one of them and you need to explicitly include them by adding
```
include_once( ABSPATH . 'wp-admin/includes/image.php' );
```
into your `call_import` ... |
261,123 | <p>I am trying to change the logo one specific page of this wordpress site. <a href="http://staging-domesticbliss.transitiongraphics.co.uk/db-home-help/" rel="nofollow noreferrer">http://staging-domesticbliss.transitiongraphics.co.uk/db-home-help/</a></p>
<p>Currently I know I am targeting the right page and element a... | [
{
"answer_id": 261125,
"author": "Dan Knauss",
"author_id": 57078,
"author_profile": "https://wordpress.stackexchange.com/users/57078",
"pm_score": 0,
"selected": false,
"text": "<p>Logo settings are controlled through the WordPress customizer and administrator interface for most themes ... | 2017/03/23 | [
"https://wordpress.stackexchange.com/questions/261123",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116101/"
] | I am trying to change the logo one specific page of this wordpress site. <http://staging-domesticbliss.transitiongraphics.co.uk/db-home-help/>
Currently I know I am targeting the right page and element as I can hide the logo using:
```
.page-id-6935 .w-logo-img > img {
display:none;
}
```
But how do I now show... | Rather than using the tag in html, set the logo using the CSS background property. Use background-image:url(<http://staging-domesticbliss.transitiongraphics.co.uk/wp-content/uploads/2017/03/db-homehelp-black-xl.png>); instead. |
261,135 | <p>I would like to add a new menu item in the admin bar. So far, I have done the following:</p>
<pre><code>function add_book_menu_item ($wp_admin_bar) {
$args = array (
'id' => 'book',
'title' => 'Book',
'href' => 'http://example.com/',
'par... | [
{
"answer_id": 261125,
"author": "Dan Knauss",
"author_id": 57078,
"author_profile": "https://wordpress.stackexchange.com/users/57078",
"pm_score": 0,
"selected": false,
"text": "<p>Logo settings are controlled through the WordPress customizer and administrator interface for most themes ... | 2017/03/23 | [
"https://wordpress.stackexchange.com/questions/261135",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34253/"
] | I would like to add a new menu item in the admin bar. So far, I have done the following:
```
function add_book_menu_item ($wp_admin_bar) {
$args = array (
'id' => 'book',
'title' => 'Book',
'href' => 'http://example.com/',
'parent' => 'new-content... | Rather than using the tag in html, set the logo using the CSS background property. Use background-image:url(<http://staging-domesticbliss.transitiongraphics.co.uk/wp-content/uploads/2017/03/db-homehelp-black-xl.png>); instead. |
261,137 | <p>I would like to replace a textarea in a wordpress plugin with the wp editor if possible.
Here is the textarea code:</p>
<pre><code><textarea id="<?php echo esc_attr( $html['id'] ); ?>" class="awpcp-textarea required" <?php echo $html['readonly'] ? 'readonly="readonly"' : ''; ?> name="<?php echo es... | [
{
"answer_id": 261423,
"author": "Samyer",
"author_id": 112788,
"author_profile": "https://wordpress.stackexchange.com/users/112788",
"pm_score": 1,
"selected": false,
"text": "<p>You would need to edit the plugin and insert an instance of the wp_editor instead of that textarea.</p>\n\n<... | 2017/03/23 | [
"https://wordpress.stackexchange.com/questions/261137",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86094/"
] | I would like to replace a textarea in a wordpress plugin with the wp editor if possible.
Here is the textarea code:
```
<textarea id="<?php echo esc_attr( $html['id'] ); ?>" class="awpcp-textarea required" <?php echo $html['readonly'] ? 'readonly="readonly"' : ''; ?> name="<?php echo esc_attr( $html['name'] ); ?>" row... | You would need to edit the plugin and insert an instance of the wp\_editor instead of that textarea.
Refer to [the wp\_editor function reference](https://codex.wordpress.org/Function_Reference/wp_editor). |
261,147 | <p>I wrote the following lines of code. It shows a dropdown menu with all available Wordpress categorys in the Wordpress customizer and can output the category slug. But instead of the slug I want to output the category id. Does anyone have an idea how to realize that?</p>
<pre><code>$categories = get_categories();
$... | [
{
"answer_id": 261242,
"author": "LWS-Mo",
"author_id": 88895,
"author_profile": "https://wordpress.stackexchange.com/users/88895",
"pm_score": 1,
"selected": true,
"text": "<p>In your foreach loop just do a quick <code>print_r($category)</code> to see all available options.</p>\n\n<p>Th... | 2017/03/23 | [
"https://wordpress.stackexchange.com/questions/261147",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116113/"
] | I wrote the following lines of code. It shows a dropdown menu with all available Wordpress categorys in the Wordpress customizer and can output the category slug. But instead of the slug I want to output the category id. Does anyone have an idea how to realize that?
```
$categories = get_categories();
$cats = array()... | In your foreach loop just do a quick `print_r($category)` to see all available options.
Than you will see that you can use `$category->term_id` to get the `ID` of the term/category, instead of `$category->slug`.
So for example, by using your code from above:
```
$categories = get_categories();
$cats = array();
$i =... |
261,169 | <p>I have to create a shortcode so I can paste the shortcode inside the mobile menu plugin's options, the plugin doesn't accept PHP so I can't do <code><span class="header-cart-total"><?php echo edd_cart_total(); ?></span></code></p>
<p>The issue I'm having is echo'ing <code>edd_get_cart_total()</cod... | [
{
"answer_id": 261171,
"author": "Sam",
"author_id": 115586,
"author_profile": "https://wordpress.stackexchange.com/users/115586",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure as to where you are trying to insert your code and what limits it has but try it like this and se... | 2017/03/23 | [
"https://wordpress.stackexchange.com/questions/261169",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49532/"
] | I have to create a shortcode so I can paste the shortcode inside the mobile menu plugin's options, the plugin doesn't accept PHP so I can't do `<span class="header-cart-total"><?php echo edd_cart_total(); ?></span>`
The issue I'm having is echo'ing `edd_get_cart_total()` which causes a white screen on my website. I ha... | `echo` is a PHP language construct which pushes values to the output buffer. It does not have a return value, so concatenating it with a string would cause everything after the `echo` to immediately be sent to the output buffer, and everything prior to `echo` to compose the concatenated string. This is such a misuse of... |
261,177 | <p>Following the <a href="https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/" rel="nofollow noreferrer">Wordpress documentation about the Rest Api</a>, i can manage to make an ajax POST working, but only when logged in to Wordpress. Here are the basic files shown in the documentation:</p>
<h3... | [
{
"answer_id": 261185,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>The </p>\n\n<blockquote>\n <p>the_author()</p>\n</blockquote>\n\n<p>function should return the name o... | 2017/03/24 | [
"https://wordpress.stackexchange.com/questions/261177",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102982/"
] | Following the [Wordpress documentation about the Rest Api](https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/), i can manage to make an ajax POST working, but only when logged in to Wordpress. Here are the basic files shown in the documentation:
### functions.php
```
wp_localize_script( 'wp-a... | Here are three possible approaches:
1. A normal WP installation already has [custom fields](https://codex.wordpress.org/Custom_Fields) which you can add to your post. So you could use those to add the original author's name to. The only problem is that general themes usually do not display `the_meta`, because they do ... |
261,196 | <p>After months of leaving and deleting my WordPress site, I decided to try again. I downloaded the new version 4.7.3, installed and added a new post. So far so good. </p>
<p>I then went back to edit the post and the same error that I received before, cannot find the post; nothing to see here, message.</p>
<p>I canno... | [
{
"answer_id": 261210,
"author": "Self Designs",
"author_id": 75780,
"author_profile": "https://wordpress.stackexchange.com/users/75780",
"pm_score": 0,
"selected": false,
"text": "<p>You could try to reset the WordPress permalinks to see if this is causing the 404 error. Here is a usefu... | 2017/03/24 | [
"https://wordpress.stackexchange.com/questions/261196",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116145/"
] | After months of leaving and deleting my WordPress site, I decided to try again. I downloaded the new version 4.7.3, installed and added a new post. So far so good.
I then went back to edit the post and the same error that I received before, cannot find the post; nothing to see here, message.
I cannot edit any new po... | To do so .. You need to login to wordpress admin and then need to save the permalink again..
Just go to Settings >> Permalink
And save without doing any changes.. and that error should be gone.. |
261,226 | <p>I'm using ACF to display a class within a <code><header></code> tag. The code for this sits within header.php. The custom field appears across all page templates in WP admin. Here's how it's working on the front-end: </p>
<pre><code><header
class="site-header
<?php
$header = get_field(... | [
{
"answer_id": 261210,
"author": "Self Designs",
"author_id": 75780,
"author_profile": "https://wordpress.stackexchange.com/users/75780",
"pm_score": 0,
"selected": false,
"text": "<p>You could try to reset the WordPress permalinks to see if this is causing the 404 error. Here is a usefu... | 2017/03/24 | [
"https://wordpress.stackexchange.com/questions/261226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37548/"
] | I'm using ACF to display a class within a `<header>` tag. The code for this sits within header.php. The custom field appears across all page templates in WP admin. Here's how it's working on the front-end:
```
<header
class="site-header
<?php
$header = get_field( 'header',$post->ID );
if ($h... | To do so .. You need to login to wordpress admin and then need to save the permalink again..
Just go to Settings >> Permalink
And save without doing any changes.. and that error should be gone.. |
261,293 | <p>I added the possibility to register on my site (with the role of subscriber), however each registration creates an author page for the user, but I do not want these pages to be indexed, only the pages of authors with roles above.</p>
<p>Something like the code below, but theres no get_user_role function, so i do no... | [
{
"answer_id": 261300,
"author": "Cedon",
"author_id": 80069,
"author_profile": "https://wordpress.stackexchange.com/users/80069",
"pm_score": 1,
"selected": false,
"text": "<p>The function you want is <code>get_userdata()</code>. Since you need to do this outside the loop, the process i... | 2017/03/24 | [
"https://wordpress.stackexchange.com/questions/261293",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111513/"
] | I added the possibility to register on my site (with the role of subscriber), however each registration creates an author page for the user, but I do not want these pages to be indexed, only the pages of authors with roles above.
Something like the code below, but theres no get\_user\_role function, so i do not know h... | The function you want is `get_userdata()`. Since you need to do this outside the loop, the process is a little less straight-forward.
The first thing you need to do is set up a variable called `$curauth` which is an object that you create by accessing the database by using the `$_GET[]` superglobal.
```
$curauth = ( ... |