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 |
|---|---|---|---|---|---|---|
275,507 | <p>i make two list theme</p>
<ol>
<li><p>the posts have featured image and title, but empty content. i want get this list.</p></li>
<li><p>and other posts with content list.</p></li>
</ol>
<p>I don't have any idea, help me please</p>
<pre><code> $args = array(
'post_type' => 'post',
'post_status' =>... | [
{
"answer_id": 275492,
"author": "Sabbir Hasan",
"author_id": 76587,
"author_profile": "https://wordpress.stackexchange.com/users/76587",
"pm_score": 2,
"selected": false,
"text": "<p>Try using <strong>get_post_ancestors</strong>. Here is how you can apply this in your case:</p>\n\n<pre>... | 2017/08/02 | [
"https://wordpress.stackexchange.com/questions/275507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125061/"
] | i make two list theme
1. the posts have featured image and title, but empty content. i want get this list.
2. and other posts with content list.
I don't have any idea, help me please
```
$args = array(
'post_type' => 'post',
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'p... | Try using **get\_post\_ancestors**. Here is how you can apply this in your case:
```
<?php
global $wp_query;
$post = $wp_query->post;
$ancestors = get_post_ancestors($post);
if( empty($post->post_parent) ) {
$parent = $post->ID;
} else {
$parent = end($ancestors);
}
if(wp_l... |
275,511 | <p>I am trying to add post-meta value and after this update query and after this get_post_meta value . but add_post_meta does not work .</p>
<pre><code><?php add_post_meta($post_id, 'Product_Year', trim( $_POST['Product_Year'])); ?>
<?php update_post_meta($post_id, 'Product_Year', trim( $_POST['Product_Year... | [
{
"answer_id": 275512,
"author": "Sonali",
"author_id": 84167,
"author_profile": "https://wordpress.stackexchange.com/users/84167",
"pm_score": 0,
"selected": false,
"text": "<p>Add last parameter, refer this <a href=\"https://codex.wordpress.org/Function_Reference/add_post_meta\" rel=\"... | 2017/08/02 | [
"https://wordpress.stackexchange.com/questions/275511",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/120176/"
] | I am trying to add post-meta value and after this update query and after this get\_post\_meta value . but add\_post\_meta does not work .
```
<?php add_post_meta($post_id, 'Product_Year', trim( $_POST['Product_Year'])); ?>
<?php update_post_meta($post_id, 'Product_Year', trim( $_POST['Product_Year'])); ?>
echo $yea... | You dont need to use `add_post_meta` and `update_post_meta` for same meta\_key.
You can simply use `update_post_meta` function and this will
**add** if the meta\_key does not exist and will **update** if meta\_key exists. |
275,543 | <p>I have the following situation:</p>
<p>I created a custom Post Type names <strong>Works</strong>.
And also attached to it custom taxonomy named <strong>Work Types</strong></p>
<p>Here is the code</p>
<pre><code>function rk_work_post_type(){
$labels = array(
'name' => 'Work',
'singular_nam... | [
{
"answer_id": 275545,
"author": "Scriptile",
"author_id": 125086,
"author_profile": "https://wordpress.stackexchange.com/users/125086",
"pm_score": 5,
"selected": true,
"text": "<p>Ok, the solution was:</p>\n\n<pre><code>example.com/wp-json/wp/v2/works?work_type=10\n</code></pre>\n\n<p>... | 2017/08/02 | [
"https://wordpress.stackexchange.com/questions/275543",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125086/"
] | I have the following situation:
I created a custom Post Type names **Works**.
And also attached to it custom taxonomy named **Work Types**
Here is the code
```
function rk_work_post_type(){
$labels = array(
'name' => 'Work',
'singular_name' => 'Work',
'add_new' => 'Add Work'... | Ok, the solution was:
```
example.com/wp-json/wp/v2/works?work_type=10
```
It views the work\_types as id's.
You can view the id's in:
```
example.com/wp-json/wp/v2/works
``` |
275,569 | <p>I mean:</p>
<pre><code>add_action( 'after_setup_theme', 'thumbs_setup' );
function thumbs_setup() {
add_theme_support( 'post-thumbnails' );
}
</code></pre>
<p>My media settings are 150x150px on thumbnails, but now <code>the_post_thumbnail()</code> will output a full sized image instead. Why?</p>
<p>I see that t... | [
{
"answer_id": 275571,
"author": "Luca Reghellin",
"author_id": 10381,
"author_profile": "https://wordpress.stackexchange.com/users/10381",
"pm_score": 2,
"selected": true,
"text": "<p>I think adding support to 'post-thumbnails' also adds a new type of size: 'post-thumbnail'. But 'post-t... | 2017/08/02 | [
"https://wordpress.stackexchange.com/questions/275569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10381/"
] | I mean:
```
add_action( 'after_setup_theme', 'thumbs_setup' );
function thumbs_setup() {
add_theme_support( 'post-thumbnails' );
}
```
My media settings are 150x150px on thumbnails, but now `the_post_thumbnail()` will output a full sized image instead. Why?
I see that the only way to have `the_post_thumbnail()` t... | I think adding support to 'post-thumbnails' also adds a new type of size: 'post-thumbnail'. But 'post-thumbnail' **is not** == 'thumb' or 'thumbnail', it's a new, different type.
Also, `the_post_thumbnail()` if called without params will output the 'post-thumbnail' size instead of the 'thumb' size.
'thumb' (or 'thumbn... |
275,629 | <p>I am trying to work out a submit contact form through ajax but somehow i fail in process and i can't figure out, every combination i try it returns <code>0</code> for some reason.</p>
<p>This is my form</p>
<pre><code><form name="sentMessage" id="contactForm" novalidate>
<div class="form-group... | [
{
"answer_id": 275639,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>action: 'ajax_contact'</code> part in: </p>\n\n<pre><code>var data = $form.serialize();\nconsole.lo... | 2017/08/03 | [
"https://wordpress.stackexchange.com/questions/275629",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21135/"
] | I am trying to work out a submit contact form through ajax but somehow i fail in process and i can't figure out, every combination i try it returns `0` for some reason.
This is my form
```
<form name="sentMessage" id="contactForm" novalidate>
<div class="form-group wow fadeInUp">
<input ty... | At the end i made it working like this.
```
<form name="sentMessage" id="contactForm" method="post" action="<?php echo admin_url('admin-ajax.php'); ?>" role="form" data-toggle="validator">
<div class="form-group wow fadeInUp">
<input type="text" class="form-c... |
275,708 | <p>In the Public Function <code>Update</code> this code is sitting →</p>
<blockquote>
<pre><code>`public function update($new_instance, $old_instance)
$instance['description_box'] = $new_instance['description_box'];
</code></pre>
</blockquote>
<p>In the public function widget, this code is sitting →</p>
<bloc... | [
{
"answer_id": 275761,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 0,
"selected": false,
"text": "<p>Here's a full implementation of a simple widget with a checkbox that hides/shows something on the front... | 2017/08/03 | [
"https://wordpress.stackexchange.com/questions/275708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105791/"
] | In the Public Function `Update` this code is sitting →
>
>
> ```
> `public function update($new_instance, $old_instance)
>
> $instance['description_box'] = $new_instance['description_box'];
>
> ```
>
>
In the public function widget, this code is sitting →
>
>
> ```
> public function widget($args, $inst... | Now, based on your full code, there's 3 problems:
Line 60 of your code is missing a semi colon and throwing a fatal error. So:
```
$instance['description_check_box'] = $new_instance['description_check_box']
```
Should be:
```
$instance['description_check_box'] = $new_instance['description_check_box'];
```
On l... |
275,716 | <p>In WordPress page in put google map Embed Code like this</p>
<pre><code><iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d805184.6317849847!2d144.49269473369353!3d-37.97123702210555!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6ad646b5d2ba4df7%3A0x4045675218ccd90!2sMelbourne+VIC!5e0!3m2!1... | [
{
"answer_id": 275761,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 0,
"selected": false,
"text": "<p>Here's a full implementation of a simple widget with a checkbox that hides/shows something on the front... | 2017/08/03 | [
"https://wordpress.stackexchange.com/questions/275716",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18787/"
] | In WordPress page in put google map Embed Code like this
```
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d805184.6317849847!2d144.49269473369353!3d-37.97123702210555!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6ad646b5d2ba4df7%3A0x4045675218ccd90!2sMelbourne+VIC!5e0!3m2!1sen!2sau!4v150176... | Now, based on your full code, there's 3 problems:
Line 60 of your code is missing a semi colon and throwing a fatal error. So:
```
$instance['description_check_box'] = $new_instance['description_check_box']
```
Should be:
```
$instance['description_check_box'] = $new_instance['description_check_box'];
```
On l... |
275,718 | <p>Wordpress post favorite image not showing on wp-admin and on page although it is set on DB. I have inserted posts with unnecessary data and post meta in DB from other db, all is ok.
When I call thumbnail url like this , it is working</p>
<pre><code>$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) )... | [
{
"answer_id": 275719,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>You have to echo it out:</p>\n\n<pre><code>echo get_the_post_thumbnail();\n</code></pre>\n\n<p>Perhaps you m... | 2017/08/03 | [
"https://wordpress.stackexchange.com/questions/275718",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57668/"
] | Wordpress post favorite image not showing on wp-admin and on page although it is set on DB. I have inserted posts with unnecessary data and post meta in DB from other db, all is ok.
When I call thumbnail url like this , it is working
```
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
echo $url;
```... | You have to echo it out:
```
echo get_the_post_thumbnail();
```
Perhaps you meant to use `the_post_thumbnail();`
<https://developer.wordpress.org/reference/functions/the_post_thumbnail/> |
275,724 | <p>I want to replace ORDER word with something like Entry Form everywhere in the wordpress website. I am trying following method to replace Order word.</p>
<pre><code>add_filter('gettext', 'translate_reply');
add_filter('ngettext', 'translate_reply');
function translate_reply($translated) {
$translated = str_ireplace... | [
{
"answer_id": 275719,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>You have to echo it out:</p>\n\n<pre><code>echo get_the_post_thumbnail();\n</code></pre>\n\n<p>Perhaps you m... | 2017/08/04 | [
"https://wordpress.stackexchange.com/questions/275724",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114560/"
] | I want to replace ORDER word with something like Entry Form everywhere in the wordpress website. I am trying following method to replace Order word.
```
add_filter('gettext', 'translate_reply');
add_filter('ngettext', 'translate_reply');
function translate_reply($translated) {
$translated = str_ireplace('Order' , 'so... | You have to echo it out:
```
echo get_the_post_thumbnail();
```
Perhaps you meant to use `the_post_thumbnail();`
<https://developer.wordpress.org/reference/functions/the_post_thumbnail/> |
275,726 | <p>Even though I type "<a href="http://aoafinc.org/wp-admin" rel="nofollow noreferrer">http://aoafinc.org/wp-admin</a>" into the address bar, it was turned into "<a href="https://aoafinc.org/wp-admin" rel="nofollow noreferrer">https://aoafinc.org/wp-admin</a>". Also, all the links to images on my site are "https" inste... | [
{
"answer_id": 275719,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>You have to echo it out:</p>\n\n<pre><code>echo get_the_post_thumbnail();\n</code></pre>\n\n<p>Perhaps you m... | 2017/08/04 | [
"https://wordpress.stackexchange.com/questions/275726",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125207/"
] | Even though I type "<http://aoafinc.org/wp-admin>" into the address bar, it was turned into "<https://aoafinc.org/wp-admin>". Also, all the links to images on my site are "https" instead of "http". Since my SSL certificate has expired, all these images can't be loaded.
I just take over this website from someone and do... | You have to echo it out:
```
echo get_the_post_thumbnail();
```
Perhaps you meant to use `the_post_thumbnail();`
<https://developer.wordpress.org/reference/functions/the_post_thumbnail/> |
275,749 | <p>Every time i tried to update WordPress ,i faced this error:</p>
<blockquote>
<p>Fatal error: Maximum execution time of 120 seconds exceeded in
G:\wamp\www\wordpress\wp-includes\Requests\Transport\fsockopen.php on
line 246</p>
</blockquote>
<p>Code of line number 246 is:</p>
<pre><code>$block = fread($socket... | [
{
"answer_id": 275750,
"author": "jreis",
"author_id": 124042,
"author_profile": "https://wordpress.stackexchange.com/users/124042",
"pm_score": 0,
"selected": false,
"text": "<p>Increase the maximum execution time of PHP.</p>\n\n<p>You can do that on <code>php.ini</code>, on <code>.htac... | 2017/08/04 | [
"https://wordpress.stackexchange.com/questions/275749",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125218/"
] | Every time i tried to update WordPress ,i faced this error:
>
> Fatal error: Maximum execution time of 120 seconds exceeded in
> G:\wamp\www\wordpress\wp-includes\Requests\Transport\fsockopen.php on
> line 246
>
>
>
Code of line number 246 is:
```
$block = fread($socket, Requests::BUFFER_SIZE);
```
How can i... | This issue generally occurs when php script takes more time for execution than set in php.ini file
You can resolve this issue by using two methods:
Method 1: Editing .htaccess File Manually
Put **php\_value max\_execution\_time 600** in .htaccess file 600 is the value of execution time in seconds, you can use yours ... |
275,774 | <p>i'm struggling with enqueueing the style.css and bootstrap.css files. i tried a lot solutions but no one worked. i also tried like in the video but it didnt work:
<a href="https://youtu.be/mtOW2J7zOSk?t=6m28s" rel="nofollow noreferrer">https://youtu.be/mtOW2J7zOSk?t=6m28s</a></p>
<p>can anyone tell me what i'm doin... | [
{
"answer_id": 275776,
"author": "Prakash Dwivedi",
"author_id": 125226,
"author_profile": "https://wordpress.stackexchange.com/users/125226",
"pm_score": 0,
"selected": false,
"text": "<p>I would suggest you to use following syntax:</p>\n\n<p>\n\n<pre><code>//Load the theme CSS\nfunctio... | 2017/08/04 | [
"https://wordpress.stackexchange.com/questions/275774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125228/"
] | i'm struggling with enqueueing the style.css and bootstrap.css files. i tried a lot solutions but no one worked. i also tried like in the video but it didnt work:
<https://youtu.be/mtOW2J7zOSk?t=6m28s>
can anyone tell me what i'm doing wrong please?
```
function load_styles() {
wp_enqueue_style( 'bootstrap-min', get_... | use `wp_head();` before `</head>` in `header.php` |
275,785 | <p>I need to have a hidden custom field that will be automatically populated with the title of the post on save.
My goal is to query posts by all its meta fields, including the title, but from my research I learned that it's not easily possible to combine title and meta_query.</p>
<p>What should be the script for crea... | [
{
"answer_id": 275787,
"author": "Wh0CaREs",
"author_id": 123614,
"author_profile": "https://wordpress.stackexchange.com/users/123614",
"pm_score": -1,
"selected": false,
"text": "<p>So you need hidden input field </p>\n\n<pre><code><input type=\"hidden\" name=\"yourName\" value=\"you... | 2017/08/04 | [
"https://wordpress.stackexchange.com/questions/275785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125233/"
] | I need to have a hidden custom field that will be automatically populated with the title of the post on save.
My goal is to query posts by all its meta fields, including the title, but from my research I learned that it's not easily possible to combine title and meta\_query.
What should be the script for creating this... | This will automatically update a meta named `post_title` to the value of the post's title, no matter where you save the post from:
```
function wpse_275785_save_title_as_meta( $post_id, $post, $update ) {
update_post_meta( $post_id, 'post_title', $post->post_title );
}
add_action( 'save_post', 'wpse_275785_save_ti... |
275,788 | <p>I want to create a filter in my functions.php theme to change the URL of $icon_html in this plugin function.</p>
<pre><code>public function get_icon() {
// paypal icon
$icon_html = '<img src="paypal.png" />';
return apply_filters( 'woocommerce_gateway_icon', $icon_html, $this->get_id() );
}
</code></pre>
... | [
{
"answer_id": 275787,
"author": "Wh0CaREs",
"author_id": 123614,
"author_profile": "https://wordpress.stackexchange.com/users/123614",
"pm_score": -1,
"selected": false,
"text": "<p>So you need hidden input field </p>\n\n<pre><code><input type=\"hidden\" name=\"yourName\" value=\"you... | 2017/08/04 | [
"https://wordpress.stackexchange.com/questions/275788",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113942/"
] | I want to create a filter in my functions.php theme to change the URL of $icon\_html in this plugin function.
```
public function get_icon() {
// paypal icon
$icon_html = '<img src="paypal.png" />';
return apply_filters( 'woocommerce_gateway_icon', $icon_html, $this->get_id() );
}
```
How to perform this? $icon\_ht... | This will automatically update a meta named `post_title` to the value of the post's title, no matter where you save the post from:
```
function wpse_275785_save_title_as_meta( $post_id, $post, $update ) {
update_post_meta( $post_id, 'post_title', $post->post_title );
}
add_action( 'save_post', 'wpse_275785_save_ti... |
275,800 | <p>I recently migrated my old website to this domain: <a href="https://thequintessentialmind.com/" rel="nofollow noreferrer">https://thequintessentialmind.com/</a></p>
<p>The ssl works fine but in the console of google inspector it suggest that there is a .gif file that should be renamed from http to https. </p>
<p><... | [
{
"answer_id": 275787,
"author": "Wh0CaREs",
"author_id": 123614,
"author_profile": "https://wordpress.stackexchange.com/users/123614",
"pm_score": -1,
"selected": false,
"text": "<p>So you need hidden input field </p>\n\n<pre><code><input type=\"hidden\" name=\"yourName\" value=\"you... | 2017/08/04 | [
"https://wordpress.stackexchange.com/questions/275800",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111649/"
] | I recently migrated my old website to this domain: <https://thequintessentialmind.com/>
The ssl works fine but in the console of google inspector it suggest that there is a .gif file that should be renamed from http to https.
[](https://i.stack.imgu... | This will automatically update a meta named `post_title` to the value of the post's title, no matter where you save the post from:
```
function wpse_275785_save_title_as_meta( $post_id, $post, $update ) {
update_post_meta( $post_id, 'post_title', $post->post_title );
}
add_action( 'save_post', 'wpse_275785_save_ti... |
275,822 | <p>I have uploaded an image that is 2100px wide into a post, and inserted that image in the post body. I'm building a custom theme based on Wordpress' Twenty Sixteen.</p>
<p>The HTML looks OK:</p>
<pre><code><img class="alignnone wp-image-2669 size-full"
src="http://.../wp-content/uploads/2017/07/GrillSommer1... | [
{
"answer_id": 275823,
"author": "Rei",
"author_id": 109614,
"author_profile": "https://wordpress.stackexchange.com/users/109614",
"pm_score": 0,
"selected": false,
"text": "<p>You can check tab <strong>media setting</strong> in wordpress<a href=\"https://i.stack.imgur.com/VFxgU.png\" re... | 2017/08/04 | [
"https://wordpress.stackexchange.com/questions/275822",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2161/"
] | I have uploaded an image that is 2100px wide into a post, and inserted that image in the post body. I'm building a custom theme based on Wordpress' Twenty Sixteen.
The HTML looks OK:
```
<img class="alignnone wp-image-2669 size-full"
src="http://.../wp-content/uploads/2017/07/GrillSommer1.jpg"
alt="" width... | Your image's src is pointing to the full size image, so it's not an issue of permalink. The issue happens because of the `sizes` values. There is a variable that determines the width of your content, which then later WordPress uses to generates the responsive sizes for your images.
This global variable can be set man... |
275,838 | <p>Trying to: </p>
<p>Submit form using admin-ajax.php to update post data from 'draft' status to 'publish' status and add custom meta field for filter type.</p>
<p>Form contents:</p>
<pre><code><form action="<?php echo admin_url( 'admin-ajax.php' ) ?>" method="post">
<?php wp_nonce_field( 's... | [
{
"answer_id": 275823,
"author": "Rei",
"author_id": 109614,
"author_profile": "https://wordpress.stackexchange.com/users/109614",
"pm_score": 0,
"selected": false,
"text": "<p>You can check tab <strong>media setting</strong> in wordpress<a href=\"https://i.stack.imgur.com/VFxgU.png\" re... | 2017/08/04 | [
"https://wordpress.stackexchange.com/questions/275838",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125259/"
] | Trying to:
Submit form using admin-ajax.php to update post data from 'draft' status to 'publish' status and add custom meta field for filter type.
Form contents:
```
<form action="<?php echo admin_url( 'admin-ajax.php' ) ?>" method="post">
<?php wp_nonce_field( 'submit_filter', 'my_filter_nonce' ); ?>
... | Your image's src is pointing to the full size image, so it's not an issue of permalink. The issue happens because of the `sizes` values. There is a variable that determines the width of your content, which then later WordPress uses to generates the responsive sizes for your images.
This global variable can be set man... |
275,859 | <p>I have the following code in my main plugin file</p>
<pre><code><?php
include plugin_dir_path( __FILE__) . 'options.php';
include plugin_dir_path( __FILE__ ) . 'config.php';
include plugin_dir_path( __FILE__ ) . 'front/manage.php';
add_action( 'admin_init', 'restrict_admin', 1 );
//prepare wordpress for ajax t... | [
{
"answer_id": 275861,
"author": "Ben HartLenn",
"author_id": 6645,
"author_profile": "https://wordpress.stackexchange.com/users/6645",
"pm_score": 1,
"selected": false,
"text": "<p>\"...I need them to authenticate the database connection.\" </p>\n\n<p>Not exactly sure this is what you w... | 2017/08/05 | [
"https://wordpress.stackexchange.com/questions/275859",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125273/"
] | I have the following code in my main plugin file
```
<?php
include plugin_dir_path( __FILE__) . 'options.php';
include plugin_dir_path( __FILE__ ) . 'config.php';
include plugin_dir_path( __FILE__ ) . 'front/manage.php';
add_action( 'admin_init', 'restrict_admin', 1 );
//prepare wordpress for ajax this needs to be d... | "...I need them to authenticate the database connection."
Not exactly sure this is what you want, but in your ajax function you can connect to and use a database if you [declare the global variable $wpdb](https://codex.wordpress.org/Class_Reference/wpdb).
Here's a simple example:
```
function api_list_devices() {
... |
275,907 | <p>I've created a plugin using various classes. I want to be able to access the methods on several of the different classes from within the page templates of my custom theme. The method I'm currently using is to make static methods but I'm wondering if this is the best way to do it?</p>
<p>An example could be a class ... | [
{
"answer_id": 275861,
"author": "Ben HartLenn",
"author_id": 6645,
"author_profile": "https://wordpress.stackexchange.com/users/6645",
"pm_score": 1,
"selected": false,
"text": "<p>\"...I need them to authenticate the database connection.\" </p>\n\n<p>Not exactly sure this is what you w... | 2017/08/05 | [
"https://wordpress.stackexchange.com/questions/275907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125295/"
] | I've created a plugin using various classes. I want to be able to access the methods on several of the different classes from within the page templates of my custom theme. The method I'm currently using is to make static methods but I'm wondering if this is the best way to do it?
An example could be a class with a met... | "...I need them to authenticate the database connection."
Not exactly sure this is what you want, but in your ajax function you can connect to and use a database if you [declare the global variable $wpdb](https://codex.wordpress.org/Class_Reference/wpdb).
Here's a simple example:
```
function api_list_devices() {
... |
275,917 | <p>I am using load to enqueue scripts only on my plugin page.</p>
<p><a href="https://developer.wordpress.org/reference/hooks/load-page_hook/" rel="nofollow noreferrer">https://developer.wordpress.org/reference/hooks/load-page_hook/</a></p>
<pre><code>add_action("admin_menu", "sap_admin_menu");
function sap_admin_men... | [
{
"answer_id": 275921,
"author": "ClemC",
"author_id": 73239,
"author_profile": "https://wordpress.stackexchange.com/users/73239",
"pm_score": 1,
"selected": false,
"text": "<p>What about <a href=\"https://codex.wordpress.org/Function_Reference/get_current_screen\" rel=\"nofollow norefer... | 2017/08/05 | [
"https://wordpress.stackexchange.com/questions/275917",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45321/"
] | I am using load to enqueue scripts only on my plugin page.
<https://developer.wordpress.org/reference/hooks/load-page_hook/>
```
add_action("admin_menu", "sap_admin_menu");
function sap_admin_menu(){
$menu = add_menu_page("Sticky Audio Player Player manager", "Sticky Audio Player", "manage_options", "sap_player_... | You can do something like this
```
add_action( 'admin_menu', 'my_admin_menus' );
function my_admin_menus() {
$GLOBALS['my_page'] = add_menu_page( 'Page Title', 'Menu Title',
MY_ADMIN_CAPABILITY, 'menu-slug', 'show_page_content');
}
add_action( 'admin_enqueue_scripts', 'enqueue_admin_js');
function enqueue_... |
275,930 | <p>I just upgraded to PHP 7 only to find that WordPress 4.8.1 (latest version) still uses mysql_connect in the wp-db.php module, but mysql_connect has been deprecated.</p>
<p>The following code is taken from wp-db-php, lines 1567-1571:</p>
<pre><code>if ( WP_DEBUG ) {
$this->dbh = mysql_connect( $this->dbho... | [
{
"answer_id": 275932,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 3,
"selected": false,
"text": "<p>This sounds like you do not have <a href=\"http://php.net/manual/en/book.mysqli.php\" rel=\"noreferrer\">... | 2017/08/05 | [
"https://wordpress.stackexchange.com/questions/275930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44926/"
] | I just upgraded to PHP 7 only to find that WordPress 4.8.1 (latest version) still uses mysql\_connect in the wp-db.php module, but mysql\_connect has been deprecated.
The following code is taken from wp-db-php, lines 1567-1571:
```
if ( WP_DEBUG ) {
$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this-... | This sounds like you do not have [mysqli](http://php.net/manual/en/book.mysqli.php) installed and/or enabled on your server. IIRC `mysqli` was added to php in version 5.5, and the older `mysql` extension had been deprecated and fully retired since then. If you upgraded from a very old PHP version it might be that you s... |
275,977 | <p>By default in the admin the Excerpt is hidden. See below.</p>
<p><a href="https://i.stack.imgur.com/XnUPZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XnUPZ.png" alt="By default in the admin the Excerpt is hidden"></a></p>
<p>I would like to make it show up by default.</p>
| [
{
"answer_id": 275985,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 3,
"selected": true,
"text": "<p>The names of unchecked boxes in <code>Screen Options</code> for <code>Edit Post</code> screen a... | 2017/08/06 | [
"https://wordpress.stackexchange.com/questions/275977",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83781/"
] | By default in the admin the Excerpt is hidden. See below.
[](https://i.stack.imgur.com/XnUPZ.png)
I would like to make it show up by default. | The names of unchecked boxes in `Screen Options` for `Edit Post` screen are stored in user's meta, per individual user, as an array. Insert the following code in your theme's `functions.php`:
```
function wpse_edit_post_show_excerpt( $user_login, $user ) {
$unchecked = get_user_meta( $user->ID, 'metaboxhidden_post... |
275,979 | <p>I have a custom post type "vegetables"</p>
<p>I have a series of custom fields for each month of the year as check boxes</p>
<p>I have a custom taxonomy "Seasons" that I want to assign based on what boxes are checked in my custom fields</p>
<p>Summer if any June July August</p>
<p>Fall if any September October N... | [
{
"answer_id": 275985,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 3,
"selected": true,
"text": "<p>The names of unchecked boxes in <code>Screen Options</code> for <code>Edit Post</code> screen a... | 2017/08/06 | [
"https://wordpress.stackexchange.com/questions/275979",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125332/"
] | I have a custom post type "vegetables"
I have a series of custom fields for each month of the year as check boxes
I have a custom taxonomy "Seasons" that I want to assign based on what boxes are checked in my custom fields
Summer if any June July August
Fall if any September October November
Winter if any December... | The names of unchecked boxes in `Screen Options` for `Edit Post` screen are stored in user's meta, per individual user, as an array. Insert the following code in your theme's `functions.php`:
```
function wpse_edit_post_show_excerpt( $user_login, $user ) {
$unchecked = get_user_meta( $user->ID, 'metaboxhidden_post... |
275,988 | <p>I have the following function for a shortcode below. I have the shortcode in a footer widget. For some reason the output is appearing outside of the container elements of the widget. I thought returning the values was the way to go so I'm kind of stuck here. </p>
<pre><code>if (!function_exists('footer_get_latest_p... | [
{
"answer_id": 275985,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 3,
"selected": true,
"text": "<p>The names of unchecked boxes in <code>Screen Options</code> for <code>Edit Post</code> screen a... | 2017/08/06 | [
"https://wordpress.stackexchange.com/questions/275988",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64789/"
] | I have the following function for a shortcode below. I have the shortcode in a footer widget. For some reason the output is appearing outside of the container elements of the widget. I thought returning the values was the way to go so I'm kind of stuck here.
```
if (!function_exists('footer_get_latest_post')) {
f... | The names of unchecked boxes in `Screen Options` for `Edit Post` screen are stored in user's meta, per individual user, as an array. Insert the following code in your theme's `functions.php`:
```
function wpse_edit_post_show_excerpt( $user_login, $user ) {
$unchecked = get_user_meta( $user->ID, 'metaboxhidden_post... |
276,032 | <p><a href="https://i.stack.imgur.com/mV5X3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mV5X3.png" alt="enter image description here"></a>i am learning html and php from scratch,
i had upload a wordpress website, all ok, but i have problem with some editing,
means i coluld not find which file ... | [
{
"answer_id": 275985,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 3,
"selected": true,
"text": "<p>The names of unchecked boxes in <code>Screen Options</code> for <code>Edit Post</code> screen a... | 2017/08/07 | [
"https://wordpress.stackexchange.com/questions/276032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125367/"
] | [](https://i.stack.imgur.com/mV5X3.png)i am learning html and php from scratch,
i had upload a wordpress website, all ok, but i have problem with some editing,
means i coluld not find which file i have to edit.
i search index.php but in index.php fi... | The names of unchecked boxes in `Screen Options` for `Edit Post` screen are stored in user's meta, per individual user, as an array. Insert the following code in your theme's `functions.php`:
```
function wpse_edit_post_show_excerpt( $user_login, $user ) {
$unchecked = get_user_meta( $user->ID, 'metaboxhidden_post... |
276,036 | <p>Is there a way to add a condition to know if the current item of the navigation walker is the last child of the menu or parent? </p>
<pre><code>| Item 1 | Item 2 |
| - Item 1.1 | - Item 2.1 |
| - Item 1.2 | - Item 2.2 |
| - Item 1.3 |<----------------- Determine if current item is last child
</co... | [
{
"answer_id": 275985,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 3,
"selected": true,
"text": "<p>The names of unchecked boxes in <code>Screen Options</code> for <code>Edit Post</code> screen a... | 2017/08/07 | [
"https://wordpress.stackexchange.com/questions/276036",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91164/"
] | Is there a way to add a condition to know if the current item of the navigation walker is the last child of the menu or parent?
```
| Item 1 | Item 2 |
| - Item 1.1 | - Item 2.1 |
| - Item 1.2 | - Item 2.2 |
| - Item 1.3 |<----------------- Determine if current item is last child
```
For example:
... | The names of unchecked boxes in `Screen Options` for `Edit Post` screen are stored in user's meta, per individual user, as an array. Insert the following code in your theme's `functions.php`:
```
function wpse_edit_post_show_excerpt( $user_login, $user ) {
$unchecked = get_user_meta( $user->ID, 'metaboxhidden_post... |
276,092 | <p>I'm trying to create an anchor tag and using a variable as the link. </p>
<p>Here's what my template looks like. </p>
<pre><code><?php
$website = tribe_get_event_website_link();
echo '<a href="' . $website. '">REGISTER</a>';
?>
</code></pre>
<p>So I'm creating a variable that will hold the ... | [
{
"answer_id": 276100,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>It's not really a WordPress related question, but it's a simple one. The <code>tribe_get_event_website_link... | 2017/08/07 | [
"https://wordpress.stackexchange.com/questions/276092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114057/"
] | I'm trying to create an anchor tag and using a variable as the link.
Here's what my template looks like.
```
<?php
$website = tribe_get_event_website_link();
echo '<a href="' . $website. '">REGISTER</a>';
?>
```
So I'm creating a variable that will hold the link the I want to anchor it. And when I echo it ba... | It's not really a WordPress related question, but it's a simple one. The `tribe_get_event_website_link()` function you are using outputs a full link. You can use SimpleXML to extract the `href` part and then use it later. It's as simple as this:
```
$website = tribe_get_event_website_link();
$xml = new SimpleXMLElemen... |
276,097 | <p>So, I need to show a page with the sub-categories of the current custom taxonomy, with their respective posts inside.</p>
<p>What I need is, when I click on a sub-cat link, I get something like:</p>
<pre><code>'Tipos' (custom taxonomy)
- Auto (first sub-cat)
- Sub-Item 1 (first sub-sub-cat)
... | [
{
"answer_id": 276099,
"author": "Greeso",
"author_id": 34253,
"author_profile": "https://wordpress.stackexchange.com/users/34253",
"pm_score": 1,
"selected": false,
"text": "<p>I think you can easily achieve that if you understand <a href=\"https://developer.wordpress.org/themes/basics/... | 2017/08/07 | [
"https://wordpress.stackexchange.com/questions/276097",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44437/"
] | So, I need to show a page with the sub-categories of the current custom taxonomy, with their respective posts inside.
What I need is, when I click on a sub-cat link, I get something like:
```
'Tipos' (custom taxonomy)
- Auto (first sub-cat)
- Sub-Item 1 (first sub-sub-cat)
- Post 1
... | **PROBLEM SOLVED.
FINAL CODE (WORKING):**
```
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
echo $term->name;
$queried_object = get_queried_object();
$term_id = get_queried_object()->term_id;
$taxonomyName = "tipos";
$termchildren = get_term_children( $term_id, $taxonomyName );
i... |
276,108 | <p>I'm using ACF to build some custom elements on pages and also WPML to manage the translations of these pages.</p>
<p>I am currently seeing an issue where the pages do not save when I update the language content.</p>
<p>In the WPML custom field settings I have each custom field down to the Translate option.</p>
<p... | [
{
"answer_id": 276113,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 1,
"selected": false,
"text": "<p>I've had a fair share of issues with ACF, but end up using it still.</p>\n\n<p>There could be 3 things causing... | 2017/08/07 | [
"https://wordpress.stackexchange.com/questions/276108",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37508/"
] | I'm using ACF to build some custom elements on pages and also WPML to manage the translations of these pages.
I am currently seeing an issue where the pages do not save when I update the language content.
In the WPML custom field settings I have each custom field down to the Translate option.
Within each page I am c... | I've had a fair share of issues with ACF, but end up using it still.
There could be 3 things causing your problem.
you could try changing your php settings:
```
max_input_time = 42000
max_execution_time = 42000
max_input_vars = 50000
```
This next one is not a great fix as if WordPress ever decides to update thei... |
276,116 | <p>So I'm attempting to create a single page Wordpress theme and right now I'm using my index.php as the page they will initially see. </p>
<p>In my index.php I use The Loop to create a bunch of <code>a</code> tags that link to the all of the post permalinks.</p>
<p>What is the template file that I need to make or wh... | [
{
"answer_id": 276117,
"author": "Chris MXol",
"author_id": 125415,
"author_profile": "https://wordpress.stackexchange.com/users/125415",
"pm_score": -1,
"selected": false,
"text": "<p>Nvm, found it. It's single.php. </p>\n"
},
{
"answer_id": 276120,
"author": "Rick Hellewell... | 2017/08/07 | [
"https://wordpress.stackexchange.com/questions/276116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125415/"
] | So I'm attempting to create a single page Wordpress theme and right now I'm using my index.php as the page they will initially see.
In my index.php I use The Loop to create a bunch of `a` tags that link to the all of the post permalinks.
What is the template file that I need to make or what do I need to define so th... | You can create new template php file.
```
//Template Name : Single Page Template
get_header();
if ( have_posts() ) :
while ( have_posts() ) : the_post();
the_content();
the_permalink();//this is for the <a> bunch you are looking for
endwhile;
endif;
get_footer();
```
Here , you can us... |
276,177 | <p>I am trying to get the permalink and title into variables to use outside of a loop - I have made it work for the thumbnail but for some reason can t get it to work for these two.</p>
<p>Here is my code:</p>
<pre><code><div class="medium-12 medium-centered columns">
<?php global $post; // ... | [
{
"answer_id": 276136,
"author": "Elroy Fernandes",
"author_id": 88483,
"author_profile": "https://wordpress.stackexchange.com/users/88483",
"pm_score": 0,
"selected": false,
"text": "<p>You need to check location first and then change the display text or you can change the text from th... | 2017/08/08 | [
"https://wordpress.stackexchange.com/questions/276177",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108232/"
] | I am trying to get the permalink and title into variables to use outside of a loop - I have made it work for the thumbnail but for some reason can t get it to work for these two.
Here is my code:
```
<div class="medium-12 medium-centered columns">
<?php global $post; // required
$args... | I found this answer .
Hope this will help you.
maybe with wpml for multi-lang
<https://stackoverflow.com/questions/38296093/woocommerce-free-shipping-remove-raw-or-change-the-text-name-on-checkout-and-e> |
276,179 | <p>I want to get the current user id from inside my plugin and use it as a variable. </p>
<p>My code is</p>
<pre><code>$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$loc_statuss = $wpdb->get_row( "SELECT status FROM profile_location INNER JOIN relation_user ON profile_location.loc_id=rel... | [
{
"answer_id": 276185,
"author": "Rahul Parikh",
"author_id": 125461,
"author_profile": "https://wordpress.stackexchange.com/users/125461",
"pm_score": 1,
"selected": false,
"text": "<p>If you want current user id only then use get_current_user_id.\nbecause it reduce execution time. get_... | 2017/08/08 | [
"https://wordpress.stackexchange.com/questions/276179",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110675/"
] | I want to get the current user id from inside my plugin and use it as a variable.
My code is
```
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$loc_statuss = $wpdb->get_row( "SELECT status FROM profile_location INNER JOIN relation_user ON profile_location.loc_id=relation_user.loc_id WHERE rel... | If you want current user id only then use get\_current\_user\_id.
because it reduce execution time. get\_current\_user\_id get only current user id where wp\_get\_current\_user get all user data.
Else every things is perfect.
```
$user_id = get_current_user_id();
$loc_statuss = $wpdb->get_row( "SELECT status FROM pro... |
276,197 | <p>Here's my challenge...</p>
<p>I have 52 pages that require a full width background image that will be rendered via a .css style..</p>
<p>So, what I will know are all the Page ID Numbers. The below code I believe is a tidy way of doing what I am trying to achieve.</p>
<p>My question is, rather than have 52 instanc... | [
{
"answer_id": 276202,
"author": "Tom Webb",
"author_id": 92615,
"author_profile": "https://wordpress.stackexchange.com/users/92615",
"pm_score": 0,
"selected": false,
"text": "<p>Try this.</p>\n\n<pre><code>function wpsites_specific_page_body_class($classes) {\n global $post;\n $p... | 2017/08/08 | [
"https://wordpress.stackexchange.com/questions/276197",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | Here's my challenge...
I have 52 pages that require a full width background image that will be rendered via a .css style..
So, what I will know are all the Page ID Numbers. The below code I believe is a tidy way of doing what I am trying to achieve.
My question is, rather than have 52 instances of the below code, is... | I would consider making it more flexible by **marking** the pages in question with post meta or custom taxonomy. That way you don't need to change a PHP code to choose what pages should have some custom look.
Here's an example, if we mark the pages with the `wpse-layout` custom field with the value `1` (assuming ther... |
276,230 | <p>Having read elsewhere on Stack of two WP plugins forcing identical menu positions (with the likelihood of one then not appearing), I'm wondering how I can control the position of menu items added by plugins.</p>
<p>I already use a function which seems to handle such submenu items in 'settings', and another function... | [
{
"answer_id": 276248,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 4,
"selected": false,
"text": "<p>when you're creating a post type with register_post_type() you can set the menu position:</p>\n\n<blockquote>\... | 2017/08/08 | [
"https://wordpress.stackexchange.com/questions/276230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/103213/"
] | Having read elsewhere on Stack of two WP plugins forcing identical menu positions (with the likelihood of one then not appearing), I'm wondering how I can control the position of menu items added by plugins.
I already use a function which seems to handle such submenu items in 'settings', and another function to reorde... | To change top level admin menu items order you'll need two `hooks`, two `filters`, and one `function`. Put the following code in your current theme's `functions.php`:
```
function wpse_custom_menu_order( $menu_ord ) {
if ( !$menu_ord ) return true;
return array(
'index.php', // Dashboard
'sepa... |
276,232 | <p>My child theme customizer is not working. I have created a child theme from the parent theme called flash. In the parent theme I can use the customizer just fine and change the layout ect. However, when I activate my child theme nothing in in my customizer working in terms of layout.I feel like the issue lies in my ... | [
{
"answer_id": 276234,
"author": "Cakers",
"author_id": 125497,
"author_profile": "https://wordpress.stackexchange.com/users/125497",
"pm_score": 1,
"selected": false,
"text": "<p>I realize that I did not know that you needed an extra step for the functions.php. Here is the last step I n... | 2017/08/08 | [
"https://wordpress.stackexchange.com/questions/276232",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125497/"
] | My child theme customizer is not working. I have created a child theme from the parent theme called flash. In the parent theme I can use the customizer just fine and change the layout ect. However, when I activate my child theme nothing in in my customizer working in terms of layout.I feel like the issue lies in my sty... | I realize that I did not know that you needed an extra step for the functions.php. Here is the last step I needed.
```
<?php
function my_theme_enqueue_styles() {
$parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the
Twenty Fifteen theme.
wp_enqueue_style( $parent_style, get_template_directo... |
276,253 | <p>I have a forum system where I created a custom post type, and I would like to have a search system for the topics, but I do not know what the structure would be, for example, how the file will be and the search form action.</p>
| [
{
"answer_id": 276234,
"author": "Cakers",
"author_id": 125497,
"author_profile": "https://wordpress.stackexchange.com/users/125497",
"pm_score": 1,
"selected": false,
"text": "<p>I realize that I did not know that you needed an extra step for the functions.php. Here is the last step I n... | 2017/08/08 | [
"https://wordpress.stackexchange.com/questions/276253",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124171/"
] | I have a forum system where I created a custom post type, and I would like to have a search system for the topics, but I do not know what the structure would be, for example, how the file will be and the search form action. | I realize that I did not know that you needed an extra step for the functions.php. Here is the last step I needed.
```
<?php
function my_theme_enqueue_styles() {
$parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the
Twenty Fifteen theme.
wp_enqueue_style( $parent_style, get_template_directo... |
276,293 | <p>I'm working on a website now and then I want to transfer to other domain.
But all I want to transfer is the WordPress Theme and content not included the plugins </p>
<p>Is this possible?
If yes how?</p>
<p>Thanks.</p>
| [
{
"answer_id": 276234,
"author": "Cakers",
"author_id": 125497,
"author_profile": "https://wordpress.stackexchange.com/users/125497",
"pm_score": 1,
"selected": false,
"text": "<p>I realize that I did not know that you needed an extra step for the functions.php. Here is the last step I n... | 2017/08/09 | [
"https://wordpress.stackexchange.com/questions/276293",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122942/"
] | I'm working on a website now and then I want to transfer to other domain.
But all I want to transfer is the WordPress Theme and content not included the plugins
Is this possible?
If yes how?
Thanks. | I realize that I did not know that you needed an extra step for the functions.php. Here is the last step I needed.
```
<?php
function my_theme_enqueue_styles() {
$parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the
Twenty Fifteen theme.
wp_enqueue_style( $parent_style, get_template_directo... |
276,298 | <p>I added a function that will return the allowed html tags array</p>
<pre><code>if ( ! function_exists( 'allowed_html_tags' ) ) {
/**
* Allowed html tags for wp_kses() function
*
* @return array Array of allowed html tags.
*/
function allowed_html_tags() {
return array(
'a' => array(
... | [
{
"answer_id": 276301,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>I hope that you don't have to modify the allowed array with the full data name (data-ter... | 2017/08/09 | [
"https://wordpress.stackexchange.com/questions/276298",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58895/"
] | I added a function that will return the allowed html tags array
```
if ( ! function_exists( 'allowed_html_tags' ) ) {
/**
* Allowed html tags for wp_kses() function
*
* @return array Array of allowed html tags.
*/
function allowed_html_tags() {
return array(
'a' => array(
'href' => ar... | >
> I hope that you don't have to modify the allowed array with the full data name (data-term) for this to work...
>
>
>
It appears to be that way. `data-term` and `data` aren't the same attribute after all, and poking around in core I don't think any sort of regular expressions can be used as supported attributes... |
276,303 | <p>I am trying to change the stylesheet file version using the <code>filemtime()</code> function with the <code>wp_enqueue_style</code> with the following snippet</p>
<pre><code>function pro_styles()
{
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() .'/child-style.css', array(), filemtime(get_styleshee... | [
{
"answer_id": 276307,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 6,
"selected": true,
"text": "<p>It's because you're retrieving it via URL, but <code>filemtime()</code> requires a path. Use <code>get_s... | 2017/08/09 | [
"https://wordpress.stackexchange.com/questions/276303",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102224/"
] | I am trying to change the stylesheet file version using the `filemtime()` function with the `wp_enqueue_style` with the following snippet
```
function pro_styles()
{
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() .'/child-style.css', array(), filemtime(get_stylesheet_directory_uri() .'/child-style.css... | It's because you're retrieving it via URL, but `filemtime()` requires a path. Use `get_stylesheet_directory()` instead. That returns a path:
```
function pro_styles()
{
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() .'/child-style.css', array(), filemtime(get_stylesheet_directory() .'/child-style.css'... |
276,304 | <p>I have created a custom taxonomy brands and added some brands to various posts.
I also created a file called taxonomy-brands.php and it seems to be working fine. If I visit www.domain.com/brands/adidas then I can see all the adidas branded posts.</p>
<p>However when I visit www.domain.com/brands/ I receive a 404 er... | [
{
"answer_id": 276307,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 6,
"selected": true,
"text": "<p>It's because you're retrieving it via URL, but <code>filemtime()</code> requires a path. Use <code>get_s... | 2017/08/09 | [
"https://wordpress.stackexchange.com/questions/276304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27593/"
] | I have created a custom taxonomy brands and added some brands to various posts.
I also created a file called taxonomy-brands.php and it seems to be working fine. If I visit www.domain.com/brands/adidas then I can see all the adidas branded posts.
However when I visit www.domain.com/brands/ I receive a 404 error. I wou... | It's because you're retrieving it via URL, but `filemtime()` requires a path. Use `get_stylesheet_directory()` instead. That returns a path:
```
function pro_styles()
{
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() .'/child-style.css', array(), filemtime(get_stylesheet_directory() .'/child-style.css'... |
276,317 | <p>I'm using WordPress social login plugin shortcode <code>[wordpress_social_login]</code>.
I want to put it in custom template file inside theme directory.</p>
<p>example:</p>
<pre><code><?php
/*
Template Name: Social Login Page
*/
echo do_shortcode('[wordpress_social_login]');
</code></pre>
<p>so I create a bl... | [
{
"answer_id": 276307,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 6,
"selected": true,
"text": "<p>It's because you're retrieving it via URL, but <code>filemtime()</code> requires a path. Use <code>get_s... | 2017/08/09 | [
"https://wordpress.stackexchange.com/questions/276317",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107171/"
] | I'm using WordPress social login plugin shortcode `[wordpress_social_login]`.
I want to put it in custom template file inside theme directory.
example:
```
<?php
/*
Template Name: Social Login Page
*/
echo do_shortcode('[wordpress_social_login]');
```
so I create a blank page using this template, the rendering is ... | It's because you're retrieving it via URL, but `filemtime()` requires a path. Use `get_stylesheet_directory()` instead. That returns a path:
```
function pro_styles()
{
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() .'/child-style.css', array(), filemtime(get_stylesheet_directory() .'/child-style.css'... |
276,325 | <p>I've been editing a few pages including the URLs. Should I have kept these pages and made a new one and then redirected, or is it fine to just redirect a page that doesn't exist anymore?.</p>
<p>Thanks,
Andy.</p>
| [
{
"answer_id": 276307,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 6,
"selected": true,
"text": "<p>It's because you're retrieving it via URL, but <code>filemtime()</code> requires a path. Use <code>get_s... | 2017/08/09 | [
"https://wordpress.stackexchange.com/questions/276325",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125547/"
] | I've been editing a few pages including the URLs. Should I have kept these pages and made a new one and then redirected, or is it fine to just redirect a page that doesn't exist anymore?.
Thanks,
Andy. | It's because you're retrieving it via URL, but `filemtime()` requires a path. Use `get_stylesheet_directory()` instead. That returns a path:
```
function pro_styles()
{
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() .'/child-style.css', array(), filemtime(get_stylesheet_directory() .'/child-style.css'... |
276,343 | <p>I created a Forum plugin and would like to have a cystomized search result template, I added the following excerpt in the plugin execution file:</p>
<pre><code>add_filter('single_template', 'pagina_topicos');
function pagina_topicos($single) {
global $wp_query, $post;
/* Informando o Modelo de Página das Aula... | [
{
"answer_id": 276307,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 6,
"selected": true,
"text": "<p>It's because you're retrieving it via URL, but <code>filemtime()</code> requires a path. Use <code>get_s... | 2017/08/09 | [
"https://wordpress.stackexchange.com/questions/276343",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124171/"
] | I created a Forum plugin and would like to have a cystomized search result template, I added the following excerpt in the plugin execution file:
```
add_filter('single_template', 'pagina_topicos');
function pagina_topicos($single) {
global $wp_query, $post;
/* Informando o Modelo de Página das Aulas */
if ($post... | It's because you're retrieving it via URL, but `filemtime()` requires a path. Use `get_stylesheet_directory()` instead. That returns a path:
```
function pro_styles()
{
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() .'/child-style.css', array(), filemtime(get_stylesheet_directory() .'/child-style.css'... |
276,396 | <p>My Seach Page URLs: </p>
<blockquote>
<p><a href="https://www.example.com/search/keyword/page/2/" rel="nofollow noreferrer">https://www.example.com/search/keyword/page/2/</a></p>
</blockquote>
<p>Here my custom search page:</p>
<pre><code><?php
if($_GET['search_text'] && !empty($_GET['searc... | [
{
"answer_id": 276307,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 6,
"selected": true,
"text": "<p>It's because you're retrieving it via URL, but <code>filemtime()</code> requires a path. Use <code>get_s... | 2017/08/09 | [
"https://wordpress.stackexchange.com/questions/276396",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112778/"
] | My Seach Page URLs:
>
> <https://www.example.com/search/keyword/page/2/>
>
>
>
Here my custom search page:
```
<?php
if($_GET['search_text'] && !empty($_GET['search_text']))
{
$text = $_GET['search_text'];
}
else
{
$text = urldecode( get_query_var('search_text') ) ; ... | It's because you're retrieving it via URL, but `filemtime()` requires a path. Use `get_stylesheet_directory()` instead. That returns a path:
```
function pro_styles()
{
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() .'/child-style.css', array(), filemtime(get_stylesheet_directory() .'/child-style.css'... |
276,407 | <p>5 of my templates require specific Javascript. Currently the below works great to load Javascript into Page Template A. </p>
<pre><code> add_action('wp_enqueue_scripts','css-flags');
function css-flags(){
if ( is_page_template('page-template-a.php') ) {
wp_enqueue_style('css-flags', get_template_directory_ur... | [
{
"answer_id": 276409,
"author": "Cedon",
"author_id": 80069,
"author_profile": "https://wordpress.stackexchange.com/users/80069",
"pm_score": 0,
"selected": false,
"text": "<p>In PHP, <code>||</code> is the OR operator so you have to build it that way feeding <code>is_page_template()</c... | 2017/08/10 | [
"https://wordpress.stackexchange.com/questions/276407",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | 5 of my templates require specific Javascript. Currently the below works great to load Javascript into Page Template A.
```
add_action('wp_enqueue_scripts','css-flags');
function css-flags(){
if ( is_page_template('page-template-a.php') ) {
wp_enqueue_style('css-flags', get_template_directory_uri() .
'/cs... | Page template seems like a more obscure thing to base the loading of your CSS on. Maybe not use template name, and use page name instead as it's more apparent to theme users. If interested you could try something more like this:
```
add_action('wp_enqueue_scripts', 'load_special_page_styles');
function load_special_pa... |
276,459 | <p>I recently migrated my old website to this domain: <a href="https://thequintessentialmind.com/" rel="nofollow noreferrer">https://thequintessentialmind.com/</a></p>
<p>It is a wordpress site and in the articles, example here: <a href="https://thequintessentialmind.com/how-to-never-run-out-of-things-to-say/" rel="no... | [
{
"answer_id": 276464,
"author": "joeDaigle",
"author_id": 76766,
"author_profile": "https://wordpress.stackexchange.com/users/76766",
"pm_score": -1,
"selected": false,
"text": "<p>Have you tried clicking on the filename generating the error? Usually you will see the file/resource in th... | 2017/08/10 | [
"https://wordpress.stackexchange.com/questions/276459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111649/"
] | I recently migrated my old website to this domain: <https://thequintessentialmind.com/>
It is a wordpress site and in the articles, example here: <https://thequintessentialmind.com/how-to-never-run-out-of-things-to-say/>, in the console of google inspector it suggest that there is a .gif file that should be renamed fr... | A quick squint at your site reveals that you're serving it with Nginx, so a simple `.htaccess` redirect won't work.
The following block in your Nginx config should take care of any stray locally-served files that are still coming over http:
```
server {
listen 80 default_server;
listen [::]:80 default_server;... |
276,476 | <p>I am trying to develop a plugin for basic SEO purposes, as a lot of people I know don't like using Yoast. I literally just started the plugin, and am building out the activation message displayed to the user when they activate the plugin. I am having trouble with a mix between OOP and built-in Wordpress functions, a... | [
{
"answer_id": 276478,
"author": "Chris Cox",
"author_id": 1718,
"author_profile": "https://wordpress.stackexchange.com/users/1718",
"pm_score": 2,
"selected": false,
"text": "<p>You really need to be registering your activation/deactivation/uninstall hooks outside of your plugin class a... | 2017/08/10 | [
"https://wordpress.stackexchange.com/questions/276476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123428/"
] | I am trying to develop a plugin for basic SEO purposes, as a lot of people I know don't like using Yoast. I literally just started the plugin, and am building out the activation message displayed to the user when they activate the plugin. I am having trouble with a mix between OOP and built-in Wordpress functions, and ... | Having reread your question, I think I see the issue, and it stems from a misunderstanding of how `register_activation_hook` works, combined with some confusion over how you're bootstrapping your code and what it means to bootstrap
Part 1: `register_activation_hook`
----------------------------------
This function ta... |
276,494 | <p>It is all started after I updated some of the plugins in my Wordpress site. </p>
<p>Right now I'm getting an Http Internal 500 Error when I try to access WordPress dashboard.</p>
<p>Error at my error log file in File Manager.</p>
<pre><code>PHP Fatal error: Call to a member function locale() on a non-object in /... | [
{
"answer_id": 276496,
"author": "Chris Cox",
"author_id": 1718,
"author_profile": "https://wordpress.stackexchange.com/users/1718",
"pm_score": 2,
"selected": false,
"text": "<p><code>$sitepress</code> is a global set by WPML, IIRC. Change your line 25 as follows:</p>\n\n<pre><code>if(i... | 2017/08/10 | [
"https://wordpress.stackexchange.com/questions/276494",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124648/"
] | It is all started after I updated some of the plugins in my Wordpress site.
Right now I'm getting an Http Internal 500 Error when I try to access WordPress dashboard.
Error at my error log file in File Manager.
```
PHP Fatal error: Call to a member function locale() on a non-object in /wp-content/themes/my_theme/l... | `$sitepress` is a global set by WPML, IIRC. Change your line 25 as follows:
```
if(isset($sitepress) && is_object($sitepress)) {
setlocale(LC_TIME, $sitepress->locale() . '.UTF-8');
}
```
As a general rule you shouldn't assume in a theme that anything included in or set by a plugin will be available, because it's ... |
276,507 | <p>I have an extremely frustrating problem where mobile (tested chrome on android & ios, and safari on ios) is always using the largest sized image from the srcset (even if a smaller size is EXPLICITLY chosen in the editor).</p>
<p>Here is a summary of the problem:</p>
<ul>
<li>In Wordpress editor, when inserting... | [
{
"answer_id": 276496,
"author": "Chris Cox",
"author_id": 1718,
"author_profile": "https://wordpress.stackexchange.com/users/1718",
"pm_score": 2,
"selected": false,
"text": "<p><code>$sitepress</code> is a global set by WPML, IIRC. Change your line 25 as follows:</p>\n\n<pre><code>if(i... | 2017/08/10 | [
"https://wordpress.stackexchange.com/questions/276507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125652/"
] | I have an extremely frustrating problem where mobile (tested chrome on android & ios, and safari on ios) is always using the largest sized image from the srcset (even if a smaller size is EXPLICITLY chosen in the editor).
Here is a summary of the problem:
* In Wordpress editor, when inserting an image, I choose LARGE... | `$sitepress` is a global set by WPML, IIRC. Change your line 25 as follows:
```
if(isset($sitepress) && is_object($sitepress)) {
setlocale(LC_TIME, $sitepress->locale() . '.UTF-8');
}
```
As a general rule you shouldn't assume in a theme that anything included in or set by a plugin will be available, because it's ... |
276,515 | <p>I'm using the following code in WordPress HTML page in Azure:</p>
<pre><code> <html>
<body>
<?php
global $wpdb;
$result = $wpdb -> get_results ( "
SELECT 'VillageLeadersName'
FROM wp_villageleaderdb
WHERE VillageID = 'V001' AND VillageLeaderPosition = 'Sarpanch' LIMIT 0, 100
" );
echo $... | [
{
"answer_id": 276559,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>Your web server has probably some misconfiguration regarding the execution of PHP files, but regardless, ... | 2017/08/10 | [
"https://wordpress.stackexchange.com/questions/276515",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125656/"
] | I'm using the following code in WordPress HTML page in Azure:
```
<html>
<body>
<?php
global $wpdb;
$result = $wpdb -> get_results ( "
SELECT 'VillageLeadersName'
FROM wp_villageleaderdb
WHERE VillageID = 'V001' AND VillageLeaderPosition = 'Sarpanch' LIMIT 0, 100
" );
echo $result;
echo $row['VillageLeade... | It's very clear that your file is not executing PHP functions, and the problem probably is because you are saving this file as `something.html`, storing it inside your theme or WordPress installation directory.
What you can do, is to wrap this as a function or shortcode, and then create a page and use that shortcode o... |
276,517 | <p>How can I view my posts in ascending order by number of views?</p>
<p>This is just for internal use so I can see how different posts are performing. Currently if I go to posts in the dashboard I can only filter by date. With over 900 posts I want to be able to see them in order by number of views. Views is a field ... | [
{
"answer_id": 276559,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>Your web server has probably some misconfiguration regarding the execution of PHP files, but regardless, ... | 2017/08/10 | [
"https://wordpress.stackexchange.com/questions/276517",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125659/"
] | How can I view my posts in ascending order by number of views?
This is just for internal use so I can see how different posts are performing. Currently if I go to posts in the dashboard I can only filter by date. With over 900 posts I want to be able to see them in order by number of views. Views is a field there but ... | It's very clear that your file is not executing PHP functions, and the problem probably is because you are saving this file as `something.html`, storing it inside your theme or WordPress installation directory.
What you can do, is to wrap this as a function or shortcode, and then create a page and use that shortcode o... |
276,556 | <p>I am trying to alter a plugin that has this code to display Related Categories names under the post:</p>
<pre><code><?php if ( count( get_the_category() ) ) : ?>
<span class="cat-links">
<?php printf( __( '<span class="%1$s">See related Videos</span> %2$s', 'posts-in-p... | [
{
"answer_id": 276561,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>use <code>wp_list_categories</code> function instead and use 'exclude' argument.</p>\n\n<p>use this code</p>\n\n<... | 2017/08/11 | [
"https://wordpress.stackexchange.com/questions/276556",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78121/"
] | I am trying to alter a plugin that has this code to display Related Categories names under the post:
```
<?php if ( count( get_the_category() ) ) : ?>
<span class="cat-links">
<?php printf( __( '<span class="%1$s">See related Videos</span> %2$s', 'posts-in-page' ), 'entry-utility-prep entry-utility... | ```
$d = get_the_category();
$glu = [];
foreach($d as $rst ):
//exclude category name
if($rst->name != 'Sticky'):
$glu[]="<a href=".get_category_link( $rst->cat_ID ).">{$rst->name}</a>";
endif;
endforeach;
//error_log(print_r($glu, true).'/n', 3, WP_CONTENT_DIR.'/debug.log');
echo "These are the catego... |
276,637 | <pre><code><?php
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' => $post->ID,
'order' => 'ASC',
'orderby' => 'menu_order'
);
$parent = new WP_Query( $args );
if ( $parent->have_posts() ) : ?>
<?php while ( $... | [
{
"answer_id": 276641,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 0,
"selected": false,
"text": "<p>I just used this in a site! What about something like this:</p>\n\n<pre><code>function rt_list_child_pages() ... | 2017/08/11 | [
"https://wordpress.stackexchange.com/questions/276637",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124648/"
] | ```
<?php
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' => $post->ID,
'order' => 'ASC',
'orderby' => 'menu_order'
);
$parent = new WP_Query( $args );
if ( $parent->have_posts() ) : ?>
<?php while ( $parent->have_posts() ) : $parent->the_... | You should use this attribute in the $args array to get children of specific page by **Parent ID**
```
'child_of' => 20,
```
More information:
<https://codex.wordpress.org/Function_Reference/get_pages> |
276,644 | <p>I am using this code in the functions.php of my theme, in order to add cart information next to the cart menu item.</p>
<p>However, this code adds this information outside the <code><li></code> and I would like the information to be into the <code><li></code>.</p>
<p>Can you help me change this code in... | [
{
"answer_id": 276641,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 0,
"selected": false,
"text": "<p>I just used this in a site! What about something like this:</p>\n\n<pre><code>function rt_list_child_pages() ... | 2017/08/11 | [
"https://wordpress.stackexchange.com/questions/276644",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121787/"
] | I am using this code in the functions.php of my theme, in order to add cart information next to the cart menu item.
However, this code adds this information outside the `<li>` and I would like the information to be into the `<li>`.
Can you help me change this code in order to display the info within the `<li>`?
Than... | You should use this attribute in the $args array to get children of specific page by **Parent ID**
```
'child_of' => 20,
```
More information:
<https://codex.wordpress.org/Function_Reference/get_pages> |
276,653 | <p>The package could not be installed. The style.css stylesheet doesn’t contain a valid theme header.</p>
<p>What do you guys think went wrong?</p>
| [
{
"answer_id": 276654,
"author": "Kort",
"author_id": 74680,
"author_profile": "https://wordpress.stackexchange.com/users/74680",
"pm_score": 1,
"selected": false,
"text": "<p>I think the problem is you're trying to upload the entire zip file which also includes documentation and license... | 2017/08/11 | [
"https://wordpress.stackexchange.com/questions/276653",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125729/"
] | The package could not be installed. The style.css stylesheet doesn’t contain a valid theme header.
What do you guys think went wrong? | Your theme’s stylesheet must contain a commented-out header with the theme’s name:
```
/*Theme Name: nameoftheme*/
``` |
276,666 | <blockquote>
<p>Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to
allocate 42240 bytes) in
/home/dh_w7t9sk/morleywines.com/wp-content/plugins/js_composer/include/params/iconpicker/iconpicker.php
on line 720</p>
</blockquote>
<p>I can't seem to get back into my dashboard. Can you help me pl... | [
{
"answer_id": 276672,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": -1,
"selected": false,
"text": "<p>THe error message indicates an issue with the 'js-composer' plugin. Rename that folder to get control... | 2017/08/12 | [
"https://wordpress.stackexchange.com/questions/276666",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125735/"
] | >
> Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to
> allocate 42240 bytes) in
> /home/dh\_w7t9sk/morleywines.com/wp-content/plugins/js\_composer/include/params/iconpicker/iconpicker.php
> on line 720
>
>
>
I can't seem to get back into my dashboard. Can you help me please | Add below code in `wp-config.php` file.
```
define('WP_MEMORY_LIMIT', '256M');
```
For more details check "Increasing memory allocated to PHP" here <https://codex.wordpress.org/Editing_wp-config.php> |
276,728 | <p><strong>*UPDATE - This wasn't showing because of a cache issue. The comment referencing changing the jQuery to :first-child instead of :first was indeed the only issue that needed to be addressed. *</strong></p>
<p>I am creating a WordPress theme and the image slider fails to do three things:</p>
<p>1) When clicki... | [
{
"answer_id": 276672,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": -1,
"selected": false,
"text": "<p>THe error message indicates an issue with the 'js-composer' plugin. Rename that folder to get control... | 2017/08/12 | [
"https://wordpress.stackexchange.com/questions/276728",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114269/"
] | **\*UPDATE - This wasn't showing because of a cache issue. The comment referencing changing the jQuery to :first-child instead of :first was indeed the only issue that needed to be addressed. \***
I am creating a WordPress theme and the image slider fails to do three things:
1) When clicking an indicator it does not ... | Add below code in `wp-config.php` file.
```
define('WP_MEMORY_LIMIT', '256M');
```
For more details check "Increasing memory allocated to PHP" here <https://codex.wordpress.org/Editing_wp-config.php> |
276,731 | <p>I am working on a Wordpress theme using a template to manage sports team, matches, players, etc.</p>
<p>I settled my local wordpress time in French.
In the blog part, no problem the post are displaying date in French.</p>
<p>But there is a all part with custom post types managed by a plugin. The dates displayed by... | [
{
"answer_id": 276762,
"author": "Benoti",
"author_id": 58141,
"author_profile": "https://wordpress.stackexchange.com/users/58141",
"pm_score": 1,
"selected": false,
"text": "<p>You need to grab the WordPress date option on the first parameter of date_i18n function :</p>\n\n<pre><code>da... | 2017/08/12 | [
"https://wordpress.stackexchange.com/questions/276731",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125770/"
] | I am working on a Wordpress theme using a template to manage sports team, matches, players, etc.
I settled my local wordpress time in French.
In the blog part, no problem the post are displaying date in French.
But there is a all part with custom post types managed by a plugin. The dates displayed by this plugins rem... | You need to grab the WordPress date option on the first parameter of date\_i18n function :
```
date_i18n( get_option( 'date_format' ), strtotime( '11/15-1976' ) );
```
You can see this example in the function codex page : [date\_i18n()](https://codex.wordpress.org/Function_Reference/date_i18n) |
276,732 | <p>Is it possible to create a plugin directly from the admin panel?</p>
<p>I cannot find any such plugin to create plugins with when searching, and that really makes me curious. Are there security risks with this that simply prevent people from developing such a thing? Or is the file system inaccessible for creating f... | [
{
"answer_id": 276735,
"author": "Mihai Papuc",
"author_id": 44326,
"author_profile": "https://wordpress.stackexchange.com/users/44326",
"pm_score": 2,
"selected": false,
"text": "<p>Why would anybody create such a tool? Creating a plugin <a href=\"https://developer.wordpress.org/plugins... | 2017/08/12 | [
"https://wordpress.stackexchange.com/questions/276732",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36207/"
] | Is it possible to create a plugin directly from the admin panel?
I cannot find any such plugin to create plugins with when searching, and that really makes me curious. Are there security risks with this that simply prevent people from developing such a thing? Or is the file system inaccessible for creating files?
As ... | Why would anybody create such a tool? Creating a plugin [is really easy](https://developer.wordpress.org/plugins/the-basics/):
>
> At its simplest, a WordPress plugin is a PHP file with a WordPress plugin header comment.
>
>
>
Here is the plugin header:
```
<?php
/*
Plugin Name: YOUR PLUGIN NAME
*/
```
Just ... |
276,781 | <p>I'm wrapping up a port from Jekyll to WordPress and have several thousand relative URLs I need to remap so they're absolute within my posts.</p>
<p><strong>Actual URL examples:</strong></p>
<pre><code>/gangs/gangster-disciples
/housing-projects/cabrini-green
/hoods/bridgeport
</code></pre>
<p><strong>Expected URL... | [
{
"answer_id": 276782,
"author": "ClemC",
"author_id": 73239,
"author_profile": "https://wordpress.stackexchange.com/users/73239",
"pm_score": 2,
"selected": false,
"text": "<p>There are several plugin solutions such as <a href=\"https://wordpress.org/plugins/search-and-replace/\" rel=\"... | 2017/08/13 | [
"https://wordpress.stackexchange.com/questions/276781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/117731/"
] | I'm wrapping up a port from Jekyll to WordPress and have several thousand relative URLs I need to remap so they're absolute within my posts.
**Actual URL examples:**
```
/gangs/gangster-disciples
/housing-projects/cabrini-green
/hoods/bridgeport
```
**Expected URL samples:**
```
http://example.com/gang/gangster-di... | [WP CLI](http://wp-cli.org/) is a great tool for performing common admin and maintenance tasks on a WordPress install. It has a large [range of commands](https://developer.wordpress.org/cli/commands/) that among other things allow you to install plugins, regenerate thumbnails, and in your case, perform a [search and re... |
276,801 | <p>I have a custom search page (<code>searchpage.php</code>) using pagination, and I am tring to add lines like below dynamically to my <code>header.php</code> inside <code><head></head></code> tag for better <a href="https://www.ayima.com/knowledge/guides/conquering-pagination-guide.html" rel="nofollow nor... | [
{
"answer_id": 276782,
"author": "ClemC",
"author_id": 73239,
"author_profile": "https://wordpress.stackexchange.com/users/73239",
"pm_score": 2,
"selected": false,
"text": "<p>There are several plugin solutions such as <a href=\"https://wordpress.org/plugins/search-and-replace/\" rel=\"... | 2017/08/14 | [
"https://wordpress.stackexchange.com/questions/276801",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112778/"
] | I have a custom search page (`searchpage.php`) using pagination, and I am tring to add lines like below dynamically to my `header.php` inside `<head></head>` tag for better [pagination SEO](https://www.ayima.com/knowledge/guides/conquering-pagination-guide.html).
```
<link rel="prev" href="https://www.example.com/sear... | [WP CLI](http://wp-cli.org/) is a great tool for performing common admin and maintenance tasks on a WordPress install. It has a large [range of commands](https://developer.wordpress.org/cli/commands/) that among other things allow you to install plugins, regenerate thumbnails, and in your case, perform a [search and re... |
276,802 | <p>I am trying to do a simple basic shortcode and it fails. I have boiled it down to the most simple test and it still fails.</p>
<p>Here is the code:</p>
<pre><code>/** My test shortcode */
function bp_basic_shortcode() {
return "This is a shortcode doing this!";
}
add_shortcode( 'basic_shortcode', 'bp_basic_shortc... | [
{
"answer_id": 276803,
"author": "jmcbade",
"author_id": 125814,
"author_profile": "https://wordpress.stackexchange.com/users/125814",
"pm_score": -1,
"selected": false,
"text": "<p>Silly spell check on the MAC - It's \"shortcodes\" not \"shortcakes\"</p>\n\n<p>But to answer the questio... | 2017/08/14 | [
"https://wordpress.stackexchange.com/questions/276802",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125814/"
] | I am trying to do a simple basic shortcode and it fails. I have boiled it down to the most simple test and it still fails.
Here is the code:
```
/** My test shortcode */
function bp_basic_shortcode() {
return "This is a shortcode doing this!";
}
add_shortcode( 'basic_shortcode', 'bp_basic_shortcode');
```
In trying... | You registered the shortcode `basic_shortcode`, but you tested the wrong `[basic-shortcode]`. These are two different things. |
276,805 | <p><a href="https://vip.wordpress.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/" rel="nofollow noreferrer">WordPress VIP</a> and other <a href="https://10up.github.io/Engineering-Best-Practices/php/#efficient-database-queries" rel="nofollow noreferrer">development guides</a> I've seen re... | [
{
"answer_id": 276803,
"author": "jmcbade",
"author_id": 125814,
"author_profile": "https://wordpress.stackexchange.com/users/125814",
"pm_score": -1,
"selected": false,
"text": "<p>Silly spell check on the MAC - It's \"shortcodes\" not \"shortcakes\"</p>\n\n<p>But to answer the questio... | 2017/08/14 | [
"https://wordpress.stackexchange.com/questions/276805",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41351/"
] | [WordPress VIP](https://vip.wordpress.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/) and other [development guides](https://10up.github.io/Engineering-Best-Practices/php/#efficient-database-queries) I've seen recommend avoiding the use of post\_\_not\_in for performance reasons when usin... | You registered the shortcode `basic_shortcode`, but you tested the wrong `[basic-shortcode]`. These are two different things. |
276,825 | <p>I developed a Plugin.It automatically creates the video URLs in the database.</p>
<p>The table consists of id, title, URL, Thurl.
We can send the content to the database using the form from the wp-admin panel(If videos by pk).</p>
<p>I want to retrieve the rows from the database and display them.First when the pag... | [
{
"answer_id": 277011,
"author": "Thamaraiselvam",
"author_id": 67717,
"author_profile": "https://wordpress.stackexchange.com/users/67717",
"pm_score": 2,
"selected": false,
"text": "<p>Here is Codex to make proper ajax calls\n<a href=\"https://codex.wordpress.org/AJAX_in_Plugins\" rel=\... | 2017/08/14 | [
"https://wordpress.stackexchange.com/questions/276825",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125822/"
] | I developed a Plugin.It automatically creates the video URLs in the database.
The table consists of id, title, URL, Thurl.
We can send the content to the database using the form from the wp-admin panel(If videos by pk).
I want to retrieve the rows from the database and display them.First when the page loads, it shoul... | Here is one approach, by using an `iframe` for the AJAX request it can be much easier to learn and debug your AJAX code... try this:
```
function videos_info() {
global $wpdb;
// add LIMIT 3 here
$videos = $wpdb->get_results( "SELECT * FROM wp_ifvideos ORDER BY id DESC LIMIT 3" , ARRAY_N);
foreach (... |
276,842 | <p>I've a custom post type <code>Clinics</code> and <code>Doctors</code>. Each clinic has own clinic_id (through custom fields). Each doctor has the same field <code>clinic_id</code> with numbers of clinics where he works. </p>
<p>I need on <code>single-clinic.php</code> to display all doctors, that working here (comp... | [
{
"answer_id": 277011,
"author": "Thamaraiselvam",
"author_id": 67717,
"author_profile": "https://wordpress.stackexchange.com/users/67717",
"pm_score": 2,
"selected": false,
"text": "<p>Here is Codex to make proper ajax calls\n<a href=\"https://codex.wordpress.org/AJAX_in_Plugins\" rel=\... | 2017/08/14 | [
"https://wordpress.stackexchange.com/questions/276842",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125831/"
] | I've a custom post type `Clinics` and `Doctors`. Each clinic has own clinic\_id (through custom fields). Each doctor has the same field `clinic_id` with numbers of clinics where he works.
I need on `single-clinic.php` to display all doctors, that working here (compare clinic\_id of a doctor with clinic\_id of current... | Here is one approach, by using an `iframe` for the AJAX request it can be much easier to learn and debug your AJAX code... try this:
```
function videos_info() {
global $wpdb;
// add LIMIT 3 here
$videos = $wpdb->get_results( "SELECT * FROM wp_ifvideos ORDER BY id DESC LIMIT 3" , ARRAY_N);
foreach (... |
276,844 | <p>I would like to redirect to a post if the taxonomy term it belongs to has only one post assigned to it and so far I have this:</p>
<pre><code>$term_id = get_queried_object()->term_id;
$taxonomy_name = 'product_range';
$term_children = get_term_children( $term_id, $taxonomy_name );
foreach ( $term_children as $c... | [
{
"answer_id": 277011,
"author": "Thamaraiselvam",
"author_id": 67717,
"author_profile": "https://wordpress.stackexchange.com/users/67717",
"pm_score": 2,
"selected": false,
"text": "<p>Here is Codex to make proper ajax calls\n<a href=\"https://codex.wordpress.org/AJAX_in_Plugins\" rel=\... | 2017/08/14 | [
"https://wordpress.stackexchange.com/questions/276844",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38592/"
] | I would like to redirect to a post if the taxonomy term it belongs to has only one post assigned to it and so far I have this:
```
$term_id = get_queried_object()->term_id;
$taxonomy_name = 'product_range';
$term_children = get_term_children( $term_id, $taxonomy_name );
foreach ( $term_children as $child ) {
$term ... | Here is one approach, by using an `iframe` for the AJAX request it can be much easier to learn and debug your AJAX code... try this:
```
function videos_info() {
global $wpdb;
// add LIMIT 3 here
$videos = $wpdb->get_results( "SELECT * FROM wp_ifvideos ORDER BY id DESC LIMIT 3" , ARRAY_N);
foreach (... |
276,856 | <p>I am building a WordPress website with an Underscore theme, it is hosted on flywheel. Everytime I make changes to a page, the styling <code>style.css</code> file is not picked up unless I do a hard reload/ clear cache. </p>
<p>Obviously I want it to load on everyone's computer immediately without the need to clear ... | [
{
"answer_id": 276859,
"author": "HOY",
"author_id": 112778,
"author_profile": "https://wordpress.stackexchange.com/users/112778",
"pm_score": 0,
"selected": false,
"text": "<p>Could be related to changing the expiration period by modifing <code>.htaccess</code>. </p>\n\n<p>For example m... | 2017/08/14 | [
"https://wordpress.stackexchange.com/questions/276856",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123149/"
] | I am building a WordPress website with an Underscore theme, it is hosted on flywheel. Everytime I make changes to a page, the styling `style.css` file is not picked up unless I do a hard reload/ clear cache.
Obviously I want it to load on everyone's computer immediately without the need to clear the cache. What is th... | If the files are being cached, then whatever caching solution you are using is working! That's why there's a clear caching button available. Typically JS and CSS files will be cached. While you are in development I recommend changing the version of the file being cached. This can be done by updating the wp\_enqueue\_sc... |
276,870 | <p>I know this is much common and I did not find the right answer. So to show all possible image sizes I have done:</p>
<pre><code>add_filter( 'image_size_names_choose', 'fashmag_image_sizes_choose' );
function fashmag_image_sizes_choose( $sizes ) {
$image_sizes = get_intermediate_image_sizes();
return $image_size... | [
{
"answer_id": 276860,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 1,
"selected": false,
"text": "<p>In your options page each field should be put into an options array. For Example:</p>\n\n<p>When you register... | 2017/08/14 | [
"https://wordpress.stackexchange.com/questions/276870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48294/"
] | I know this is much common and I did not find the right answer. So to show all possible image sizes I have done:
```
add_filter( 'image_size_names_choose', 'fashmag_image_sizes_choose' );
function fashmag_image_sizes_choose( $sizes ) {
$image_sizes = get_intermediate_image_sizes();
return $image_sizes;
}
```
Thi... | Turns out it a lot simpler than I though. When you use `register_setting("something", "name")` then to get it in the plugin, just use `get_option("name")`. |
276,887 | <p>I entered a header image as a logo to the theme ajaira. Although the image has the right size, it won't fit onto the page.</p>
<p>Any help is much appreciated.</p>
<p><a href="https://i.stack.imgur.com/nmvak.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nmvak.png" alt="enter image description ... | [
{
"answer_id": 276895,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>If you can look at the CSS class used for the header image, you can use some customized CSS to change ... | 2017/08/14 | [
"https://wordpress.stackexchange.com/questions/276887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125845/"
] | I entered a header image as a logo to the theme ajaira. Although the image has the right size, it won't fit onto the page.
Any help is much appreciated.
[](https://i.stack.imgur.com/nmvak.png) | It looks like the background image was added to the tag inline. You will need to change the following:
Locate your template file (probably header.php) which has the tag Inside style="" remove `background-size: cover` and replace it with `background-size:auto 100%` then add `background-position: center`
This will let ... |
276,889 | <p>I am developing a website using wampserver on localhost and I am trying to view my site on mobile on my local network. </p>
<p>I changed the home and site URL in <code>Settings > General</code> from </p>
<blockquote>
<p><a href="http://localhost/site/wordpress" rel="nofollow noreferrer">http://localhost/site/... | [
{
"answer_id": 276965,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 1,
"selected": false,
"text": "<p>Relative paths act differently when they are used in a CSS file. The behavior is still the same, and the pa... | 2017/08/14 | [
"https://wordpress.stackexchange.com/questions/276889",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125843/"
] | I am developing a website using wampserver on localhost and I am trying to view my site on mobile on my local network.
I changed the home and site URL in `Settings > General` from
>
> <http://localhost/site/wordpress>
>
>
>
To
>
> <http://ip/site/wordpress>
>
>
>
I also used the velvet blues URL plugin ... | Relative paths act differently when they are used in a CSS file. The behavior is still the same, and the path is still relative, but to a human it might seem confusing.
When you use a path like this for your image:
```
<img src="/path/image.jpg"/>
```
The browser will look inside the `path` folder, located at the ... |
276,890 | <p>I have a whole entire <code>js</code> folder of scripts and it would be tedious to have to load them all with <code>wp_enqueue_script()</code> one by one. </p>
<p>Is there a way I can just insert the directory they are all in and it do it for me?</p>
| [
{
"answer_id": 276897,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": false,
"text": "<p>There's nothing wrong with enqueuing many files by using <code>wp_enqueue_script</code>. If you are referri... | 2017/08/14 | [
"https://wordpress.stackexchange.com/questions/276890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80568/"
] | I have a whole entire `js` folder of scripts and it would be tedious to have to load them all with `wp_enqueue_script()` one by one.
Is there a way I can just insert the directory they are all in and it do it for me? | There's nothing wrong with enqueuing many files by using `wp_enqueue_script`. If you are referring to it as frustrating, then there is a simple solution for this.
PHP offers a function that can list files and directories. By using [`glob`](http://php.net/manual/en/function.glob.php) you can list every `.js` file in yo... |
276,910 | <p>I have 2 area of post to show in each page.</p>
<p>first is on the widget (it's on the top of each page).</p>
<p>second is on the posts area (it show below the widget).</p>
<p>It's separated queries. article on the widget is another query and article on the posts area is main query.</p>
<p>So,I don't want it to ... | [
{
"answer_id": 276962,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": true,
"text": "<p>Rather than trying to set a global variable, just use the main query for both the widget and the other con... | 2017/08/15 | [
"https://wordpress.stackexchange.com/questions/276910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125859/"
] | I have 2 area of post to show in each page.
first is on the widget (it's on the top of each page).
second is on the posts area (it show below the widget).
It's separated queries. article on the widget is another query and article on the posts area is main query.
So,I don't want it to have same article in both area ... | Rather than trying to set a global variable, just use the main query for both the widget and the other content. Simply adjust your Loop.
If you share more of your code perhaps we can help specify where this would go, but the general idea is to move the start of the Loop above wherever you need to display the widget. U... |
276,950 | <p>I want to track how many views a post has had for every day. So that I can get all kind of interesting trends out of it later. For example most visit last three days.</p>
<p>But what is the best way to store this data? Most tutorials on google search is about just storing the total views. Not per day. If I would st... | [
{
"answer_id": 276952,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 1,
"selected": false,
"text": "<p>When you want to store the data for a specific period of time, you can use the <a href=\"https://codex.word... | 2017/08/15 | [
"https://wordpress.stackexchange.com/questions/276950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3216/"
] | I want to track how many views a post has had for every day. So that I can get all kind of interesting trends out of it later. For example most visit last three days.
But what is the best way to store this data? Most tutorials on google search is about just storing the total views. Not per day. If I would store the da... | Put simply, **you don't**, and you shouldn't
The Problems
------------
### Race Conditions Make the Data Super Unreliable
Updating post meta, options, terms, etc is not an atomic operation. You need to fetch the view count, add 1 to it, then send it back to the database.
During that process, another page load is oc... |
276,960 | <p>I think I've been looking at too much code and have confused myself while trying to get a better understanding of forms in WordPress with AJAX. I set out this week to learn how to create a form for a page and submit it through AJAX. </p>
<p>The page is a template and the action I've looked into two solutions of t... | [
{
"answer_id": 276967,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<pre><code><form action=\"<?php echo get_template_directory_uri() . \"/validation.php\"; ?>\" id=\"cont... | 2017/08/15 | [
"https://wordpress.stackexchange.com/questions/276960",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25271/"
] | I think I've been looking at too much code and have confused myself while trying to get a better understanding of forms in WordPress with AJAX. I set out this week to learn how to create a form for a page and submit it through AJAX.
The page is a template and the action I've looked into two solutions of the handling.... | ```
<form action="<?php echo get_template_directory_uri() . "/validation.php"; ?>" id="contactForm">
```
So I'll outline the basic fundamentals, so you have a framework to move forwards with
Fixing Admin AJAX
-----------------
So I'll cover this very briefly as it's not the crux of my answer, but would be useful:
... |
276,966 | <p>I am trying to add custom add to cart link. I am getting product details from product slug. And trying to add, ADD to cart link by product id but no luck so far. Any help will be highly appreciated. </p>
<pre><code>if(!empty($tracks[ $k ][ 'buy_link_a' ])){
list($hash, $slug) = explode("product/",$trac... | [
{
"answer_id": 276967,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<pre><code><form action=\"<?php echo get_template_directory_uri() . \"/validation.php\"; ?>\" id=\"cont... | 2017/08/15 | [
"https://wordpress.stackexchange.com/questions/276966",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125883/"
] | I am trying to add custom add to cart link. I am getting product details from product slug. And trying to add, ADD to cart link by product id but no luck so far. Any help will be highly appreciated.
```
if(!empty($tracks[ $k ][ 'buy_link_a' ])){
list($hash, $slug) = explode("product/",$tracks[ $k ][ 'buy_... | ```
<form action="<?php echo get_template_directory_uri() . "/validation.php"; ?>" id="contactForm">
```
So I'll outline the basic fundamentals, so you have a framework to move forwards with
Fixing Admin AJAX
-----------------
So I'll cover this very briefly as it's not the crux of my answer, but would be useful:
... |
276,972 | <p>When I use <code>get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL );</code> wordpress automatically outputs the <code>srcset</code> data like these:</p>
<pre><code><img
width="1000"
height="625"
src="https://x.cloudfront.net/wp-content/uploads/2017/08/photo.jpg"
class="attachment-entry... | [
{
"answer_id": 276975,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 4,
"selected": true,
"text": "<p>I think <a href=\"https://developer.wordpress.org/reference/functions/wp_get_attachment_image_srcset/\" rel=... | 2017/08/15 | [
"https://wordpress.stackexchange.com/questions/276972",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | When I use `get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL );` wordpress automatically outputs the `srcset` data like these:
```
<img
width="1000"
height="625"
src="https://x.cloudfront.net/wp-content/uploads/2017/08/photo.jpg"
class="attachment-entry-fullwidth size-entry-fullwidth wp-post-i... | I think [`wp_get_attachment_srcset()`](https://developer.wordpress.org/reference/functions/wp_get_attachment_image_srcset/) is what you are looking for.
```
$srcset = wp_get_attachment_image_srcset( $image['id'], array( 100, 100 ) );
```
Now you can escape the HTML and use it in your code.
```
<img src="PATH HERE" ... |
276,980 | <p>I have a blog and I make posts daily, and I would like for users to be able to access posts one day before they are published. How can I do that?</p>
| [
{
"answer_id": 276981,
"author": "Swati",
"author_id": 123547,
"author_profile": "https://wordpress.stackexchange.com/users/123547",
"pm_score": 0,
"selected": false,
"text": "<p>You can just add a post in admin and give post link to user, Like suppose you want to publish post tomorrow t... | 2017/08/15 | [
"https://wordpress.stackexchange.com/questions/276980",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123649/"
] | I have a blog and I make posts daily, and I would like for users to be able to access posts one day before they are published. How can I do that? | You can use this in a template file:
```
$tomr = getdate(time()+86400); //utc=gmt time in seconds, add 24 hours = 86400 seconds
$args = array(
'post_status' => 'future',
'date_query' => array(
array(
'year' => $tomr['year'],
'month' => $tomr['mon'],
'day' => $tomr['mday'],
... |
276,987 | <p>I have a custom meta box in my page admin with 5 checkboxes. If one or more of the checkboxes are checked, I want certain content to display on the page. </p>
<p>I have the meta box checkboxes displaying and saving properly in the admin, but what do I need to put in my template file to show content based on whether... | [
{
"answer_id": 276991,
"author": "inarilo",
"author_id": 17923,
"author_profile": "https://wordpress.stackexchange.com/users/17923",
"pm_score": 2,
"selected": true,
"text": "<p>Use <a href=\"https://developer.wordpress.org/reference/functions/get_post_meta/\" rel=\"nofollow noreferrer\"... | 2017/08/15 | [
"https://wordpress.stackexchange.com/questions/276987",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125898/"
] | I have a custom meta box in my page admin with 5 checkboxes. If one or more of the checkboxes are checked, I want certain content to display on the page.
I have the meta box checkboxes displaying and saving properly in the admin, but what do I need to put in my template file to show content based on whether or not th... | Use [get\_post\_meta](https://developer.wordpress.org/reference/functions/get_post_meta/) to fetch each value and compare against 'yes'. E.g.
```
if(get_post_meta($post->ID, 'ui-ux-design', true) == 'yes') {
//show relevant content
}
``` |
277,008 | <p>please I need help with this code</p>
<pre><code>add_action( 'the_title', 'adddd', 10, 2 );
function adddd( $title, $post_id )
{
if( has_category( 30, $post_id ) ) {
$title = 'Prefix ' . $title;
}
return $title;
}
</code></pre>
<p>Changing the post title of a specific category.</p>
<p>The co... | [
{
"answer_id": 277010,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 1,
"selected": false,
"text": "<p>You should use filter not action:</p>\n\n<pre><code>function adddd( $title, $post_id ) {\n ... | 2017/08/15 | [
"https://wordpress.stackexchange.com/questions/277008",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125912/"
] | please I need help with this code
```
add_action( 'the_title', 'adddd', 10, 2 );
function adddd( $title, $post_id )
{
if( has_category( 30, $post_id ) ) {
$title = 'Prefix ' . $title;
}
return $title;
}
```
Changing the post title of a specific category.
The code above is working fine displayi... | You should use filter not action:
```
function adddd( $title, $post_id ) {
if( in_category( 30 ) ) {
$title = 'Prefix - ' . $title . ' - xxx';
}
return $title;
}
add_filter( 'the_title', 'adddd', 10, 2 );
``` |
277,012 | <p>How can I make all the css in the <code>twentyseventeen</code> theme appear inline? I already tried putting the following in header.php:</p>
<pre><code><style>
<?php include("/wp-content/themes/twentyseventeen/style.css");?>
</style>
</code></pre>
<p>and it did not work. </p>
| [
{
"answer_id": 277019,
"author": "Berat Çakır",
"author_id": 125911,
"author_profile": "https://wordpress.stackexchange.com/users/125911",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>wp_register_style()</code></p>\n\n<pre><code>// Include stylesheets\nfunction stylename() {\n... | 2017/08/16 | [
"https://wordpress.stackexchange.com/questions/277012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123649/"
] | How can I make all the css in the `twentyseventeen` theme appear inline? I already tried putting the following in header.php:
```
<style>
<?php include("/wp-content/themes/twentyseventeen/style.css");?>
</style>
```
and it did not work. | For some reason, taking out the beginning `/` solved my issue:
```
<style>
<?php include("wp-content/themes/twentyseventeen/style.css");?>
</style>
```
After doing this, I removed it because I realized how much slower it made the page load. |
277,027 | <p>I'm not sure why but I tried to place Google Fonts at the bottom of the page (in the Javascript section) but it doesn't want to load the font.</p>
<p>What should I be looking for that might be preventing that?</p>
<p>My logic is that I need so speed up my site and placing the fonts at the bottom of the page I am ... | [
{
"answer_id": 277019,
"author": "Berat Çakır",
"author_id": 125911,
"author_profile": "https://wordpress.stackexchange.com/users/125911",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>wp_register_style()</code></p>\n\n<pre><code>// Include stylesheets\nfunction stylename() {\n... | 2017/08/16 | [
"https://wordpress.stackexchange.com/questions/277027",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | I'm not sure why but I tried to place Google Fonts at the bottom of the page (in the Javascript section) but it doesn't want to load the font.
What should I be looking for that might be preventing that?
My logic is that I need so speed up my site and placing the fonts at the bottom of the page I am sure will be bette... | For some reason, taking out the beginning `/` solved my issue:
```
<style>
<?php include("wp-content/themes/twentyseventeen/style.css");?>
</style>
```
After doing this, I removed it because I realized how much slower it made the page load. |
277,035 | <p>I recognized that site is not responsive and media.css file is not working, i inspected with dev tools what kind of styles are included in header and i found that there is min version<code>/css/media.min.css?ver=4.8.1</code>, but i include media.css without min, What can be the problem that media.css is not working?... | [
{
"answer_id": 277019,
"author": "Berat Çakır",
"author_id": 125911,
"author_profile": "https://wordpress.stackexchange.com/users/125911",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>wp_register_style()</code></p>\n\n<pre><code>// Include stylesheets\nfunction stylename() {\n... | 2017/08/16 | [
"https://wordpress.stackexchange.com/questions/277035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124458/"
] | I recognized that site is not responsive and media.css file is not working, i inspected with dev tools what kind of styles are included in header and i found that there is min version`/css/media.min.css?ver=4.8.1`, but i include media.css without min, What can be the problem that media.css is not working?
This is how ... | For some reason, taking out the beginning `/` solved my issue:
```
<style>
<?php include("wp-content/themes/twentyseventeen/style.css");?>
</style>
```
After doing this, I removed it because I realized how much slower it made the page load. |
277,092 | <p>I'm trying to insert a <code>wp_editor()</code> into a page on the front-end with AJAX. The code I have right now inserts the wp_editor elements and the needed JavaScript and CSS files, but none of the settings I used initially in <code>wp_editor()</code> are used when creating this TinyMCE element.</p>
<p><strong>... | [
{
"answer_id": 277214,
"author": "Swen",
"author_id": 22588,
"author_profile": "https://wordpress.stackexchange.com/users/22588",
"pm_score": 4,
"selected": true,
"text": "<p>So, after doing some more digging, I answered my own question by \"connecting the dots\", so to speak. There's a ... | 2017/08/16 | [
"https://wordpress.stackexchange.com/questions/277092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22588/"
] | I'm trying to insert a `wp_editor()` into a page on the front-end with AJAX. The code I have right now inserts the wp\_editor elements and the needed JavaScript and CSS files, but none of the settings I used initially in `wp_editor()` are used when creating this TinyMCE element.
**How do I pass the `$settings` set in ... | So, after doing some more digging, I answered my own question by "connecting the dots", so to speak. There's a lot of bits and pieces of info on this topic on StackOverflow and StackExchange, but none of them really answered my question.
So here is the full working code to loading a `wp_editor` instance with AJAX on t... |
277,098 | <p>I have the following I'm trying to enqueue in <code>functions.php</code></p>
<pre><code>wp_enqueue_script( 'param-example', 'https://domain.com/example?f=j&s=w&c=t', array(), null );
</code></pre>
<p>Except WordPress is escaping the ampersands in the HTML which is breaking the script.</p>
<p>How can I pre... | [
{
"answer_id": 277214,
"author": "Swen",
"author_id": 22588,
"author_profile": "https://wordpress.stackexchange.com/users/22588",
"pm_score": 4,
"selected": true,
"text": "<p>So, after doing some more digging, I answered my own question by \"connecting the dots\", so to speak. There's a ... | 2017/08/16 | [
"https://wordpress.stackexchange.com/questions/277098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125976/"
] | I have the following I'm trying to enqueue in `functions.php`
```
wp_enqueue_script( 'param-example', 'https://domain.com/example?f=j&s=w&c=t', array(), null );
```
Except WordPress is escaping the ampersands in the HTML which is breaking the script.
How can I prevent WordPress from escaping the URL in `wp_enqueue_... | So, after doing some more digging, I answered my own question by "connecting the dots", so to speak. There's a lot of bits and pieces of info on this topic on StackOverflow and StackExchange, but none of them really answered my question.
So here is the full working code to loading a `wp_editor` instance with AJAX on t... |
277,133 | <p>I'm trying to add the category to the post-meta.php file so the blog page will not only show the author and date, but also the category for each post. However, I can't seem to find any correct way to do so. The current code is the following:</p>
<pre><code><span class="post-meta">
<?php
$author = "<a hr... | [
{
"answer_id": 277137,
"author": "David Lee",
"author_id": 111965,
"author_profile": "https://wordpress.stackexchange.com/users/111965",
"pm_score": 1,
"selected": false,
"text": "<p>you can use <code>get_the_category_list()</code> it will show a list of the categories of the post, you c... | 2017/08/17 | [
"https://wordpress.stackexchange.com/questions/277133",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125997/"
] | I'm trying to add the category to the post-meta.php file so the blog page will not only show the author and date, but also the category for each post. However, I can't seem to find any correct way to do so. The current code is the following:
```
<span class="post-meta">
<?php
$author = "<a href='" . esc_url( get_autho... | you can use `get_the_category_list()` it will show a list of the categories of the post, you can also use `get_the_category()` it will return an array, you can iterate it to format it, you can find examples [here](https://developer.wordpress.org/reference/functions/get_the_category/). |
277,179 | <p>I've created two taxonomies:</p>
<ul>
<li>Make</li>
<li>Model</li>
</ul>
<p>This is for a CPT Vehicles. It goes without saying, Make would be your make (Honda / Toyota / Ford / etc) and then one would select the Model based on the Make.</p>
<p>How do I setup the relationship between Make and Model? Or have I gone... | [
{
"answer_id": 277180,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": true,
"text": "<p>Taxonomies are not child of each other unlike terms, which can be. Take a look at this flowchart:</p>\n\n<p>... | 2017/08/17 | [
"https://wordpress.stackexchange.com/questions/277179",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77729/"
] | I've created two taxonomies:
* Make
* Model
This is for a CPT Vehicles. It goes without saying, Make would be your make (Honda / Toyota / Ford / etc) and then one would select the Model based on the Make.
How do I setup the relationship between Make and Model? Or have I gone about this all wrong and it should in fac... | Taxonomies are not child of each other unlike terms, which can be. Take a look at this flowchart:
[](https://i.stack.imgur.com/dYJob.png)
Model is a child of Make, and should not be registered as a new taxonomy. What you are trying to do, is something like ... |
277,182 | <p>I am developing a plugin which uses options API.</p>
<p>I defined a class that uses a function to sanitize the inputs, but when I submit the options form, It displays errors and info twice.</p>
<p>And also I didn't succeed at displaying the error messages.</p>
<p>What is the proper way to display the successful a... | [
{
"answer_id": 277180,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": true,
"text": "<p>Taxonomies are not child of each other unlike terms, which can be. Take a look at this flowchart:</p>\n\n<p>... | 2017/08/17 | [
"https://wordpress.stackexchange.com/questions/277182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114465/"
] | I am developing a plugin which uses options API.
I defined a class that uses a function to sanitize the inputs, but when I submit the options form, It displays errors and info twice.
And also I didn't succeed at displaying the error messages.
What is the proper way to display the successful and error messages on val... | Taxonomies are not child of each other unlike terms, which can be. Take a look at this flowchart:
[](https://i.stack.imgur.com/dYJob.png)
Model is a child of Make, and should not be registered as a new taxonomy. What you are trying to do, is something like ... |
277,197 | <p>With WP.SE's help I've learned how to send data from a form to WP_REST but now I'm having an issue with returning a custom error. I can successfully pass information to the <code>WP_REST_Response</code> and I've added a check in <code>WP_REST_Response</code> and want it to return the error message back to the AJAX ... | [
{
"answer_id": 277200,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": true,
"text": "<p>An Ajax call can be sent to anywhere. It can be a server running a PHP, a virtual local route that is simula... | 2017/08/17 | [
"https://wordpress.stackexchange.com/questions/277197",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25271/"
] | With WP.SE's help I've learned how to send data from a form to WP\_REST but now I'm having an issue with returning a custom error. I can successfully pass information to the `WP_REST_Response` and I've added a check in `WP_REST_Response` and want it to return the error message back to the AJAX error function but I'm ha... | An Ajax call can be sent to anywhere. It can be a server running a PHP, a virtual local route that is simulated using C#, or anything else. So, Ajax does not care what the response is, since it can't understand it.
When you are sending *any* data back from your server, as long as the status is 200 ( or anything but an... |
277,234 | <p>I know this is going to be a little strange because it's seemingly counter-intuitive. How do I add code to my WP multisite without adding a new plugin, and keeping it out of functions.php?</p>
<p>Purpose:
I run a WP multisite instance that uses some custom code for sending emails using a self-signed certificate. I... | [
{
"answer_id": 277200,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": true,
"text": "<p>An Ajax call can be sent to anywhere. It can be a server running a PHP, a virtual local route that is simula... | 2017/08/17 | [
"https://wordpress.stackexchange.com/questions/277234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126052/"
] | I know this is going to be a little strange because it's seemingly counter-intuitive. How do I add code to my WP multisite without adding a new plugin, and keeping it out of functions.php?
Purpose:
I run a WP multisite instance that uses some custom code for sending emails using a self-signed certificate. I don't want... | An Ajax call can be sent to anywhere. It can be a server running a PHP, a virtual local route that is simulated using C#, or anything else. So, Ajax does not care what the response is, since it can't understand it.
When you are sending *any* data back from your server, as long as the status is 200 ( or anything but an... |
277,263 | <p>I've been trying to achieve this for a bit now, and having no success. I have a custom post type "Contributor" where I've disabled the default title field, and I'm trying to figure out how to set a custom title based on four values from Advanced Custom Fields:</p>
<ul>
<li>a "Corporate?" checkbox;</li>
<li>a Corpor... | [
{
"answer_id": 277297,
"author": "Dylan",
"author_id": 41351,
"author_profile": "https://wordpress.stackexchange.com/users/41351",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>acf/update_value</code> filter won't work as it's meant for modifying the acf value and not the post ... | 2017/08/17 | [
"https://wordpress.stackexchange.com/questions/277263",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57588/"
] | I've been trying to achieve this for a bit now, and having no success. I have a custom post type "Contributor" where I've disabled the default title field, and I'm trying to figure out how to set a custom title based on four values from Advanced Custom Fields:
* a "Corporate?" checkbox;
* a Corporate Name text field (... | The `acf/update_value` filter won't work as it's meant for modifying the acf value and not the post it's associated with. Try using the [acf/save\_post](https://www.advancedcustomfields.com/resources/acf-save_post/) action instead. Here's a simplified example of how I'd normally set the post title from first and last n... |
277,266 | <p>I know i'll get bombarded for this question but the truth is I researched and found nothing.</p>
<p>I'm not a WP expert or anything, i just found my ways to design WP themes. But there is something i never got straight. </p>
<p><strong><em>WHY IN HECK SHORT-CODES DON'T WORK FOR ME.</em></strong></p>
<p>When i mea... | [
{
"answer_id": 277271,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 1,
"selected": false,
"text": "<p>Take a look at the syntax of do_shortcode (here: <a href=\"https://developer.wordpress.org/reference/f... | 2017/08/18 | [
"https://wordpress.stackexchange.com/questions/277266",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124731/"
] | I know i'll get bombarded for this question but the truth is I researched and found nothing.
I'm not a WP expert or anything, i just found my ways to design WP themes. But there is something i never got straight.
***WHY IN HECK SHORT-CODES DON'T WORK FOR ME.***
When i mean shortcodes i mean the ones provided by a p... | It looks like theme issue. Switch to default WordPress theme and check it. I have tested it on WordPress Twenty Seventeen theme.
For testing:
1) Add below code in theme `functions.php`
```
// Sample shortcode [testme]
function testme_cb( $atts ) {
return 'Working? Maybe.';
}
add_shortcode( 'testme', 'testme_cb' ... |
277,343 | <p>I have a fresh WP install and for purposes of keeping things simple I currently just have a simple action as follows in my <code>functions.php</code>:</p>
<pre><code>function getFruits() {
return json_encode( ['fruits' => ['apples', 'pears']]);
}
function my_enqueue() {
wp_enqueue_script( 'ajax-scr... | [
{
"answer_id": 277346,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 3,
"selected": true,
"text": "<p>WordPress AJAX uses actions to connect your jQuery <code>action</code> with a traditional WordPress action. ... | 2017/08/18 | [
"https://wordpress.stackexchange.com/questions/277343",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75012/"
] | I have a fresh WP install and for purposes of keeping things simple I currently just have a simple action as follows in my `functions.php`:
```
function getFruits() {
return json_encode( ['fruits' => ['apples', 'pears']]);
}
function my_enqueue() {
wp_enqueue_script( 'ajax-script', get_template_directory... | WordPress AJAX uses actions to connect your jQuery `action` with a traditional WordPress action. Take a look at the [example WordPress provides in their docs](https://codex.wordpress.org/AJAX_in_Plugins). There's 2 hooks:
```
add_action( "wp_ajax_{$jquery_action_string}", "callback_function_name" );
```
The above wi... |
277,349 | <p>In the Velux theme <code>functions.php</code> there is this:</p>
<pre><code>if ( is_front_page() && is_active_sidebar( 'hero' ) )
</code></pre>
<p>Which apparently means the Hero widget only functions on the home page. I used that widget to add custom HTML that needs to be in the header on all pages. </p>... | [
{
"answer_id": 277346,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 3,
"selected": true,
"text": "<p>WordPress AJAX uses actions to connect your jQuery <code>action</code> with a traditional WordPress action. ... | 2017/08/18 | [
"https://wordpress.stackexchange.com/questions/277349",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121627/"
] | In the Velux theme `functions.php` there is this:
```
if ( is_front_page() && is_active_sidebar( 'hero' ) )
```
Which apparently means the Hero widget only functions on the home page. I used that widget to add custom HTML that needs to be in the header on all pages.
I tried the following mod to `functions.php` an... | WordPress AJAX uses actions to connect your jQuery `action` with a traditional WordPress action. Take a look at the [example WordPress provides in their docs](https://codex.wordpress.org/AJAX_in_Plugins). There's 2 hooks:
```
add_action( "wp_ajax_{$jquery_action_string}", "callback_function_name" );
```
The above wi... |
277,418 | <p>I'm faced with a situation where I need to fetch meta_value of a specific meta_key from ALL the posts available in WordPress database. Obviously, this results into large number of database queries. Here's how it looks : </p>
<pre><code>foreach ( $quiz_takers as $competitor ) {
$quizzes_user_has_taken = get_post... | [
{
"answer_id": 277419,
"author": "zedejose",
"author_id": 34514,
"author_profile": "https://wordpress.stackexchange.com/users/34514",
"pm_score": 0,
"selected": false,
"text": "<p>Not tested, but a meta-only <code>WP_Query</code> should do the trick, no?</p>\n\n<p>As in:</p>\n\n<pre><cod... | 2017/08/19 | [
"https://wordpress.stackexchange.com/questions/277418",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21100/"
] | I'm faced with a situation where I need to fetch meta\_value of a specific meta\_key from ALL the posts available in WordPress database. Obviously, this results into large number of database queries. Here's how it looks :
```
foreach ( $quiz_takers as $competitor ) {
$quizzes_user_has_taken = get_post_meta( $comp... | Querying wp\_postmeta would be the way to go:
```
global $wpdb;
$results = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = 'quiz_results'");
```
That will get you an array of values for quiz\_results across all posts. |
277,465 | <p>Looking for a code which could potentially help me get the list of gallery images present in product in woocommerce.</p>
<p>Need them so i can use them in a custom single page design for woocommerce product page.</p>
| [
{
"answer_id": 277467,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": false,
"text": "<p>The <code>get_gallery_image_ids()</code> method on the product will return an array of image IDs.</p>\n... | 2017/08/20 | [
"https://wordpress.stackexchange.com/questions/277465",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125791/"
] | Looking for a code which could potentially help me get the list of gallery images present in product in woocommerce.
Need them so i can use them in a custom single page design for woocommerce product page. | ```
<?php
$product_id = '14';
$product = new WC_product($product_id);
$attachment_ids = $product->get_gallery_image_ids();
foreach( $attachment_ids as $attachment_id )
{
// Display the image URL
echo $Original_image_url = wp_get_attachment_url( $attachment_id );
// Display Image instead of URL
... |
277,474 | <p>I am busy moving all sites to HTTPS (using ZeroSSL/Letsencrypt) on a Hetzner.de managed hosting server. I have this working for a single site but my <strong>multisite installation</strong> is giving me issues.</p>
<p>My main site (top-node.com) works without an issue (frontend and backend), however, I cannot log in... | [
{
"answer_id": 313535,
"author": "Ryan M",
"author_id": 71096,
"author_profile": "https://wordpress.stackexchange.com/users/71096",
"pm_score": 1,
"selected": false,
"text": "<p>For me, it was removing <code>http://</code> from DOMAIN_CURRENT_SITE in my wp-config.php.</p>\n\n<p>before\n<... | 2017/08/20 | [
"https://wordpress.stackexchange.com/questions/277474",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/117438/"
] | I am busy moving all sites to HTTPS (using ZeroSSL/Letsencrypt) on a Hetzner.de managed hosting server. I have this working for a single site but my **multisite installation** is giving me issues.
My main site (top-node.com) works without an issue (frontend and backend), however, I cannot log into the **network admin*... | For me, it was removing `http://` from DOMAIN\_CURRENT\_SITE in my wp-config.php.
before
`define( 'DOMAIN_CURRENT_SITE', 'http://example.com' );`
after
`define( 'DOMAIN_CURRENT_SITE', 'example.com' );` |
277,515 | <p>By default, when you click on the author in a post, WP directs you to:</p>
<blockquote>
<p>example.com/author/sample-user/</p>
</blockquote>
<p>However, for BuddyPress users, it makes much more sense that it directs the user to the author's BuddyPress profile page: </p>
<blockquote>
<p>example.com/members/sam... | [
{
"answer_id": 277534,
"author": "Ashley Liu",
"author_id": 126220,
"author_profile": "https://wordpress.stackexchange.com/users/126220",
"pm_score": 1,
"selected": false,
"text": "<p>The following codes worked. I added to my child theme's functions.php</p>\n\n<pre><code> add_filter( 'a... | 2017/08/20 | [
"https://wordpress.stackexchange.com/questions/277515",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126220/"
] | By default, when you click on the author in a post, WP directs you to:
>
> example.com/author/sample-user/
>
>
>
However, for BuddyPress users, it makes much more sense that it directs the user to the author's BuddyPress profile page:
>
> example.com/members/sample-user/
>
>
>
Does anyone know how to do th... | The following codes worked. I added to my child theme's functions.php
```
add_filter( 'author_link', 'change_author_link', 10, 1 );
function change_author_link($link) {
$username=get_the_author_meta('user_nicename');
$link = 'http://example.com/members/' . $username;
return $link;
}
``` |
277,525 | <p>I just imported a bunch of posts to my WordPress site, from Tumblr, using the </p>
<pre><code>Tools -> Import
</code></pre>
<p>menu. All my content is pulled into WordPress. Yay!</p>
<p>Next -- I want to drop all the posts from this Tumblr site into a new category. There doesn't appear to be a way to do thi... | [
{
"answer_id": 277534,
"author": "Ashley Liu",
"author_id": 126220,
"author_profile": "https://wordpress.stackexchange.com/users/126220",
"pm_score": 1,
"selected": false,
"text": "<p>The following codes worked. I added to my child theme's functions.php</p>\n\n<pre><code> add_filter( 'a... | 2017/08/21 | [
"https://wordpress.stackexchange.com/questions/277525",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33566/"
] | I just imported a bunch of posts to my WordPress site, from Tumblr, using the
```
Tools -> Import
```
menu. All my content is pulled into WordPress. Yay!
Next -- I want to drop all the posts from this Tumblr site into a new category. There doesn't appear to be a way to do this via the UI that isn't incredibly tedi... | The following codes worked. I added to my child theme's functions.php
```
add_filter( 'author_link', 'change_author_link', 10, 1 );
function change_author_link($link) {
$username=get_the_author_meta('user_nicename');
$link = 'http://example.com/members/' . $username;
return $link;
}
``` |
277,539 | <pre><code><?php if (!is_user_logged_in()) { ?>
<p class="text-center">
برای ارسال نظر باید <a href="https://www. .com/login?redirect_to=<?php echo the_permalink();?>"><i class="fa fa-fw fa-sign-in"></i> وارد حساب کاربریتان شوید</a> یا <a href="/register"><i class="fa ... | [
{
"answer_id": 277568,
"author": "Shahzaib Khan",
"author_id": 125791,
"author_profile": "https://wordpress.stackexchange.com/users/125791",
"pm_score": 0,
"selected": false,
"text": "<p>If it is for the post, then check whether in the post settings have you allowed the comments should b... | 2017/08/21 | [
"https://wordpress.stackexchange.com/questions/277539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125908/"
] | ```
<?php if (!is_user_logged_in()) { ?>
<p class="text-center">
برای ارسال نظر باید <a href="https://www. .com/login?redirect_to=<?php echo the_permalink();?>"><i class="fa fa-fw fa-sign-in"></i> وارد حساب کاربریتان شوید</a> یا <a href="/register"><i class="fa fa-fw fa-user-plus"></i> عضو سایت شوید</a>
</p>
<?php } ?>... | If it is for the post, then check whether in the post settings have you allowed the comments should be displayed?
Also do check the settings at: /wp-admin/options-discussion.php |
277,546 | <p>before happening this error i go to the general setting and on the place of HTTP i did HTTPS by mistake. but now i am unable to login into my <code>wp-admin</code> panel</p>
<p>Whenever i type <code>www.mydomain.com/wp-admin/</code> the privacy error comes:</p>
<blockquote>
<p>Your connection is not private</p>... | [
{
"answer_id": 277548,
"author": "Aniruddha Gawade",
"author_id": 101818,
"author_profile": "https://wordpress.stackexchange.com/users/101818",
"pm_score": 1,
"selected": false,
"text": "<p>You can fix this by changes <code>site_url</code> and <code>home_url</code> in your database.</p>\... | 2017/08/21 | [
"https://wordpress.stackexchange.com/questions/277546",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126236/"
] | before happening this error i go to the general setting and on the place of HTTP i did HTTPS by mistake. but now i am unable to login into my `wp-admin` panel
Whenever i type `www.mydomain.com/wp-admin/` the privacy error comes:
>
> Your connection is not private
>
>
> Attackers might be trying to steal your infor... | You can fix this by changes `site_url` and `home_url` in your database.
If you have access to your database(phpmyadmin) go to `options` table and change `site_url` and `home_url` from HTTPS to HTTP.
You can also change it through `wp-config` file.
```
define('WP_HOME','http://www.example.com');
define('WP_SITEURL',... |