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 |
|---|---|---|---|---|---|---|
279,399 | <p>I am using a WCK plugin to Wordpress. In the php code to call the image source, I used <code>wp_get_attachment_image_src()</code> but it only gets the url of the image. I want to include the alt value of it. Please help. Thanks.</p>
<p>Below is my code.</p>
<pre><code><div class="authortest-cont">
... | [
{
"answer_id": 279400,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<p><code>wp_get_attachment_image()</code> will generate a full image tag, including the alt attribute. If ... | 2017/09/08 | [
"https://wordpress.stackexchange.com/questions/279399",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125514/"
] | I am using a WCK plugin to Wordpress. In the php code to call the image source, I used `wp_get_attachment_image_src()` but it only gets the url of the image. I want to include the alt value of it. Please help. Thanks.
Below is my code.
```
<div class="authortest-cont">
<h2><span>W</span>hat Our <small... | `wp_get_attachment_image()` will generate a full image tag, including the alt attribute. If you need to put a custom class or attribute on the image (one reason you might only want the src), you can still do that with that function by using the 4th argument:
```
echo wp_get_attachment_image( $attachment_id, 'large', f... |
279,429 | <p>where the default category to is titled 'Games'.</p>
<p>In the functions.php I have added this code to give each page a second category.</p>
<pre><code><?php
add_action('init', 'build_taxonomies', 0);
function build_taxonomies() {
register_taxonomy('players_team', 'player', array(
'hierarchical' =&... | [
{
"answer_id": 279430,
"author": "Sören Wrede",
"author_id": 68682,
"author_profile": "https://wordpress.stackexchange.com/users/68682",
"pm_score": 1,
"selected": true,
"text": "<p>For every taxonomy you have to choose a unique name, which is used in the database. so so your new e.g. <c... | 2017/09/08 | [
"https://wordpress.stackexchange.com/questions/279429",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127476/"
] | where the default category to is titled 'Games'.
In the functions.php I have added this code to give each page a second category.
```
<?php
add_action('init', 'build_taxonomies', 0);
function build_taxonomies() {
register_taxonomy('players_team', 'player', array(
'hierarchical' => true,
'label' =... | For every taxonomy you have to choose a unique name, which is used in the database. so so your new e.g. `players_region`.
```
<?php
add_action( 'init', 'build_taxonomies' );
function build_taxonomies() {
register_taxonomy(
'players_team', // Unique name.
'player', // Post type.
array... |
279,448 | <p>I am using the below contact from code in the WordPress by creating shortcode. When i submit the form it shows success message but didn't get any email in inbox or spam. Can anybody please help.</p>
<pre><code>function contactform_func( $atts ) {
$atts = shortcode_atts( array(
'to_email' => '',
'title' =... | [
{
"answer_id": 280923,
"author": "SEO DEVS",
"author_id": 111163,
"author_profile": "https://wordpress.stackexchange.com/users/111163",
"pm_score": 2,
"selected": false,
"text": "<p>The caption is stored in the image data. The only way to achieve what you require is to use multiple copi... | 2017/09/08 | [
"https://wordpress.stackexchange.com/questions/279448",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127490/"
] | I am using the below contact from code in the WordPress by creating shortcode. When i submit the form it shows success message but didn't get any email in inbox or spam. Can anybody please help.
```
function contactform_func( $atts ) {
$atts = shortcode_atts( array(
'to_email' => '',
'title' => 'Contact enquir... | The caption is stored in the image data. The only way to achieve what you require is to use multiple copies of the image and change the image data on each image. To better understand image data go ahead and download an image to your desktop then right click it, go to properties then the details tab. this is where the i... |
279,455 | <p>There seem to be countless custom query pagination questions on here, so glad to know I'm not the only one struggling with it. Have tried following the answers in those questions but so far no luck.</p>
<p>I have a custom post type, say Galleries. Each post has a title, and an Advanced Custom Field Gallery field th... | [
{
"answer_id": 280923,
"author": "SEO DEVS",
"author_id": 111163,
"author_profile": "https://wordpress.stackexchange.com/users/111163",
"pm_score": 2,
"selected": false,
"text": "<p>The caption is stored in the image data. The only way to achieve what you require is to use multiple copi... | 2017/09/08 | [
"https://wordpress.stackexchange.com/questions/279455",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5465/"
] | There seem to be countless custom query pagination questions on here, so glad to know I'm not the only one struggling with it. Have tried following the answers in those questions but so far no luck.
I have a custom post type, say Galleries. Each post has a title, and an Advanced Custom Field Gallery field that include... | The caption is stored in the image data. The only way to achieve what you require is to use multiple copies of the image and change the image data on each image. To better understand image data go ahead and download an image to your desktop then right click it, go to properties then the details tab. this is where the i... |
279,493 | <p>So I am working on a website. I'd like it so that on the interior pages of the site, there is a different title and subtitle representing that page. Unfortunately, the theme I am working with doesn't originally have the heading in the header but in the content area. </p>
<p><strong>The solution I want:</strong> I w... | [
{
"answer_id": 280923,
"author": "SEO DEVS",
"author_id": 111163,
"author_profile": "https://wordpress.stackexchange.com/users/111163",
"pm_score": 2,
"selected": false,
"text": "<p>The caption is stored in the image data. The only way to achieve what you require is to use multiple copi... | 2017/09/08 | [
"https://wordpress.stackexchange.com/questions/279493",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127514/"
] | So I am working on a website. I'd like it so that on the interior pages of the site, there is a different title and subtitle representing that page. Unfortunately, the theme I am working with doesn't originally have the heading in the header but in the content area.
**The solution I want:** I want to create a global ... | The caption is stored in the image data. The only way to achieve what you require is to use multiple copies of the image and change the image data on each image. To better understand image data go ahead and download an image to your desktop then right click it, go to properties then the details tab. this is where the i... |
279,498 | <p>I've created a custom taxonomy (locations) which is hierarchical, and would like to:
a) display an unordered list that respects the hierarchy
AND
b)customize the display output so that I can specify a custom url</p>
<p>Here's the code I'm using, including the two different ways I'm outputting. </p>
<pre><code><... | [
{
"answer_id": 279499,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 0,
"selected": false,
"text": "<p>I may be mis-understanding but you don't need wp_list_categories for this. (also your coding is missing some ... | 2017/09/08 | [
"https://wordpress.stackexchange.com/questions/279498",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127524/"
] | I've created a custom taxonomy (locations) which is hierarchical, and would like to:
a) display an unordered list that respects the hierarchy
AND
b)customize the display output so that I can specify a custom url
Here's the code I'm using, including the two different ways I'm outputting.
```
<?php
$args = array(
'ta... | Solved it with the following Custom Walker:
```
class CustomWalker extends Walker_Category {
function start_el(&$output, $item, $depth=0, $args=array()) {
$output .= "\n<li><a href=\"http://website.com/?ls=&location=" . $item->slug . "\">".esc_attr($item->name);
}
function end_el(&$output, $item, $depth=0, $args=... |
279,533 | <p>I am trying to create a simple form on one of my wordpress pages.
The code used is as basic as it can be, namely the following:</p>
<pre><code><form action="" method="GET">
<select>
<option value="test" >test</option>
</select>
<input type="s... | [
{
"answer_id": 279564,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 1,
"selected": false,
"text": "<p>Try</p>\n\n<pre><code><form action=\"#\" method=\"GET\">\n</code></pre>\n\n<p>(Although I prefer... | 2017/09/09 | [
"https://wordpress.stackexchange.com/questions/279533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am trying to create a simple form on one of my wordpress pages.
The code used is as basic as it can be, namely the following:
```
<form action="" method="GET">
<select>
<option value="test" >test</option>
</select>
<input type="submit" value="search">
</form>
```
the p... | Alright guys, believe it or not, but the underlying problem had to do with permissions on the root folder!
the aforementioned `<form action="#" method="GET">` didn't work either, so i digged a little deeper, and i found out certain pages couldn't be opened either.
Why this causes every single simple form to be redire... |
279,556 | <p>I installed the "JWT Authentication for WP REST API" plugin for user authentication through an Ionic app. Although authentication was successful, attempting to find a way to register users from the mobile app proved to be a particularly difficult task.</p>
<p>Is there a way to register users from the API given by W... | [
{
"answer_id": 279558,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 0,
"selected": false,
"text": "<p>The JSON API plugin is not needed, as the REST API is part of WordPress core (as of about Version 4.7, if I rec... | 2017/09/09 | [
"https://wordpress.stackexchange.com/questions/279556",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127571/"
] | I installed the "JWT Authentication for WP REST API" plugin for user authentication through an Ionic app. Although authentication was successful, attempting to find a way to register users from the mobile app proved to be a particularly difficult task.
Is there a way to register users from the API given by WordPress? ... | This does not use the API, but it's a script I've used a hundred times over the years, always works. Simply drop it in the root of your install and then access the file directly. Remember to delete the file immediately afterward. I do not remember where I originally obtained this script.
```
<?php
// ADD NEW ADMIN USE... |
279,627 | <p>As for now, my CSS hierarchy goes like this:</p>
<p>Theme > plugins (mainly page builders) > Child theme.</p>
<p>How to load all plugins CSS last in hierarchy?</p>
| [
{
"answer_id": 279644,
"author": "Milan Petrovic",
"author_id": 126702,
"author_profile": "https://wordpress.stackexchange.com/users/126702",
"pm_score": 1,
"selected": false,
"text": "<p>It depends on when you execute the wp_enqueue_scripts action. You need to include priority parameter... | 2017/09/11 | [
"https://wordpress.stackexchange.com/questions/279627",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127625/"
] | As for now, my CSS hierarchy goes like this:
Theme > plugins (mainly page builders) > Child theme.
How to load all plugins CSS last in hierarchy? | You have 3 options:
**Option 1**:
Using dependencies, first of all get the style `handler`, if you have access to the file you can grab it from the `wp_enqueue_style` function, if not, inspect the HTML code and find the `id` the handler its the `id` without the `-css`
[;
$rating = $product->get_average_rating();
```
That'll return the raw number (4.00, 3.50 etc.).
To output the rating HTML for a given product you can use this code:
```
$product = wc_get_product( $product_id ... |
279,683 | <p>I have a page that lists some custom posts and the they are not showing in the correct Alphabetical order. As a test I have also tried listing them in order of there Ids and that does not appear in the correct order either. When it's listed as Ids they appear as if they grouped into 3 groups high numbers in the 4000... | [
{
"answer_id": 279686,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>It would be atypical for server configuration to have a direct impact on posts query, short of SQL explicitly misbe... | 2017/09/11 | [
"https://wordpress.stackexchange.com/questions/279683",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7557/"
] | I have a page that lists some custom posts and the they are not showing in the correct Alphabetical order. As a test I have also tried listing them in order of there Ids and that does not appear in the correct order either. When it's listed as Ids they appear as if they grouped into 3 groups high numbers in the 4000s, ... | It would be atypical for server configuration to have a direct impact on posts query, short of SQL explicitly misbehaving. Which would be quite an edge case.
The much more common case would be some code attaching to query filters for its purposes and not being precise enough to target *just* the queries it needs to. I... |
279,736 | <pre><code>$output = '<p class="one"><small>'.$newsletter_one. '</small></p>'
</code></pre>
<p>Generally, when we write short codes we publish HTML like the above one, and instead of echo use return function.</p>
<p>How should we write this one →</p>
<pre><code><span class="class2" id="cla... | [
{
"answer_id": 279738,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 4,
"selected": true,
"text": "<p>When you want to return a data combined with a string, you can use one of the following methods:</p>\n\n<p>E... | 2017/09/12 | [
"https://wordpress.stackexchange.com/questions/279736",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105791/"
] | ```
$output = '<p class="one"><small>'.$newsletter_one. '</small></p>'
```
Generally, when we write short codes we publish HTML like the above one, and instead of echo use return function.
How should we write this one →
```
<span class="class2" id="class3-<?php echo $random;?>"> </span>
```
Like this →
```
$outp... | When you want to return a data combined with a string, you can use one of the following methods:
Either open and close the string using `'`:
```
return '<span class="class2" id="class3-' . $random . '"> </span>';
```
Or use the double quote:
```
return "<span class='class2' id='class3-{$random}'> </span>";
```
Y... |
279,755 | <p>I would like to display the 'file path' in the conventional position on a page on my WordPress site. Something like this:</p>
<p><a href="https://i.stack.imgur.com/6aIUy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6aIUy.png" alt="example"></a></p>
<p>Does anybody know if this is possible wit... | [
{
"answer_id": 279762,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 1,
"selected": false,
"text": "<p>There are a lot of plugins that offer a breadcrumb, but you can also create your own.</p>\n\n<p>To create a... | 2017/09/12 | [
"https://wordpress.stackexchange.com/questions/279755",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127707/"
] | I would like to display the 'file path' in the conventional position on a page on my WordPress site. Something like this:
[](https://i.stack.imgur.com/6aIUy.png)
Does anybody know if this is possible without manually typing it onto each page (not really feasible)? | There are a lot of plugins that offer a breadcrumb, but you can also create your own.
To create a simple breadcrumb, you'll need 2 functions. One to create a chain of categories, and one to generate the breadcrumb itself.
Create a Chain of Categories
----------------------------
This function will generate a list of... |
279,758 | <p>I create the title of the custom-post-type "produktionsauftrag" automatically. The script in my functions.php works but i cant get the postid at the end of my title. </p>
<p>Filter in my functions.php file:</p>
<pre><code>add_filter('wp_insert_post_data','update_pa_title',99,2);
function update_pa_title($data, $po... | [
{
"answer_id": 279760,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 2,
"selected": false,
"text": "<p>The filter \"wp_insert_post_data\" runs before the data is inserted into the database. When you creat... | 2017/09/12 | [
"https://wordpress.stackexchange.com/questions/279758",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81609/"
] | I create the title of the custom-post-type "produktionsauftrag" automatically. The script in my functions.php works but i cant get the postid at the end of my title.
Filter in my functions.php file:
```
add_filter('wp_insert_post_data','update_pa_title',99,2);
function update_pa_title($data, $postarr) {
global $post... | I found the solution with title\_save\_pre
```
add_filter('title_save_pre','auto_generate_post_title');
function auto_generate_post_title($title) {
global $post;
if (isset($post->ID)) {
if (empty($_POST['post_title']) && 'produktionsauftrag' == get_post_type($post->ID)){
// get the current post ID... |
279,766 | <p>I am new in WordPress so I am building my first theme with theme options I am facing the problem in my theme options pages that I have made in admin. I have two different styles for my theme options in admin area when I enqueue scripts for admin the problem are as follows:</p>
<ol>
<li><p>When I enqueue the scripts... | [
{
"answer_id": 279760,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 2,
"selected": false,
"text": "<p>The filter \"wp_insert_post_data\" runs before the data is inserted into the database. When you creat... | 2017/09/12 | [
"https://wordpress.stackexchange.com/questions/279766",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123366/"
] | I am new in WordPress so I am building my first theme with theme options I am facing the problem in my theme options pages that I have made in admin. I have two different styles for my theme options in admin area when I enqueue scripts for admin the problem are as follows:
1. When I enqueue the scripts the script load... | I found the solution with title\_save\_pre
```
add_filter('title_save_pre','auto_generate_post_title');
function auto_generate_post_title($title) {
global $post;
if (isset($post->ID)) {
if (empty($_POST['post_title']) && 'produktionsauftrag' == get_post_type($post->ID)){
// get the current post ID... |
279,806 | <p>I am trying to get the post id outside the loop in functions.php.but what error i am getting : <code>Notice: Trying to get property of non-object in functions.php on line 549</code></p>
<pre><code>function theme_myeffecto_disable() {
global $wp_query;
$post_id = $wp_query->post->ID;
$showreaction = get... | [
{
"answer_id": 279760,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 2,
"selected": false,
"text": "<p>The filter \"wp_insert_post_data\" runs before the data is inserted into the database. When you creat... | 2017/09/12 | [
"https://wordpress.stackexchange.com/questions/279806",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127737/"
] | I am trying to get the post id outside the loop in functions.php.but what error i am getting : `Notice: Trying to get property of non-object in functions.php on line 549`
```
function theme_myeffecto_disable() {
global $wp_query;
$post_id = $wp_query->post->ID;
$showreaction = get_post_meta( $post_id, 'post_rea... | I found the solution with title\_save\_pre
```
add_filter('title_save_pre','auto_generate_post_title');
function auto_generate_post_title($title) {
global $post;
if (isset($post->ID)) {
if (empty($_POST['post_title']) && 'produktionsauftrag' == get_post_type($post->ID)){
// get the current post ID... |
279,815 | <p>Currently, we are running our WP based website at dedicated OVH web hosting with the highest performance. Due to fact that traffic at our website continuously grows, we are about to migrate to the dedicated solution and here is where my doubts come. </p>
<p>While searching for WP HA tutorials I found 2 main approac... | [
{
"answer_id": 279760,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 2,
"selected": false,
"text": "<p>The filter \"wp_insert_post_data\" runs before the data is inserted into the database. When you creat... | 2017/09/12 | [
"https://wordpress.stackexchange.com/questions/279815",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77480/"
] | Currently, we are running our WP based website at dedicated OVH web hosting with the highest performance. Due to fact that traffic at our website continuously grows, we are about to migrate to the dedicated solution and here is where my doubts come.
While searching for WP HA tutorials I found 2 main approaches - self... | I found the solution with title\_save\_pre
```
add_filter('title_save_pre','auto_generate_post_title');
function auto_generate_post_title($title) {
global $post;
if (isset($post->ID)) {
if (empty($_POST['post_title']) && 'produktionsauftrag' == get_post_type($post->ID)){
// get the current post ID... |
279,821 | <p>Is there any way to add a <code>crossorigin</code> attribute to a custom registered JavaScript?</p>
<pre><code>wp_register_script('foo', 'http://cdn.domain.com/script.min.js', null, '1.2.3');
wp_enqueue_script( 'bar', '/path/to/bar.js', array( 'foo' ), '20170912' );
</code></pre>
| [
{
"answer_id": 279823,
"author": "Milan Petrovic",
"author_id": 126702,
"author_profile": "https://wordpress.stackexchange.com/users/126702",
"pm_score": 0,
"selected": false,
"text": "<p>Using wp_register_script/wp_enqueue_script functions, you can't do that. Maybe open the ticket with ... | 2017/09/12 | [
"https://wordpress.stackexchange.com/questions/279821",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18126/"
] | Is there any way to add a `crossorigin` attribute to a custom registered JavaScript?
```
wp_register_script('foo', 'http://cdn.domain.com/script.min.js', null, '1.2.3');
wp_enqueue_script( 'bar', '/path/to/bar.js', array( 'foo' ), '20170912' );
``` | [`script_loader_tag`](https://developer.wordpress.org/reference/hooks/script_loader_tag/) or `script_loader_src` filters are there to let you tweak the HTML of the script easily so you can add custom attributes:
```
add_filter('script_loader_tag', function($tag, $handle){
switch ( $handle ) {
case 'foo':
... |
279,845 | <p>I run a function to rename draggable/sortable items in a list, and I'd like it if the items could have a wysiwyg editor in them. I saw that some new javascript functions were introduced with 4.8, so I tried them out. Unfortunately, I can't seem to get them to work properly with dynamic elements. Here's the function ... | [
{
"answer_id": 279953,
"author": "Jarocks",
"author_id": 127830,
"author_profile": "https://wordpress.stackexchange.com/users/127830",
"pm_score": 1,
"selected": false,
"text": "<p>I had similar issues with <code>wp.editor.initialize</code>, after a bit of troubleshooting, I found that s... | 2017/09/12 | [
"https://wordpress.stackexchange.com/questions/279845",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127380/"
] | I run a function to rename draggable/sortable items in a list, and I'd like it if the items could have a wysiwyg editor in them. I saw that some new javascript functions were introduced with 4.8, so I tried them out. Unfortunately, I can't seem to get them to work properly with dynamic elements. Here's the function tha... | You can use only `wp_enqueue_editor();` instead of:
```
if ( ! class_exists( '_WP_Editors', false ) ) {
require( ABSPATH . WPINC . '/class-wp-editor.php' );
}
add_action( 'admin_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) );
``` |
279,860 | <p>All the resources I've read online suggest using a different CSS file (i.e. <code>editor-style.css</code>) in order to style the WYSIWYG editor to better resemble what the actual content will look like.</p>
<p>For the purpose of testing I tried to just use the main <code>style.css</code> file that I've been using f... | [
{
"answer_id": 279864,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>The editor doesn't use the every style used by your website's front end. So, you don't need the whole <code... | 2017/09/13 | [
"https://wordpress.stackexchange.com/questions/279860",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123345/"
] | All the resources I've read online suggest using a different CSS file (i.e. `editor-style.css`) in order to style the WYSIWYG editor to better resemble what the actual content will look like.
For the purpose of testing I tried to just use the main `style.css` file that I've been using for the rest of the site and the ... | The simplest answer is: you can use whatever stylesheet you want for the editor. `editor-style.css` is just the default stylesheet loaded if none is passed to `add_editor_style()`.
This will load the specified stylesheet:
```
add_editor_style( 'some-stylsheet.css' );
```
This will load editor-style.css:
```
add_ed... |
279,882 | <p>I am new to WordPress development ,I am using <code>wp_insert_post()</code> to create posts from front end, This function works fine when I have already logged in but I need to implement this without any login . </p>
<p>can you please guide me the exact way how this can be achieved .</p>
<pre><code>$post = array(
... | [
{
"answer_id": 279871,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>.htaccess</code> file is mostly used to create rewrite rules and conditions, which is used by Apa... | 2017/09/13 | [
"https://wordpress.stackexchange.com/questions/279882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127183/"
] | I am new to WordPress development ,I am using `wp_insert_post()` to create posts from front end, This function works fine when I have already logged in but I need to implement this without any login .
can you please guide me the exact way how this can be achieved .
```
$post = array(
'post_title' => "Tshirt-custo... | The `.htaccess` file is not actually required for WordPress to "work". However, it is required if you wish to create a more user-friendly URL structure (ie. anything other than "plain" permalinks, as Jack suggests).
This is also why the default WordPress `.htaccess` file surrounds the directives in an `<IfModule mod_r... |
279,894 | <p>quick newbie question but the answer is nowhere to be found!</p>
<p>I am building my site from the ground up on Wordpress with Genesis and a child theme (Minimum Pro). I am interested in implementing the Bulma CSS Framework for its ease of use. I would like to do this as efficiently as possible in terms of resource... | [
{
"answer_id": 288171,
"author": "RLM",
"author_id": 60779,
"author_profile": "https://wordpress.stackexchange.com/users/60779",
"pm_score": 2,
"selected": false,
"text": "<p>Here is a great <code>Wordpress/Bulma</code> boilerplate theme:</p>\n\n<p><a href=\"https://github.com/teamscops/... | 2017/09/13 | [
"https://wordpress.stackexchange.com/questions/279894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123290/"
] | quick newbie question but the answer is nowhere to be found!
I am building my site from the ground up on Wordpress with Genesis and a child theme (Minimum Pro). I am interested in implementing the Bulma CSS Framework for its ease of use. I would like to do this as efficiently as possible in terms of resources. How can... | [Bulma.io](https://bulma.io/) is likely to conflict with any styling that comes from Genesis (or any other theme). If you understand HTML/CSS, I recommend using bulma without any other themes/frameworks to avoid conflict/bloat. If you rely on any visual page builders, I would avoid CSS frameworks like bulma and just st... |
279,931 | <p>I apologize in advance for my lack of PHP/WP knowledge, and my wordiness in explaining what I'm looking for, but I've been trying to work out a solution for a couple of days now, and I'm just starting to wrap my head around filters and the loop. </p>
<p><strong>Here's what I'd like to accomplish:</strong></p>
<p>A... | [
{
"answer_id": 288171,
"author": "RLM",
"author_id": 60779,
"author_profile": "https://wordpress.stackexchange.com/users/60779",
"pm_score": 2,
"selected": false,
"text": "<p>Here is a great <code>Wordpress/Bulma</code> boilerplate theme:</p>\n\n<p><a href=\"https://github.com/teamscops/... | 2017/09/13 | [
"https://wordpress.stackexchange.com/questions/279931",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127459/"
] | I apologize in advance for my lack of PHP/WP knowledge, and my wordiness in explaining what I'm looking for, but I've been trying to work out a solution for a couple of days now, and I'm just starting to wrap my head around filters and the loop.
**Here's what I'd like to accomplish:**
A shortcode for a plugin I'm us... | [Bulma.io](https://bulma.io/) is likely to conflict with any styling that comes from Genesis (or any other theme). If you understand HTML/CSS, I recommend using bulma without any other themes/frameworks to avoid conflict/bloat. If you rely on any visual page builders, I would avoid CSS frameworks like bulma and just st... |
279,947 | <p>I have several wp users who do not insert a title when creating a new post (and custom type post). This means that the permalink is assigned a number as the link. Within the multisite I am developing, this will commonly stop the link from working (the page just refreshes).</p>
<p>I want to show a warning message wh... | [
{
"answer_id": 279994,
"author": "Kumar",
"author_id": 32466,
"author_profile": "https://wordpress.stackexchange.com/users/32466",
"pm_score": 3,
"selected": true,
"text": "<p>Your error doesn't appears on the screen because the page is reloaded after the action <code>publish_post</code>... | 2017/09/13 | [
"https://wordpress.stackexchange.com/questions/279947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105819/"
] | I have several wp users who do not insert a title when creating a new post (and custom type post). This means that the permalink is assigned a number as the link. Within the multisite I am developing, this will commonly stop the link from working (the page just refreshes).
I want to show a warning message when the use... | Your error doesn't appears on the screen because the page is reloaded after the action `publish_post`.
I have followed a different approach altogether, I'm checking the post title at `wp_insert_post_data` if the title is empty, I mark the post\_status as draft and save a simple flag in options table. The flag I've sav... |
279,999 | <p>Is there a way to not show the points while you are typing the password but show the letters/numbers of the password? </p>
<p>I would like to implement it in my "My account" page of woocommerce:</p>
<p><a href="https://i.stack.imgur.com/qyaih.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qyaih... | [
{
"answer_id": 280002,
"author": "Harry",
"author_id": 100916,
"author_profile": "https://wordpress.stackexchange.com/users/100916",
"pm_score": -1,
"selected": false,
"text": "<p>override by copying <code>woocommerce/templates/myaccount/form-login.php</code>. it to <code>yourtheme/wooco... | 2017/09/14 | [
"https://wordpress.stackexchange.com/questions/279999",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107597/"
] | Is there a way to not show the points while you are typing the password but show the letters/numbers of the password?
I would like to implement it in my "My account" page of woocommerce:
[](https://i.stack.imgur.com/qyaih.png) | I would strongly disagree to show the **password as the user typing it**.
You could instead implement a way to show the status of the field with a user action like a **user click** to show password or on **hover**.
The reason is that the user makes the decision to show the password. Also, improve the security as maybe... |
280,022 | <p>Is there a way that I can change the order of sections using custom fields?</p>
<p>For example I have:</p>
<pre><code><section id="1"></section>
<section id="2"></section>
<section id="3"></section>
<section id="4"></section>
</code></pre>
<p>And maybe the marketing... | [
{
"answer_id": 280002,
"author": "Harry",
"author_id": 100916,
"author_profile": "https://wordpress.stackexchange.com/users/100916",
"pm_score": -1,
"selected": false,
"text": "<p>override by copying <code>woocommerce/templates/myaccount/form-login.php</code>. it to <code>yourtheme/wooco... | 2017/09/14 | [
"https://wordpress.stackexchange.com/questions/280022",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127880/"
] | Is there a way that I can change the order of sections using custom fields?
For example I have:
```
<section id="1"></section>
<section id="2"></section>
<section id="3"></section>
<section id="4"></section>
```
And maybe the marketing team would like to try displaying section 4 first.
I do use custom fields a lot... | I would strongly disagree to show the **password as the user typing it**.
You could instead implement a way to show the status of the field with a user action like a **user click** to show password or on **hover**.
The reason is that the user makes the decision to show the password. Also, improve the security as maybe... |
280,023 | <p>I want to rewrite custom post type slug. I used this snippet. but not working.</p>
<pre><code>add_filter( 'register_post_type_args', 'wpse247328_register_post_type_args', 10, 2 );
function wpse247328_register_post_type_args( $args ) {
if ( 'stores' === $post_type ) {
$args['rewrite']['slug'] = 'locatio... | [
{
"answer_id": 280002,
"author": "Harry",
"author_id": 100916,
"author_profile": "https://wordpress.stackexchange.com/users/100916",
"pm_score": -1,
"selected": false,
"text": "<p>override by copying <code>woocommerce/templates/myaccount/form-login.php</code>. it to <code>yourtheme/wooco... | 2017/09/14 | [
"https://wordpress.stackexchange.com/questions/280023",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116711/"
] | I want to rewrite custom post type slug. I used this snippet. but not working.
```
add_filter( 'register_post_type_args', 'wpse247328_register_post_type_args', 10, 2 );
function wpse247328_register_post_type_args( $args ) {
if ( 'stores' === $post_type ) {
$args['rewrite']['slug'] = 'location';
}
... | I would strongly disagree to show the **password as the user typing it**.
You could instead implement a way to show the status of the field with a user action like a **user click** to show password or on **hover**.
The reason is that the user makes the decision to show the password. Also, improve the security as maybe... |
280,035 | <p>As you may know, when using the <code><?php</code> tag in a page, it automatically gets commented by WordPress. There are numerous famous plugins allowing to bypass this, such as "insert PHP", but they don't work on WordPress 4.8.1 (I tested a few deprecated ones).</p>
<p>Does anyone know a way to use the <code>... | [
{
"answer_id": 280037,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 2,
"selected": false,
"text": "<p>Although the plugin Exce-WP <a href=\"https://wordpress.org/plugins/wp-exec-php/\" rel=\"nofollow nore... | 2017/09/14 | [
"https://wordpress.stackexchange.com/questions/280035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127874/"
] | As you may know, when using the `<?php` tag in a page, it automatically gets commented by WordPress. There are numerous famous plugins allowing to bypass this, such as "insert PHP", but they don't work on WordPress 4.8.1 (I tested a few deprecated ones).
Does anyone know a way to use the `<?php` tag correctly in WordP... | As I mentioned in the comments, you should not and also can not use codes inside your content. Any code tags that you use will be escaped.
Instead, define a [shortcode](https://codex.wordpress.org/Function_Reference/add_shortcode) in your theme's `functions.php` file and use that inside your content. Let's create a si... |
280,088 | <p>I want to create a splash page with a timer which disappears after 5 seconds when I open up the website before it opens up the main homepage. Any help on this will be highly appreciated. Thanks n advance</p>
| [
{
"answer_id": 280091,
"author": "Richard Bos",
"author_id": 127918,
"author_profile": "https://wordpress.stackexchange.com/users/127918",
"pm_score": -1,
"selected": false,
"text": "<p>The splash page is easy enough, that's in about half of all themes these days. To make it disappear, I... | 2017/09/15 | [
"https://wordpress.stackexchange.com/questions/280088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127917/"
] | I want to create a splash page with a timer which disappears after 5 seconds when I open up the website before it opens up the main homepage. Any help on this will be highly appreciated. Thanks n advance | I would propose first to make this at the front end. The reason is Google and other crawlers can read your content and don't penalize you for sneaky (the user didn't expect a redirect) redirects or slow loading times.
What I would do:
On the main page :
```
function load_splash() {
setTimeout(function () {
$('#hi... |
280,096 | <p>Right now on my root folder, I have an "Under construction" page. So just an index.html, and a style. Then I have a test folder with Wordpress in it, so my website URL is root/test/wordpress. I want to "upload" the website to the root folder so I see the site instead of the under construction page. I have tried chan... | [
{
"answer_id": 280091,
"author": "Richard Bos",
"author_id": 127918,
"author_profile": "https://wordpress.stackexchange.com/users/127918",
"pm_score": -1,
"selected": false,
"text": "<p>The splash page is easy enough, that's in about half of all themes these days. To make it disappear, I... | 2017/09/15 | [
"https://wordpress.stackexchange.com/questions/280096",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115742/"
] | Right now on my root folder, I have an "Under construction" page. So just an index.html, and a style. Then I have a test folder with Wordpress in it, so my website URL is root/test/wordpress. I want to "upload" the website to the root folder so I see the site instead of the under construction page. I have tried changin... | I would propose first to make this at the front end. The reason is Google and other crawlers can read your content and don't penalize you for sneaky (the user didn't expect a redirect) redirects or slow loading times.
What I would do:
On the main page :
```
function load_splash() {
setTimeout(function () {
$('#hi... |
280,098 | <p>I need to send an email to the admin user when a post of the post type "task" is created. Any help would be really appreciated. Thanks!</p>
| [
{
"answer_id": 280103,
"author": "Asisten",
"author_id": 88402,
"author_profile": "https://wordpress.stackexchange.com/users/88402",
"pm_score": 1,
"selected": false,
"text": "<p>You can add action after wp insert post with specified post type:</p>\n\n<pre><code> function after_task_p... | 2017/09/15 | [
"https://wordpress.stackexchange.com/questions/280098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81609/"
] | I need to send an email to the admin user when a post of the post type "task" is created. Any help would be really appreciated. Thanks! | If you want to send an email **on first publish and on updates**, you can avoid many extra checks by using {`status`}\_{`post type`} action hook. Put the code below into the current theme's functions.php:
```
add_action( 'publish_task', 'wpse_admin_email', 10, 2 );
function wpse_admin_email( $post_id, $post ) {
/... |
280,123 | <p>I'm trying to unpublish (set post_status to draft) all posts when a new one (with specific conditions that don't really matter right now) is published. </p>
<p>Here's what I currently have:</p>
<pre><code>function rsc_unpublish_all_ads( $post_id ) {
// don't do anything if the post is not an ad
$post_type... | [
{
"answer_id": 280103,
"author": "Asisten",
"author_id": 88402,
"author_profile": "https://wordpress.stackexchange.com/users/88402",
"pm_score": 1,
"selected": false,
"text": "<p>You can add action after wp insert post with specified post type:</p>\n\n<pre><code> function after_task_p... | 2017/09/15 | [
"https://wordpress.stackexchange.com/questions/280123",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121195/"
] | I'm trying to unpublish (set post\_status to draft) all posts when a new one (with specific conditions that don't really matter right now) is published.
Here's what I currently have:
```
function rsc_unpublish_all_ads( $post_id ) {
// don't do anything if the post is not an ad
$post_type = get_post_type($po... | If you want to send an email **on first publish and on updates**, you can avoid many extra checks by using {`status`}\_{`post type`} action hook. Put the code below into the current theme's functions.php:
```
add_action( 'publish_task', 'wpse_admin_email', 10, 2 );
function wpse_admin_email( $post_id, $post ) {
/... |
280,125 | <p>I would like to have a separate url for each of my product variations. For that I would need to create a rewrite rule, that will work on the product URLs</p>
<p>Ie, my product URL is <code>https://example.com/product/tshirt/</code> </p>
<p>The product has two variations - size and color. I would like to be able to... | [
{
"answer_id": 287827,
"author": "user1049961",
"author_id": 47664,
"author_profile": "https://wordpress.stackexchange.com/users/47664",
"pm_score": 4,
"selected": true,
"text": "<p>Ok, for anyone looking for this, here's a complete plugin that I came up with, that solves the issue:</p>\... | 2017/09/15 | [
"https://wordpress.stackexchange.com/questions/280125",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47664/"
] | I would like to have a separate url for each of my product variations. For that I would need to create a rewrite rule, that will work on the product URLs
Ie, my product URL is `https://example.com/product/tshirt/`
The product has two variations - size and color. I would like to be able to access the product on url l... | Ok, for anyone looking for this, here's a complete plugin that I came up with, that solves the issue:
```
<?php
/*
Plugin Name: WooCommerce Variations URL
Description: Adds support for variation-specific URL's for WooCommerce product variations
Author: Václav Greif
Version: 1.0
Author URI: https://wp-programator.cz
*/... |
280,146 | <p>I want to remove automatically the <em>Home</em> menu item, <strong>but only once</strong>, more precisely <strong>at the first run of Wordpress or at the first child theme activation/loading</strong>. Now I have a function in the functions.php of my child theme that checks if the <em>Home</em> menu item exists and ... | [
{
"answer_id": 379826,
"author": "Tariq Ahmed",
"author_id": 119429,
"author_profile": "https://wordpress.stackexchange.com/users/119429",
"pm_score": 4,
"selected": true,
"text": "<p>There is no native WordPress hook called <code>add_filter_once()</code>. This is an custom solution whic... | 2017/09/15 | [
"https://wordpress.stackexchange.com/questions/280146",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | I want to remove automatically the *Home* menu item, **but only once**, more precisely **at the first run of Wordpress or at the first child theme activation/loading**. Now I have a function in the functions.php of my child theme that checks if the *Home* menu item exists and delete it from the menu. Of course, this fu... | There is no native WordPress hook called `add_filter_once()`. This is an custom solution which will help you to run your hook only once.
For example if inside a loop or whatever situation you are facing. However,
The basic idea is to check when you need to stop using your hook and simply **remove\_hook** from WordPres... |
280,151 | <p>I am saving a post id in a variable with the_id() function. And then i need to fetch the data of same post id from database . As post id is working fine but i am getting error while executing get result . below is the code . Can anyone please help ?</p>
<pre><code> $a = the_ID();;
global $wp... | [
{
"answer_id": 379826,
"author": "Tariq Ahmed",
"author_id": 119429,
"author_profile": "https://wordpress.stackexchange.com/users/119429",
"pm_score": 4,
"selected": true,
"text": "<p>There is no native WordPress hook called <code>add_filter_once()</code>. This is an custom solution whic... | 2017/09/15 | [
"https://wordpress.stackexchange.com/questions/280151",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127961/"
] | I am saving a post id in a variable with the\_id() function. And then i need to fetch the data of same post id from database . As post id is working fine but i am getting error while executing get result . below is the code . Can anyone please help ?
```
$a = the_ID();;
global $wpdb;
... | There is no native WordPress hook called `add_filter_once()`. This is an custom solution which will help you to run your hook only once.
For example if inside a loop or whatever situation you are facing. However,
The basic idea is to check when you need to stop using your hook and simply **remove\_hook** from WordPres... |
280,156 | <p>We are trying to get our set up an SMTP function but keep hitting errors with the test email. We even tried both WP-Mail-SMTP and Easy WP SMTP. After talking with our host at WPEngine we couldn't find any issue on their end since they do use OpenSSL and told us to use port 2525 since we are using Outlook. Our IT dep... | [
{
"answer_id": 379826,
"author": "Tariq Ahmed",
"author_id": 119429,
"author_profile": "https://wordpress.stackexchange.com/users/119429",
"pm_score": 4,
"selected": true,
"text": "<p>There is no native WordPress hook called <code>add_filter_once()</code>. This is an custom solution whic... | 2017/09/15 | [
"https://wordpress.stackexchange.com/questions/280156",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/118885/"
] | We are trying to get our set up an SMTP function but keep hitting errors with the test email. We even tried both WP-Mail-SMTP and Easy WP SMTP. After talking with our host at WPEngine we couldn't find any issue on their end since they do use OpenSSL and told us to use port 2525 since we are using Outlook. Our IT depart... | There is no native WordPress hook called `add_filter_once()`. This is an custom solution which will help you to run your hook only once.
For example if inside a loop or whatever situation you are facing. However,
The basic idea is to check when you need to stop using your hook and simply **remove\_hook** from WordPres... |
280,161 | <p>I'm trying to overwrite following code in the child theme. I want to load file <code>/inc/soundtheme-admin.php</code> from child folder. I copied same code snippet in <code>child-theme/functions.php</code> and also copied the <code>inc/soundtheme-admin.php</code>. I also replaced the <code>get_template_directory()</... | [
{
"answer_id": 280164,
"author": "dwcouch",
"author_id": 33411,
"author_profile": "https://wordpress.stackexchange.com/users/33411",
"pm_score": 2,
"selected": true,
"text": "<p><strong>The functions in your child theme will be loaded before the functions in the parent theme</strong>. Th... | 2017/09/15 | [
"https://wordpress.stackexchange.com/questions/280161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127970/"
] | I'm trying to overwrite following code in the child theme. I want to load file `/inc/soundtheme-admin.php` from child folder. I copied same code snippet in `child-theme/functions.php` and also copied the `inc/soundtheme-admin.php`. I also replaced the `get_template_directory()` to `get_stylesheet_directory()` but its s... | **The functions in your child theme will be loaded before the functions in the parent theme**. This means that if your parent and child themes both have functions called my\_function() which do a similar job, the one in the parent theme will load last, meaning it will override the one in the child theme.
~[Guide to Fu... |
280,176 | <p>I have been using quark a lot which is a starter theme.</p>
<p>I have been using a child theme with quark for a few reasons:</p>
<ul>
<li>Clear separation of code </li>
<li>Ability to easily update quark on theme
updates</li>
</ul>
<p>As I have become more in tune with the theme and wordpress, I am trying to redu... | [
{
"answer_id": 280164,
"author": "dwcouch",
"author_id": 33411,
"author_profile": "https://wordpress.stackexchange.com/users/33411",
"pm_score": 2,
"selected": true,
"text": "<p><strong>The functions in your child theme will be loaded before the functions in the parent theme</strong>. Th... | 2017/09/16 | [
"https://wordpress.stackexchange.com/questions/280176",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10368/"
] | I have been using quark a lot which is a starter theme.
I have been using a child theme with quark for a few reasons:
* Clear separation of code
* Ability to easily update quark on theme
updates
As I have become more in tune with the theme and wordpress, I am trying to reduce the load and resources to ensure speed a... | **The functions in your child theme will be loaded before the functions in the parent theme**. This means that if your parent and child themes both have functions called my\_function() which do a similar job, the one in the parent theme will load last, meaning it will override the one in the child theme.
~[Guide to Fu... |
280,198 | <p>I am a beginner with WordPress. Studying hook, add_action() and add_filer() and see in the documentation that</p>
<pre><code>add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )
</code></pre>
<p>But I dont know how to get $tag and where to get it to fill into add_action(... | [
{
"answer_id": 280204,
"author": "Trac Nguyen",
"author_id": 128003,
"author_profile": "https://wordpress.stackexchange.com/users/128003",
"pm_score": 1,
"selected": false,
"text": "<p>These 2 function <code>add_action()</code> and <code>add_filter()</code> are magics of WP and do not di... | 2017/09/16 | [
"https://wordpress.stackexchange.com/questions/280198",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127997/"
] | I am a beginner with WordPress. Studying hook, add\_action() and add\_filer() and see in the documentation that
```
add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )
```
But I dont know how to get $tag and where to get it to fill into add\_action() or add\_filter() func... | These 2 function `add_action()` and `add_filter()` are magics of WP and do not directly affect your code. In WordPress, they use `hooks` for mocking into existing functions, methods without changing it's code.
The `$tag` you are referring is the **name of the hook** that you want to use. List of core hooks can be fou... |
280,200 | <p>I deleted everything in my directory to "start over" When I install wordpress it says :
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
I tried changing the php version but it makes no difference.
here is a scrnsht of my home dir : <a href="https://i.stack.imgur.com/L... | [
{
"answer_id": 280204,
"author": "Trac Nguyen",
"author_id": 128003,
"author_profile": "https://wordpress.stackexchange.com/users/128003",
"pm_score": 1,
"selected": false,
"text": "<p>These 2 function <code>add_action()</code> and <code>add_filter()</code> are magics of WP and do not di... | 2017/09/16 | [
"https://wordpress.stackexchange.com/questions/280200",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128000/"
] | I deleted everything in my directory to "start over" When I install wordpress it says :
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
I tried changing the php version but it makes no difference.
here is a scrnsht of my home dir : [` and `add_filter()` are magics of WP and do not directly affect your code. In WordPress, they use `hooks` for mocking into existing functions, methods without changing it's code.
The `$tag` you are referring is the **name of the hook** that you want to use. List of core hooks can be fou... |
280,241 | <p>I uploaded an html 403 and 404 page to my WordPress theme directory and if I hit a random mistake after .com such as .com/yyyy then it loads the 404 page for example - so all is good...</p>
<p>However...I would like the 403.php to be shown when someone outside my permitted IP string attempts to access my log in pag... | [
{
"answer_id": 280243,
"author": "Asisten",
"author_id": 88402,
"author_profile": "https://wordpress.stackexchange.com/users/88402",
"pm_score": -1,
"selected": false,
"text": "<ol>\n<li><p>Wordpress has built in 404 and 403 template, it called in 404.php and 403.php in your template.</p... | 2017/09/17 | [
"https://wordpress.stackexchange.com/questions/280241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | I uploaded an html 403 and 404 page to my WordPress theme directory and if I hit a random mistake after .com such as .com/yyyy then it loads the 404 page for example - so all is good...
However...I would like the 403.php to be shown when someone outside my permitted IP string attempts to access my log in page.
This .... | >
> it create a never-ending loop as WordPress tries to find the 403.php page
>
>
>
Not WordPress, but Apache. WordPress never even sees the request.
You need to make an exception for your custom 403 error document, otherwise, the directives you have posted would issue another 403 for the error document itself...... |
280,256 | <p>I am trying to use <code>wp_remote_post()</code> like this:</p>
<pre><code>wp_remote_post( $url, array( 'blocking' => false, 'timeout' => 0.1 ) );
</code></pre>
<p>The problem is that it seems to always force the timeout to 1s.<br>
I don't even want to wait for 1s, I just want the remote post to start and im... | [
{
"answer_id": 280259,
"author": "Sören Wrede",
"author_id": 68682,
"author_profile": "https://wordpress.stackexchange.com/users/68682",
"pm_score": 0,
"selected": false,
"text": "<p>The timeout is the <strong>maximal</strong> not minimal time the functions waits for an answer. So, if th... | 2017/09/17 | [
"https://wordpress.stackexchange.com/questions/280256",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124462/"
] | I am trying to use `wp_remote_post()` like this:
```
wp_remote_post( $url, array( 'blocking' => false, 'timeout' => 0.1 ) );
```
The problem is that it seems to always force the timeout to 1s.
I don't even want to wait for 1s, I just want the remote post to start and immediately go back to my the calling function... | For cURL, a minimum of 1 second applies, as DNS resolution operates at second-resolution only.
See more in wp-includes/class-request.php function request() |
280,257 | <p>Problem Description:</p>
<p>the code below is from a single-featured-article.php file . Copying this custom template for a custom post type 'featured-article' from my plug-in to the active theme folder . The template is rendering fine . Even the query showing data in the array .</p>
<p>see: result of print_r($feat... | [
{
"answer_id": 280258,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p><code>the_post()</code> doesn't render anything. Read <a href=\"https://developer.wordpress.org/referen... | 2017/09/17 | [
"https://wordpress.stackexchange.com/questions/280257",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127638/"
] | Problem Description:
the code below is from a single-featured-article.php file . Copying this custom template for a custom post type 'featured-article' from my plug-in to the active theme folder . The template is rendering fine . Even the query showing data in the array .
see: result of print\_r($featured\_articles) ... | You made a mistake in the syntax:
`if ($featured_articles > have_posts()):
while ($featured_articles > have_posts()) : $featured_articles->the_post();`
in the `if` and `while` conditions should be `->` instead `>`. |
280,271 | <p>I use <em>Tinymce Advanced</em> plugin. I would like to remove p tag by adding this code <code>remove_filter( 'the_content', 'wpautop' );</code> to my <code>functions.php</code>. However, it does't work. When I press ENTER, it still inserts double line, not single line. The <code>p</code> character still displays at... | [
{
"answer_id": 280330,
"author": "CodeMascot",
"author_id": 44192,
"author_profile": "https://wordpress.stackexchange.com/users/44192",
"pm_score": 0,
"selected": false,
"text": "<p>Your code seems pretty correnct. Please check whether your code actually removes <code>wpautop</code> func... | 2017/09/17 | [
"https://wordpress.stackexchange.com/questions/280271",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125408/"
] | I use *Tinymce Advanced* plugin. I would like to remove p tag by adding this code `remove_filter( 'the_content', 'wpautop' );` to my `functions.php`. However, it does't work. When I press ENTER, it still inserts double line, not single line. The `p` character still displays at the bottom left of the `textarea`. | You can achieve this much easier with css (escpecially for wp-ers who dont have access to edit plugins):
```
<style>
p:empty{
height: 0;
margin: 0;
padding: 0;
}
</style>
``` |
280,278 | <p>In the customizer, the site identity section is missing a logo upload field. Adding such field is not a big deal: A field can be added, but I don't know the section name that is created in the core of the WordPress. Can someone help me in that?</p>
<p>The field can be created like this:</p>
<pre><code> $fields[... | [
{
"answer_id": 280294,
"author": "Weston Ruter",
"author_id": 8521,
"author_profile": "https://wordpress.stackexchange.com/users/8521",
"pm_score": 3,
"selected": true,
"text": "<p>The “Site Identity” section has the ID of <code>title_tagline</code> for historical reasons.</p>\n\n<p>If y... | 2017/09/17 | [
"https://wordpress.stackexchange.com/questions/280278",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105791/"
] | In the customizer, the site identity section is missing a logo upload field. Adding such field is not a big deal: A field can be added, but I don't know the section name that is created in the core of the WordPress. Can someone help me in that?
The field can be created like this:
```
$fields[] = array(
'type'... | The “Site Identity” section has the ID of `title_tagline` for historical reasons.
If you want to see the IDs for the core sections, all you have to do is look at the source for [`WP_Customize_Manager::register_controls()`](https://github.com/WordPress/wordpress-develop/blob/2ff66f7c50cf375289cf5f2e47d140250c94e59e/src... |
280,311 | <p>I'm seeking to echo the domain name (url) without the 'http://' (or 'https://').</p>
<p>I've created the following: </p>
<p><code><?php $surl = bloginfo('url'); $findh = array( 'http://' ); $replace = ''; $outputh = str_replace( $findh, $replace, $surl ); echo $outputh; ?></code></p>
<p>also another one (of... | [
{
"answer_id": 280313,
"author": "UltimateDevil",
"author_id": 128073,
"author_profile": "https://wordpress.stackexchange.com/users/128073",
"pm_score": 0,
"selected": false,
"text": "<p>try this may help you,</p>\n\n<pre><code>$link = get_permalink();\n $remove_http = '#^http(s)?://#... | 2017/09/18 | [
"https://wordpress.stackexchange.com/questions/280311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128074/"
] | I'm seeking to echo the domain name (url) without the 'http://' (or 'https://').
I've created the following:
`<?php $surl = bloginfo('url'); $findh = array( 'http://' ); $replace = ''; $outputh = str_replace( $findh, $replace, $surl ); echo $outputh; ?>`
also another one (of many) I tried:
```
<?php $surl = blogin... | You could use core PHP function [`parse_url();`](http://php.net/manual/en/function.parse-url.php) for this.
**Example:**
```
$url = 'https://www.google.com/';
$url_data = parse_url( $url );
$url_data['host'] = explode( '.', $url_data['host'] );
unset( $url_data['host'][0] );
echo join( '.', $url... |
280,338 | <p>In my plugin (my first one), I inserted 2 posts with a custom post_type ('foo' for this example). This kind of post is exactly like a page but which is unedited (so hidden in the admin. interface).
I would like to display this post on the front-end as a page (so with the template: page.php) when the user click on th... | [
{
"answer_id": 280313,
"author": "UltimateDevil",
"author_id": 128073,
"author_profile": "https://wordpress.stackexchange.com/users/128073",
"pm_score": 0,
"selected": false,
"text": "<p>try this may help you,</p>\n\n<pre><code>$link = get_permalink();\n $remove_http = '#^http(s)?://#... | 2017/09/18 | [
"https://wordpress.stackexchange.com/questions/280338",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128094/"
] | In my plugin (my first one), I inserted 2 posts with a custom post\_type ('foo' for this example). This kind of post is exactly like a page but which is unedited (so hidden in the admin. interface).
I would like to display this post on the front-end as a page (so with the template: page.php) when the user click on the ... | You could use core PHP function [`parse_url();`](http://php.net/manual/en/function.parse-url.php) for this.
**Example:**
```
$url = 'https://www.google.com/';
$url_data = parse_url( $url );
$url_data['host'] = explode( '.', $url_data['host'] );
unset( $url_data['host'][0] );
echo join( '.', $url... |
280,364 | <p>We bought a SLL certificate recently to change our website to work with https protocol. After this change, we realized that the tag:</p>
<pre><code><meta
property="og:image" content="https://[ ... url ...].jpg" />
</code></pre>
<p>is working when you load the website and open its source code. The thing is: F... | [
{
"answer_id": 280374,
"author": "Jan Boddez",
"author_id": 128111,
"author_profile": "https://wordpress.stackexchange.com/users/128111",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think the tag is wrongly formatted <em>because</em> of the SSL certificate.</p>\n\n<p>Sometimes,... | 2017/09/18 | [
"https://wordpress.stackexchange.com/questions/280364",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77513/"
] | We bought a SLL certificate recently to change our website to work with https protocol. After this change, we realized that the tag:
```
<meta
property="og:image" content="https://[ ... url ...].jpg" />
```
is working when you load the website and open its source code. The thing is: Facebook sharing debug tool doesn... | The https change was not the cause. Actually - coincidentally - the W3 Total Cache was updated on the same day, and the **Minify** setting was breaking lines between **meta** and **property** words on the HTML, which were causing the error on Facebook debug tool. |
280,429 | <p>I'm developing a WordPress theme and I would like to add a feature like that of page origin page builder.</p>
<p>I would have just used their plugin but I don't really like the way it's setup. My main question is a guideline on how to make a page builder to have a button with an ability to insert widgets into areas... | [
{
"answer_id": 280462,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 0,
"selected": false,
"text": "<p>Building a page builder would be a much more complex undertaking than some other options. I would suggest... | 2017/09/19 | [
"https://wordpress.stackexchange.com/questions/280429",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127929/"
] | I'm developing a WordPress theme and I would like to add a feature like that of page origin page builder.
I would have just used their plugin but I don't really like the way it's setup. My main question is a guideline on how to make a page builder to have a button with an ability to insert widgets into areas.
I've se... | You can insert widgets into a post by Shortcode. Just make a shortcode with `dynamic_sidebar()` function to insert your specified sidebar widgets.
```
<?php
add_shortcode('sidebar_widgets', function($atts, $content) {
ob_start();
$atts = shortcode_atts(array(
'sidebar_id' => '',
),$atts);
?>
<div>
<?ph... |
280,430 | <p>Can I do this for posts?</p>
<p>I have the most recents posts I am fetching and I am showing the thumbnail (the featured image) of these posts IF they exist.</p>
<p><strong>What I want to do now, is to show category images IF the featured image does not exist.</strong></p>
<p>Can someone help me with this?</p>
<... | [
{
"answer_id": 280462,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 0,
"selected": false,
"text": "<p>Building a page builder would be a much more complex undertaking than some other options. I would suggest... | 2017/09/19 | [
"https://wordpress.stackexchange.com/questions/280430",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62192/"
] | Can I do this for posts?
I have the most recents posts I am fetching and I am showing the thumbnail (the featured image) of these posts IF they exist.
**What I want to do now, is to show category images IF the featured image does not exist.**
Can someone help me with this?
I have this, at the moment:
```
<?php... | You can insert widgets into a post by Shortcode. Just make a shortcode with `dynamic_sidebar()` function to insert your specified sidebar widgets.
```
<?php
add_shortcode('sidebar_widgets', function($atts, $content) {
ob_start();
$atts = shortcode_atts(array(
'sidebar_id' => '',
),$atts);
?>
<div>
<?ph... |
280,457 | <p>I've created a page with list of custom terms:
<a href="https://i.stack.imgur.com/JZIhy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JZIhy.png" alt="enter image description here"></a></p>
<p>Under each Term, i need to show every posts with post_type = 'courses'e taxnonomy = 'courses_category'<... | [
{
"answer_id": 280462,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 0,
"selected": false,
"text": "<p>Building a page builder would be a much more complex undertaking than some other options. I would suggest... | 2017/09/19 | [
"https://wordpress.stackexchange.com/questions/280457",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128160/"
] | I've created a page with list of custom terms:
[](https://i.stack.imgur.com/JZIhy.png)
Under each Term, i need to show every posts with post\_type = 'courses'e taxnonomy = 'courses\_category'
What will be the query to display those records?
Thanks | You can insert widgets into a post by Shortcode. Just make a shortcode with `dynamic_sidebar()` function to insert your specified sidebar widgets.
```
<?php
add_shortcode('sidebar_widgets', function($atts, $content) {
ob_start();
$atts = shortcode_atts(array(
'sidebar_id' => '',
),$atts);
?>
<div>
<?ph... |
280,459 | <p>I am trying to create custom slider so trying to print all ul in same li . but problem is that I am getting data in different different ul.
Here is query.</p>
<pre><code> <?php
$args = array(
'post_type' => 'slider',
'posts_per_page' => 5
);
$loop = new WP_Query( $args );
while... | [
{
"answer_id": 280460,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 0,
"selected": false,
"text": "<p>Move the <code><ul></code> out of the <code>while</code> loop:</p>\n\n<pre><code>$loop = new WP_Q... | 2017/09/19 | [
"https://wordpress.stackexchange.com/questions/280459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/120176/"
] | I am trying to create custom slider so trying to print all ul in same li . but problem is that I am getting data in different different ul.
Here is query.
```
<?php
$args = array(
'post_type' => 'slider',
'posts_per_page' => 5
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() )... | Preblem is because inside loop you have UL
```
echo '<ul>';
while ( $loop->have_posts() ) : $loop->the_post();
?>
<li data-transition="fade" data-slotamount="6">
<?php
echo wp_get_attachment_image( get_post_thumbnail_id(), 'full', false, array( 'class' => 'thumbnail zoom' ) );?... |
280,532 | <p>I'm making a plugin which generate a form in a custom post. For security, I would like to avise the administrator with a notice if this specific post does not work with HTTPS/SSL yet.</p>
<p>I know the function <strong>is_ssl()</strong> but it is to check the current page, not a specific post by the ID.</p>
<p>Som... | [
{
"answer_id": 280460,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 0,
"selected": false,
"text": "<p>Move the <code><ul></code> out of the <code>while</code> loop:</p>\n\n<pre><code>$loop = new WP_Q... | 2017/09/20 | [
"https://wordpress.stackexchange.com/questions/280532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128094/"
] | I'm making a plugin which generate a form in a custom post. For security, I would like to avise the administrator with a notice if this specific post does not work with HTTPS/SSL yet.
I know the function **is\_ssl()** but it is to check the current page, not a specific post by the ID.
Someone has got an idea ? | Preblem is because inside loop you have UL
```
echo '<ul>';
while ( $loop->have_posts() ) : $loop->the_post();
?>
<li data-transition="fade" data-slotamount="6">
<?php
echo wp_get_attachment_image( get_post_thumbnail_id(), 'full', false, array( 'class' => 'thumbnail zoom' ) );?... |
280,540 | <p>I have two areas where I fetch the most recent entries. In the first area, I want to get the first 10 posts. In the second area, I want to fetch the posts starting at post number 11....</p>
<p>I have this:</p>
<pre><code><?php
$args = array( 'numberposts' => '10' );
$recent_posts = wp_get_recent_posts($args... | [
{
"answer_id": 280542,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 1,
"selected": false,
"text": "<p>Looking at the <a href=\"https://developer.wordpress.org/reference/classes/wp_query/#pagination-parameters\" r... | 2017/09/20 | [
"https://wordpress.stackexchange.com/questions/280540",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62192/"
] | I have two areas where I fetch the most recent entries. In the first area, I want to get the first 10 posts. In the second area, I want to fetch the posts starting at post number 11....
I have this:
```
<?php
$args = array( 'numberposts' => '10' );
$recent_posts = wp_get_recent_posts($args);
$featured_posts = themen... | I solved it myself. What I did, is adding this:
```php
$loop = new WP_Query(array(
'offset' => 20,
));
```
And then changing:
```
if (have_posts()) : while (have_posts()) : the_post();
```
into:
```
if ($loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
``` |
280,546 | <p>Here is my website <a href="http://www.taramesh.ae/" rel="nofollow noreferrer">http://www.taramesh.ae/</a>
I'm trying to perform SEO on it and for this I need to set alt attribute for each image. Even I have given it in media but instead, it is not showing when I look it in inspect element or view source.
I have fo... | [
{
"answer_id": 280542,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 1,
"selected": false,
"text": "<p>Looking at the <a href=\"https://developer.wordpress.org/reference/classes/wp_query/#pagination-parameters\" r... | 2017/09/20 | [
"https://wordpress.stackexchange.com/questions/280546",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128233/"
] | Here is my website <http://www.taramesh.ae/>
I'm trying to perform SEO on it and for this I need to set alt attribute for each image. Even I have given it in media but instead, it is not showing when I look it in inspect element or view source.
I have found an article related to this [alt, title tags not showing](http... | I solved it myself. What I did, is adding this:
```php
$loop = new WP_Query(array(
'offset' => 20,
));
```
And then changing:
```
if (have_posts()) : while (have_posts()) : the_post();
```
into:
```
if ($loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
``` |
280,554 | <p>I want to import existing users with their passwords from an old WordPress site to a new one. The new WordPress installation has also existing users. Therefore I couldn't simply export/import the database tables from the old site.</p>
<p>Is there any other way to import the old users with passwords to the new site?... | [
{
"answer_id": 280542,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 1,
"selected": false,
"text": "<p>Looking at the <a href=\"https://developer.wordpress.org/reference/classes/wp_query/#pagination-parameters\" r... | 2017/09/20 | [
"https://wordpress.stackexchange.com/questions/280554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96806/"
] | I want to import existing users with their passwords from an old WordPress site to a new one. The new WordPress installation has also existing users. Therefore I couldn't simply export/import the database tables from the old site.
Is there any other way to import the old users with passwords to the new site? | I solved it myself. What I did, is adding this:
```php
$loop = new WP_Query(array(
'offset' => 20,
));
```
And then changing:
```
if (have_posts()) : while (have_posts()) : the_post();
```
into:
```
if ($loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
``` |
280,566 | <p>If you want to escape string values in an SQL query, you can use WordPress's <a href="https://developer.wordpress.org/reference/functions/esc_sql/" rel="nofollow noreferrer"><code>esc_sql</code></a> function:</p>
<pre><code><?php
$wpdb->get_var( "SELECT * FROM something WHERE foo = '" . esc_sql( $foo ) . "'"... | [
{
"answer_id": 280583,
"author": "Flimm",
"author_id": 122391,
"author_profile": "https://wordpress.stackexchange.com/users/122391",
"pm_score": 3,
"selected": true,
"text": "<p>I can't find a function shipped with WordPress that does this, so I created my own:</p>\n\n<pre><code> functio... | 2017/09/20 | [
"https://wordpress.stackexchange.com/questions/280566",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122391/"
] | If you want to escape string values in an SQL query, you can use WordPress's [`esc_sql`](https://developer.wordpress.org/reference/functions/esc_sql/) function:
```
<?php
$wpdb->get_var( "SELECT * FROM something WHERE foo = '" . esc_sql( $foo ) . "'" );
```
You can also use the much more convenient [`prepare`](http... | I can't find a function shipped with WordPress that does this, so I created my own:
```
function esc_sql_name( $name ) {
return str_replace( "`", "``", $name );
}
```
You can use it like this:
```
$escaped_name = esc_sql_name( $column_name );
$sql = $wpdb->prepare(
"SELECT * FROM example WHERE `$es... |
280,604 | <p>My site was first built with html/css in 2000, and when I rebuilt it with WordPress in 2012, I kept the .html extension in the interest of keeping the same URLs. I'd like to get rid of it now and redirect the old html pages to the new extension-less pages.</p>
<p>My current permalink structure is:
/%category%/%post... | [
{
"answer_id": 280583,
"author": "Flimm",
"author_id": 122391,
"author_profile": "https://wordpress.stackexchange.com/users/122391",
"pm_score": 3,
"selected": true,
"text": "<p>I can't find a function shipped with WordPress that does this, so I created my own:</p>\n\n<pre><code> functio... | 2017/09/20 | [
"https://wordpress.stackexchange.com/questions/280604",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128267/"
] | My site was first built with html/css in 2000, and when I rebuilt it with WordPress in 2012, I kept the .html extension in the interest of keeping the same URLs. I'd like to get rid of it now and redirect the old html pages to the new extension-less pages.
My current permalink structure is:
/%category%/%postname%.html... | I can't find a function shipped with WordPress that does this, so I created my own:
```
function esc_sql_name( $name ) {
return str_replace( "`", "``", $name );
}
```
You can use it like this:
```
$escaped_name = esc_sql_name( $column_name );
$sql = $wpdb->prepare(
"SELECT * FROM example WHERE `$es... |
280,615 | <p>I saw this question on another post but was unable to add an answer because my reputation is too low. So I thought I would create a new thread. </p>
<ul>
<li>So I migrated a website from a draft server to a live server.
<ul>
<li>I copied the website folder from the draft server and pasted into the live server.</l... | [
{
"answer_id": 280616,
"author": "Justin Young",
"author_id": 114859,
"author_profile": "https://wordpress.stackexchange.com/users/114859",
"pm_score": -1,
"selected": false,
"text": "<p>This was the solution</p>\n\n<ul>\n<li>Go ftp or file manager\n\n<ul>\n<li>find the .htaccess file</l... | 2017/09/20 | [
"https://wordpress.stackexchange.com/questions/280615",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114859/"
] | I saw this question on another post but was unable to add an answer because my reputation is too low. So I thought I would create a new thread.
* So I migrated a website from a draft server to a live server.
+ I copied the website folder from the draft server and pasted into the live server.
+ I copied the website ... | For those who may come along: In addition to your proposed answer, you can use the .htaccess file in your web root directory. These often get missed as they are hidden files on linux systems. You can check and make sure that was copied over, or make a new file and paste the rewrite rules into that. Here is an example o... |
280,633 | <p>I want my posts to be limited to number characters. I want this to happen on the page that shows all my posts. I am using this snippet. The read more link also appears when you are viewing the single post. I only want this to happen on the multi post view</p>
<p><a href="https://i.stack.imgur.com/vcIun.png" rel="n... | [
{
"answer_id": 280616,
"author": "Justin Young",
"author_id": 114859,
"author_profile": "https://wordpress.stackexchange.com/users/114859",
"pm_score": -1,
"selected": false,
"text": "<p>This was the solution</p>\n\n<ul>\n<li>Go ftp or file manager\n\n<ul>\n<li>find the .htaccess file</l... | 2017/09/21 | [
"https://wordpress.stackexchange.com/questions/280633",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128284/"
] | I want my posts to be limited to number characters. I want this to happen on the page that shows all my posts. I am using this snippet. The read more link also appears when you are viewing the single post. I only want this to happen on the multi post view
[;
if(is_user_logged_in()){
// content for login user
}
else {
// https://developer.wordpress.org/reference/functions/wp_redirect/
// wp_redirect() does not validate that the $locati... | [
{
"answer_id": 280665,
"author": "Wh0CaREs",
"author_id": 123614,
"author_profile": "https://wordpress.stackexchange.com/users/123614",
"pm_score": 0,
"selected": false,
"text": "<p>As I know you can use wp_redirect before content is sent to the browser. You should use hooks for that.</p... | 2017/09/21 | [
"https://wordpress.stackexchange.com/questions/280660",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128293/"
] | ```
<?php
/**
* Template Name: Custom Page Template
*/
get_header();
if(is_user_logged_in()){
// content for login user
}
else {
// https://developer.wordpress.org/reference/functions/wp_redirect/
// wp_redirect() does not validate that the $location is a re... | Redirects are performed by outputting HTTP headers, `wp_redirect()` just adds some bits on top of it for flexibility.
Headers are only ever meant to be used *before any and all output* to a page, since that is how HTTP response is structured.
Hypothetically it could work in template *if* you make sure it fires before... |
280,693 | <p>I have tried a lot but didn't got a proper result. Someone please check my code, where I am doing mistake.</p>
<p>I want to show other posts with same categories but not the post shows on single page also previous and next post of the current post. Is there any other way to show?</p>
<pre><code>$thisid = get_the_I... | [
{
"answer_id": 280695,
"author": "Jan Boddez",
"author_id": 128111,
"author_profile": "https://wordpress.stackexchange.com/users/128111",
"pm_score": 2,
"selected": false,
"text": "<p>Have a look at <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow noreferre... | 2017/09/21 | [
"https://wordpress.stackexchange.com/questions/280693",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128317/"
] | I have tried a lot but didn't got a proper result. Someone please check my code, where I am doing mistake.
I want to show other posts with same categories but not the post shows on single page also previous and next post of the current post. Is there any other way to show?
```
$thisid = get_the_ID();
$prevpost = get_... | Have a look at <https://codex.wordpress.org/Class_Reference/WP_Query>, and maybe try passing your args in an array.
Above page lists this exact example, which should work:
```
// This WILL work
$exclude_ids = array( 1, 2, 3 );
$query = new WP_Query( array( 'post__not_in' => $exclude_ids ) );
``` |
280,694 | <p>I am a newbie with WordPress and I have a little question. I met an issue this morning ("wpdb class was not found") with WordPress and while debugging I find that my wpbg.php file was empty !</p>
<p>Here comes my question:</p>
<p><strong>Is it possible that WordPress erase the content of a file because the server ... | [
{
"answer_id": 280695,
"author": "Jan Boddez",
"author_id": 128111,
"author_profile": "https://wordpress.stackexchange.com/users/128111",
"pm_score": 2,
"selected": false,
"text": "<p>Have a look at <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow noreferre... | 2017/09/21 | [
"https://wordpress.stackexchange.com/questions/280694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128314/"
] | I am a newbie with WordPress and I have a little question. I met an issue this morning ("wpdb class was not found") with WordPress and while debugging I find that my wpbg.php file was empty !
Here comes my question:
**Is it possible that WordPress erase the content of a file because the server has no more memory or I... | Have a look at <https://codex.wordpress.org/Class_Reference/WP_Query>, and maybe try passing your args in an array.
Above page lists this exact example, which should work:
```
// This WILL work
$exclude_ids = array( 1, 2, 3 );
$query = new WP_Query( array( 'post__not_in' => $exclude_ids ) );
``` |
280,747 | <p>I'm really new to php and I'm trying to get an image set using advanced custom fields on my front end. I've looked at the docs and forums but I can't get the url. All the code works but for the image. I expect the url value to show up but instead I get a blank value. I know I need to get the taxonomy ID, I must be m... | [
{
"answer_id": 280751,
"author": "roychri",
"author_id": 128349,
"author_profile": "https://wordpress.stackexchange.com/users/128349",
"pm_score": 2,
"selected": true,
"text": "<p>Make sure you are using version 5.5.0 or newer since only that version support the format</p>\n\n<pre><code>... | 2017/09/22 | [
"https://wordpress.stackexchange.com/questions/280747",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128346/"
] | I'm really new to php and I'm trying to get an image set using advanced custom fields on my front end. I've looked at the docs and forums but I can't get the url. All the code works but for the image. I expect the url value to show up but instead I get a blank value. I know I need to get the taxonomy ID, I must be miss... | Make sure you are using version 5.5.0 or newer since only that version support the format
```
'term_' . $id
```
Try passing `$cat` as the second parameter to `the_field()`. |
280,782 | <p>I have a registration form where i am trying to register new members.
I am trying to pass both the formdata for image upload and ajax action in wordpress. Currently i am trying to print the values in console. But the ajax function is not at all called as action is not working. How can i do that. Please help me.</p>
... | [
{
"answer_id": 280784,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 3,
"selected": true,
"text": "<p>try to add the action in the formdata : </p>\n\n<pre><code> var formData=new FormData(document.getElementBy... | 2017/09/22 | [
"https://wordpress.stackexchange.com/questions/280782",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128368/"
] | I have a registration form where i am trying to register new members.
I am trying to pass both the formdata for image upload and ajax action in wordpress. Currently i am trying to print the values in console. But the ajax function is not at all called as action is not working. How can i do that. Please help me.
**HTML... | try to add the action in the formdata :
```
var formData=new FormData(document.getElementById('landlordregform'));
formData.append("action", "custom_landlord_registration_process");
jQuery.ajax({
url: jQuery("#cusajaxurl").val(),
type: 'POST',
data: fo... |
280,792 | <p>I'm trying to search only by a custom post type in Wordpress. </p>
<p>In my search form I have:</p>
<pre><code><input type="hidden" name="post_type" value="customposttype" />
</code></pre>
<p>In my functions file I have:</p>
<pre><code> function template_chooser($template)
{
global $wp_query;
... | [
{
"answer_id": 280784,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 3,
"selected": true,
"text": "<p>try to add the action in the formdata : </p>\n\n<pre><code> var formData=new FormData(document.getElementBy... | 2017/09/22 | [
"https://wordpress.stackexchange.com/questions/280792",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121694/"
] | I'm trying to search only by a custom post type in Wordpress.
In my search form I have:
```
<input type="hidden" name="post_type" value="customposttype" />
```
In my functions file I have:
```
function template_chooser($template)
{
global $wp_query;
$post_type = get_query_var('post_type');
if... | try to add the action in the formdata :
```
var formData=new FormData(document.getElementById('landlordregform'));
formData.append("action", "custom_landlord_registration_process");
jQuery.ajax({
url: jQuery("#cusajaxurl").val(),
type: 'POST',
data: fo... |
280,796 | <p>I would like to apply special styling to the menu items of pages that are children of child pages. Is there a way to do this?</p>
| [
{
"answer_id": 280798,
"author": "Elmar Anthony Furtado Tavares",
"author_id": 128314,
"author_profile": "https://wordpress.stackexchange.com/users/128314",
"pm_score": 1,
"selected": false,
"text": "<p>You can target your elements with jQuery using these methods:</p>\n\n<p><strong>child... | 2017/09/22 | [
"https://wordpress.stackexchange.com/questions/280796",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/118284/"
] | I would like to apply special styling to the menu items of pages that are children of child pages. Is there a way to do this? | Add this `CSS` rule to your stylesheet:
```
ul.menu ul.sub-menu ul.sub-menu li{
//special styling here
}
```
its the default `CSS` classnaming `WordPress` use for the menus, you can see how i add it here.
[](https://i.stack.imgur.com/vfxiK.png) |
280,797 | <p>Lets say i need to add custom radio fields ( company or person ) at the top of the form to the billing for. And if the visitor checks person they should pay 21% Tax and they select company that is localated in NL they also should pay 21% tax. Any other case they should be free of tax? Any ideas ?</p>
<p>This is wh... | [
{
"answer_id": 280798,
"author": "Elmar Anthony Furtado Tavares",
"author_id": 128314,
"author_profile": "https://wordpress.stackexchange.com/users/128314",
"pm_score": 1,
"selected": false,
"text": "<p>You can target your elements with jQuery using these methods:</p>\n\n<p><strong>child... | 2017/09/22 | [
"https://wordpress.stackexchange.com/questions/280797",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128373/"
] | Lets say i need to add custom radio fields ( company or person ) at the top of the form to the billing for. And if the visitor checks person they should pay 21% Tax and they select company that is localated in NL they also should pay 21% tax. Any other case they should be free of tax? Any ideas ?
This is what i've tri... | Add this `CSS` rule to your stylesheet:
```
ul.menu ul.sub-menu ul.sub-menu li{
//special styling here
}
```
its the default `CSS` classnaming `WordPress` use for the menus, you can see how i add it here.
[](https://i.stack.imgur.com/vfxiK.png) |
280,807 | <p>I'm trying to add a child theme on a website, I created the folder called mythemename-child, I created the style.css file with this information inside: </p>
<pre><code>/*
Theme Name: Mizrahi-child
Theme URI: http://www.templatemonster.com/wordpress-themes
Description: Your theme description.
Author: Matteo Sch... | [
{
"answer_id": 280798,
"author": "Elmar Anthony Furtado Tavares",
"author_id": 128314,
"author_profile": "https://wordpress.stackexchange.com/users/128314",
"pm_score": 1,
"selected": false,
"text": "<p>You can target your elements with jQuery using these methods:</p>\n\n<p><strong>child... | 2017/09/22 | [
"https://wordpress.stackexchange.com/questions/280807",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107597/"
] | I'm trying to add a child theme on a website, I created the folder called mythemename-child, I created the style.css file with this information inside:
```
/*
Theme Name: Mizrahi-child
Theme URI: http://www.templatemonster.com/wordpress-themes
Description: Your theme description.
Author: Matteo Schiatti
Author U... | Add this `CSS` rule to your stylesheet:
```
ul.menu ul.sub-menu ul.sub-menu li{
//special styling here
}
```
its the default `CSS` classnaming `WordPress` use for the menus, you can see how i add it here.
[](https://i.stack.imgur.com/vfxiK.png) |
280,811 | <p>I want to get next and previous posts based on a particular category slugs. For example, some posts might have the "sports" category while another has the "tech" category.</p>
<p>I was hoping to plug in a category slug into <code>get_adjacent_post</code> but it doesn't appear that it's working. It looks like it jus... | [
{
"answer_id": 280812,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>What you call \"slugs\" here is more appropriately called <em>terms</em>. It is a little confusing with native taxo... | 2017/09/22 | [
"https://wordpress.stackexchange.com/questions/280811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57849/"
] | I want to get next and previous posts based on a particular category slugs. For example, some posts might have the "sports" category while another has the "tech" category.
I was hoping to plug in a category slug into `get_adjacent_post` but it doesn't appear that it's working. It looks like it just wants use the slug ... | What you call "slugs" here is more appropriately called *terms*. It is a little confusing with native taxonomies because it turns into tautology: individual categories are *terms* of the category *taxonomy*.
So `sports` and `tech` are terms of native `category` taxonomy.
The function arguments operate on *taxonomy* l... |
280,825 | <pre><code>/home/<website>/public_html/wp-content/themes/basic/functions.php
</code></pre>
<p>At the very end of the file, I have included these 8 lines:</p>
<pre><code>// Add Shortcode
function custom_shortcode() {
return "Hello world.";
}
add_shortcode( 'test', 'custom_shortcode' );
</code></pre>
<p>Do... | [
{
"answer_id": 280812,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>What you call \"slugs\" here is more appropriately called <em>terms</em>. It is a little confusing with native taxo... | 2017/09/22 | [
"https://wordpress.stackexchange.com/questions/280825",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128333/"
] | ```
/home/<website>/public_html/wp-content/themes/basic/functions.php
```
At the very end of the file, I have included these 8 lines:
```
// Add Shortcode
function custom_shortcode() {
return "Hello world.";
}
add_shortcode( 'test', 'custom_shortcode' );
```
Doesn't work and I can't figure out why.
I am sel... | What you call "slugs" here is more appropriately called *terms*. It is a little confusing with native taxonomies because it turns into tautology: individual categories are *terms* of the category *taxonomy*.
So `sports` and `tech` are terms of native `category` taxonomy.
The function arguments operate on *taxonomy* l... |
280,836 | <p>I have many hundreds of post which start with 'Post' and then a hyphen - </p>
<p>Some of these post have some other unimportant text before it, usually post summaries. What comes after the hyphen is the body of the post that I want to retain.</p>
<p>My objective is to have a solution that (ideally) automatically f... | [
{
"answer_id": 280855,
"author": "CK MacLeod",
"author_id": 35923,
"author_profile": "https://wordpress.stackexchange.com/users/35923",
"pm_score": 1,
"selected": false,
"text": "<p>Note that this filter function, added to the theme functions.php file, will apply to all output that uses ... | 2017/09/22 | [
"https://wordpress.stackexchange.com/questions/280836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121633/"
] | I have many hundreds of post which start with 'Post' and then a hyphen -
Some of these post have some other unimportant text before it, usually post summaries. What comes after the hyphen is the body of the post that I want to retain.
My objective is to have a solution that (ideally) automatically finds 'Post' at th... | Note that this filter function, added to the theme functions.php file, will apply to all output that uses "the\_content" everywhere (all posts essentially) - so exercise or consider narrowing the scope.
For instance, you might want to limit it to the first 100 characters, or to posts before a certain date, or within a... |
280,845 | <p>Can we count the WordPress loop and store it in a variable?</p>
<pre><code><?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php $post_id = get_the_ID(); ?>
<?php get_template_part('content','home'); ?>
some code to be executed
<?php endwhile; ?>
<?php e... | [
{
"answer_id": 280847,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 3,
"selected": true,
"text": "<p><code>$wp_query->current_post</code> is the build-in loop counter, starting with 0 zero for the first post in... | 2017/09/23 | [
"https://wordpress.stackexchange.com/questions/280845",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105791/"
] | Can we count the WordPress loop and store it in a variable?
```
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php $post_id = get_the_ID(); ?>
<?php get_template_part('content','home'); ?>
some code to be executed
<?php endwhile; ?>
<?php endif; ?>
```
what I want is that for ev... | `$wp_query->current_post` is the build-in loop counter, starting with 0 zero for the first post in the loop.
so the line `some code to be executed` could translate to:
`<?php if( $wp_query->current_post > 0 && $wp_query->current_post % 5 == 0 ) { ?>
some code to be executed
<?php } ?>` |
280,857 | <p>I am trying to follow <a href="https://adactio.com/journal/8504" rel="nofollow noreferrer">this tutorial</a> that says i can make a server to send a file like style.css if the requested file is style.15458888.css with a rewrite rule to be put inside the htaccess file. </p>
<p>This Rule</p>
<pre><code>RewriteCond %... | [
{
"answer_id": 280847,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 3,
"selected": true,
"text": "<p><code>$wp_query->current_post</code> is the build-in loop counter, starting with 0 zero for the first post in... | 2017/09/23 | [
"https://wordpress.stackexchange.com/questions/280857",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102224/"
] | I am trying to follow [this tutorial](https://adactio.com/journal/8504) that says i can make a server to send a file like style.css if the requested file is style.15458888.css with a rewrite rule to be put inside the htaccess file.
This Rule
```
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+).(d+).(js|css)$ $1... | `$wp_query->current_post` is the build-in loop counter, starting with 0 zero for the first post in the loop.
so the line `some code to be executed` could translate to:
`<?php if( $wp_query->current_post > 0 && $wp_query->current_post % 5 == 0 ) { ?>
some code to be executed
<?php } ?>` |
280,868 | <p>I am willing to migrate a new website to the customer server to replace its old one.
The old customer website used to be a single website (no network). I want to replace it with a network so as to be able to have one site in French, and another in English.</p>
<p>I would like it to use subfolders. So that :</p>
<b... | [
{
"answer_id": 280847,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 3,
"selected": true,
"text": "<p><code>$wp_query->current_post</code> is the build-in loop counter, starting with 0 zero for the first post in... | 2017/09/23 | [
"https://wordpress.stackexchange.com/questions/280868",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128403/"
] | I am willing to migrate a new website to the customer server to replace its old one.
The old customer website used to be a single website (no network). I want to replace it with a network so as to be able to have one site in French, and another in English.
I would like it to use subfolders. So that :
>
> idakt.com -... | `$wp_query->current_post` is the build-in loop counter, starting with 0 zero for the first post in the loop.
so the line `some code to be executed` could translate to:
`<?php if( $wp_query->current_post > 0 && $wp_query->current_post % 5 == 0 ) { ?>
some code to be executed
<?php } ?>` |
280,871 | <p>I'm running a WP multisite using subdomains. I would like to force SSL protocol for all requests and am running into an issue for non-SSL requests on my child sites. I'm using the <a href="https://wordpress.org/plugins/wp-force-ssl/" rel="nofollow noreferrer">WP Force SSL</a> plugin. I've done a bit of digging aroun... | [
{
"answer_id": 280896,
"author": "SEO DEVS",
"author_id": 111163,
"author_profile": "https://wordpress.stackexchange.com/users/111163",
"pm_score": 0,
"selected": false,
"text": "<p>Because this is classed as 2 different domains, it will need to be done in 2 parts. Try this:</p>\n\n<pre... | 2017/09/23 | [
"https://wordpress.stackexchange.com/questions/280871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47880/"
] | I'm running a WP multisite using subdomains. I would like to force SSL protocol for all requests and am running into an issue for non-SSL requests on my child sites. I'm using the [WP Force SSL](https://wordpress.org/plugins/wp-force-ssl/) plugin. I've done a bit of digging around and tried the following .htaccess dire... | From the description of the error you get, it seems like you do not get at all to your account related software when trying to access the child on http. This sounds like a web server configuration error, so in your case you need to make sure that in your cpanel you enabled subdomains for http and not only https |
280,897 | <p>This is my first experience with WordPress multisite and i followed all instructions from codex to make my website a multisite.<br>
But my sub domains are not working and chrome is displaying this message for my sub domains.<br>
DNS address could not be found.<br>
Do i have to create sub domain all the time in my cp... | [
{
"answer_id": 280898,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>Do I have to create sub domain all the time in my cpanel before creating new website (sub domain... | 2017/09/23 | [
"https://wordpress.stackexchange.com/questions/280897",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/120693/"
] | This is my first experience with WordPress multisite and i followed all instructions from codex to make my website a multisite.
But my sub domains are not working and chrome is displaying this message for my sub domains.
DNS address could not be found.
Do i have to create sub domain all the time in my cpanel b... | >
> Do I have to create sub domain all the time in my cpanel before creating new website (sub domain) in WordPress?
>
>
>
You need to make sure that the subdomains are created *somewhere*. WordPress doesn't have the capability to create DNS entries for you.
If you've got WordPress set up on `example.com` and you ... |
280,912 | <p>I found many requests made from Russia targeting the file admin-ajax.php, my server is not working right now.</p>
<p>I am sure that this traffic doesn't come from normal users but a robot.</p>
<p>How to avoid processing these queries to save resources ?</p>
<pre><code>5.188.203.23 - - [24/Sep/2017:02:18:36 +0200]... | [
{
"answer_id": 280919,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>Right now (version 4.8) there is no simple way to do it without crippling the admin.</p>\n\n<p>OTOH, proc... | 2017/09/24 | [
"https://wordpress.stackexchange.com/questions/280912",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121382/"
] | I found many requests made from Russia targeting the file admin-ajax.php, my server is not working right now.
I am sure that this traffic doesn't come from normal users but a robot.
How to avoid processing these queries to save resources ?
```
5.188.203.23 - - [24/Sep/2017:02:18:36 +0200] "POST /wp-admin/admin-ajax.... | You can use **.htaccess** to ban IP's that you don't want to access your website. If you are attacked from the same IP over the prolonged period of time, and with great frequency, banning the IP is the best solution.
Simples way to ban IP in **.htaccess** is (replace 123.123.123.123 with IP you want to ban):
```
Deny... |
280,931 | <p>I have a really weird issue. I use the Facebook Open Graph, Google+ and Twitter Card Tags plugin to create open graph tags for my wordpress pages. Normally this works smoothly. It takes the first image of a page and uses it as the <code>og:image</code> tag.</p>
<p>Example page: <a href="https://ungehorsam.org/progr... | [
{
"answer_id": 280919,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>Right now (version 4.8) there is no simple way to do it without crippling the admin.</p>\n\n<p>OTOH, proc... | 2017/09/24 | [
"https://wordpress.stackexchange.com/questions/280931",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26545/"
] | I have a really weird issue. I use the Facebook Open Graph, Google+ and Twitter Card Tags plugin to create open graph tags for my wordpress pages. Normally this works smoothly. It takes the first image of a page and uses it as the `og:image` tag.
Example page: <https://ungehorsam.org/programm/geschichten>
The created... | You can use **.htaccess** to ban IP's that you don't want to access your website. If you are attacked from the same IP over the prolonged period of time, and with great frequency, banning the IP is the best solution.
Simples way to ban IP in **.htaccess** is (replace 123.123.123.123 with IP you want to ban):
```
Deny... |
280,938 | <p>I want to add few settings fields dynamically on settings page depending on user action. I am planning to register these new fields dynamically once user asks for it and show the corresponding HTML using jQuery. Is it possible to register settings once you are already on settings page? Also, is there a better way to... | [
{
"answer_id": 280919,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>Right now (version 4.8) there is no simple way to do it without crippling the admin.</p>\n\n<p>OTOH, proc... | 2017/09/24 | [
"https://wordpress.stackexchange.com/questions/280938",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116770/"
] | I want to add few settings fields dynamically on settings page depending on user action. I am planning to register these new fields dynamically once user asks for it and show the corresponding HTML using jQuery. Is it possible to register settings once you are already on settings page? Also, is there a better way to do... | You can use **.htaccess** to ban IP's that you don't want to access your website. If you are attacked from the same IP over the prolonged period of time, and with great frequency, banning the IP is the best solution.
Simples way to ban IP in **.htaccess** is (replace 123.123.123.123 with IP you want to ban):
```
Deny... |
280,947 | <p>I'm trying to use the REST API v2 to populate a modal window when clicking on a project custom post type item.</p>
<p>Projects have a custom taxonomy, Skills. I'm using ?_embed on the JSON URL and it is returning the custom taxonomy items, but it's being limited to 10 terms for each returned Project item. I can't s... | [
{
"answer_id": 280919,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>Right now (version 4.8) there is no simple way to do it without crippling the admin.</p>\n\n<p>OTOH, proc... | 2017/09/24 | [
"https://wordpress.stackexchange.com/questions/280947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99012/"
] | I'm trying to use the REST API v2 to populate a modal window when clicking on a project custom post type item.
Projects have a custom taxonomy, Skills. I'm using ?\_embed on the JSON URL and it is returning the custom taxonomy items, but it's being limited to 10 terms for each returned Project item. I can't seem to do... | You can use **.htaccess** to ban IP's that you don't want to access your website. If you are attacked from the same IP over the prolonged period of time, and with great frequency, banning the IP is the best solution.
Simples way to ban IP in **.htaccess** is (replace 123.123.123.123 with IP you want to ban):
```
Deny... |
280,966 | <p>I'm using the Twenty Seventeen theme and my goal is to move the main menu (top nav) from its position under the header image to the very top of the page directly over the header image (transparent background), but there seems to be a lot of javascript in addition to css involved in positioning the menu and making it... | [
{
"answer_id": 282593,
"author": "Brian",
"author_id": 129437,
"author_profile": "https://wordpress.stackexchange.com/users/129437",
"pm_score": 0,
"selected": false,
"text": "<p>Try adding the following</p>\n\n<pre><code>.navigation-top {\n top: 14px;\n}\n</code></pre>\n\n<p>Should mov... | 2017/09/25 | [
"https://wordpress.stackexchange.com/questions/280966",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67759/"
] | I'm using the Twenty Seventeen theme and my goal is to move the main menu (top nav) from its position under the header image to the very top of the page directly over the header image (transparent background), but there seems to be a lot of javascript in addition to css involved in positioning the menu and making it st... | This is a two step solution:
1. Install plugin "Options for Twenty Seventeen" ([Link](https://wordpress.org/plugins/options-for-twenty-seventeen/))
2. Add the following CSS to "Design" > "Customizer" > "Additional CSS"
---
```
.navigation-top {
position: fixed;
bottom: auto;
left: 0;
right: 0;
to... |
280,981 | <p>I'm having quite a few problems with my WP settings. The main issue is that I need to have WP installed at //domain1.xxx/ and viewed at //domain2.xxx. It's not enough to change wp_home and wp_site_url to achieve this. Since I want to remove all trace of domain1 when viewing the site at domain2 I use relative paths (... | [
{
"answer_id": 282593,
"author": "Brian",
"author_id": 129437,
"author_profile": "https://wordpress.stackexchange.com/users/129437",
"pm_score": 0,
"selected": false,
"text": "<p>Try adding the following</p>\n\n<pre><code>.navigation-top {\n top: 14px;\n}\n</code></pre>\n\n<p>Should mov... | 2017/09/25 | [
"https://wordpress.stackexchange.com/questions/280981",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128466/"
] | I'm having quite a few problems with my WP settings. The main issue is that I need to have WP installed at //domain1.xxx/ and viewed at //domain2.xxx. It's not enough to change wp\_home and wp\_site\_url to achieve this. Since I want to remove all trace of domain1 when viewing the site at domain2 I use relative paths (... | This is a two step solution:
1. Install plugin "Options for Twenty Seventeen" ([Link](https://wordpress.org/plugins/options-for-twenty-seventeen/))
2. Add the following CSS to "Design" > "Customizer" > "Additional CSS"
---
```
.navigation-top {
position: fixed;
bottom: auto;
left: 0;
right: 0;
to... |
280,994 | <p>I'm trying to sort by custom meta data for posts. The custom meta is forum_order. The posts currently only display when the value is either minus or above 0. I would like the default to be 0 so unless the user sets it it will be displayed alphabetical. </p>
<pre><code>$forum_category_query = new WP_Query(
arra... | [
{
"answer_id": 280997,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 0,
"selected": false,
"text": "<p>try this to do a double sort.<br>\non <code>forum_order</code> first and by <code>title</code> if <code>forum_ord... | 2017/09/25 | [
"https://wordpress.stackexchange.com/questions/280994",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128475/"
] | I'm trying to sort by custom meta data for posts. The custom meta is forum\_order. The posts currently only display when the value is either minus or above 0. I would like the default to be 0 so unless the user sets it it will be displayed alphabetical.
```
$forum_category_query = new WP_Query(
array(
'... | SOLVED:
I had this in the function to save the meta data (like an idiot!!)
```
if ( !$value ) delete_post_meta( $post->ID, $key ); // Delete if blank
```
So it wasn't saving the meta value if set to 0.
I changed it to:
```
if ( !$value ) add_post_meta( $post->ID, $key, '0' ); // add 0 if blank
```
Simple to sol... |
280,995 | <p>In my Plugin, I have an object 'Settings' (to display stuff in Wordpress settings).</p>
<p><strong>Settings.php</strong></p>
<pre><code><?php
namespace FooNamespace\Admin\Settings;
class Settings {
public $menu_slug;
public function __construct(){
$this->menu_slug = 'settings-'.PLUGIN_DO... | [
{
"answer_id": 281003,
"author": "Akash K.",
"author_id": 124921,
"author_profile": "https://wordpress.stackexchange.com/users/124921",
"pm_score": 0,
"selected": false,
"text": "<p>I've had this problem in past</p>\n\n<p>try using <code>include</code> with <code>locate_template</code>:\... | 2017/09/25 | [
"https://wordpress.stackexchange.com/questions/280995",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128094/"
] | In my Plugin, I have an object 'Settings' (to display stuff in Wordpress settings).
**Settings.php**
```
<?php
namespace FooNamespace\Admin\Settings;
class Settings {
public $menu_slug;
public function __construct(){
$this->menu_slug = 'settings-'.PLUGIN_DOMAIN ;
// Initialize the compon... | I found the problem and I have the solution :
To include the child file, as I'm working on localhost I changed the path :
**My error :**
```
plugin_dir_path( __FILE__ ).'my-child-template.php' //<-- \path\to\file/my-child-template.php
//Changed by
plugin_dir_url( __FILE__ ).'my-child-template.php' //<-- http://lo... |
281,013 | <p>I have an issue that I can find how to setup vertical scroll-bars but not horizontal scrollbars.</p>
<p>A couple of demos are at:</p>
<p><a href="https://www.w3schools.com/TagS/tag_textarea.asp" rel="nofollow noreferrer">https://www.w3schools.com/TagS/tag_textarea.asp</a>
<a href="https://stackoverflow.com/questi... | [
{
"answer_id": 281003,
"author": "Akash K.",
"author_id": 124921,
"author_profile": "https://wordpress.stackexchange.com/users/124921",
"pm_score": 0,
"selected": false,
"text": "<p>I've had this problem in past</p>\n\n<p>try using <code>include</code> with <code>locate_template</code>:\... | 2017/09/25 | [
"https://wordpress.stackexchange.com/questions/281013",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126081/"
] | I have an issue that I can find how to setup vertical scroll-bars but not horizontal scrollbars.
A couple of demos are at:
<https://www.w3schools.com/TagS/tag_textarea.asp>
<https://stackoverflow.com/questions/19292559/how-to-scroll-text-area-horizontally>
I ran out of references. I am looking to have the box format... | I found the problem and I have the solution :
To include the child file, as I'm working on localhost I changed the path :
**My error :**
```
plugin_dir_path( __FILE__ ).'my-child-template.php' //<-- \path\to\file/my-child-template.php
//Changed by
plugin_dir_url( __FILE__ ).'my-child-template.php' //<-- http://lo... |
281,031 | <p>I want to add a dynamic page for every page that has URL subpage of "/team".</p>
<p>How would I configure "add_rewrite_rule" regex expression to allow me that?</p>
<p>Example:</p>
<pre><code>path: http://page.com/business/team
rewrite: http://page.com/index.php?department-team=business
path: http://page.com/hr/t... | [
{
"answer_id": 281032,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>add_rewrite_endpoint</code> instead, it generates the rules for you.</p>\n\n<pre><code>add_rewrite_endpo... | 2017/09/25 | [
"https://wordpress.stackexchange.com/questions/281031",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80191/"
] | I want to add a dynamic page for every page that has URL subpage of "/team".
How would I configure "add\_rewrite\_rule" regex expression to allow me that?
Example:
```
path: http://page.com/business/team
rewrite: http://page.com/index.php?department-team=business
path: http://page.com/hr/team
rewrite: http://page.c... | I do something similar. I have a page (country\_tc) that uses a custom page template that either dynamically generates info for requested country, or a series of sub-pages for the country e.g.
`/country/Egypt` (*index.php?pagename=country&countrytc=egypt*)
`/country/egypt/safety` (*index.php?pagename=country&countryt... |
281,058 | <p>in my web I have a button (.x-btn.widgetbar) that displays a section of widgets in the upper right as in this <a href="http://demo.theme.co/integrity-1/" rel="nofollow noreferrer">example</a>.</p>
<p>I have modified the icon to change based on whether the user is registered or not, I would like that when the user i... | [
{
"answer_id": 281063,
"author": "IBRAHIM EZZAT",
"author_id": 120259,
"author_profile": "https://wordpress.stackexchange.com/users/120259",
"pm_score": 2,
"selected": true,
"text": "<p>when you want interaction between client side and server side you should use ajax .</p>\n\n<p>i think ... | 2017/09/25 | [
"https://wordpress.stackexchange.com/questions/281058",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128506/"
] | in my web I have a button (.x-btn.widgetbar) that displays a section of widgets in the upper right as in this [example](http://demo.theme.co/integrity-1/).
I have modified the icon to change based on whether the user is registered or not, I would like that when the user is not logged in redirect to a login page instea... | when you want interaction between client side and server side you should use ajax .
i think this [Link](https://wordpress.stackexchange.com/questions/69814/check-if-user-is-logged-in-using-jquery) will be very helpful to you :)
Put this in your javascript
```
var data = {
action: 'is_user_logged_in'
};
jquery.('.... |
281,068 | <pre><code>wp_register_script( $handle, $src, $deps, $ver, $in_footer );
</code></pre>
<p>If <code>$ver</code> is not required then should we leave that space blank? or completely remove the commas?</p>
<p>Example →</p>
<pre><code>wp_register_script( 'scroll', get_template_directory_uri() . '/js/infinite-scroll.pkgd... | [
{
"answer_id": 281069,
"author": "David Lee",
"author_id": 111965,
"author_profile": "https://wordpress.stackexchange.com/users/111965",
"pm_score": 0,
"selected": false,
"text": "<p>you cant leave it empty, at least you have to put an empty string <code>''</code>, it will default the de... | 2017/09/26 | [
"https://wordpress.stackexchange.com/questions/281068",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105791/"
] | ```
wp_register_script( $handle, $src, $deps, $ver, $in_footer );
```
If `$ver` is not required then should we leave that space blank? or completely remove the commas?
Example →
```
wp_register_script( 'scroll', get_template_directory_uri() . '/js/infinite-scroll.pkgd.min.js', array( 'jquery' ), '1.1', true );
```... | Simply pass in `null` or the empty equivalent.
For example, if you don't depend on anything, say so. It's expecting an array of the dependencies, so pass an empty array `array()`
Or pass in `null` |
281,081 | <p>Contributors loses the ability to edit their posts after one admin approves their post. </p>
<p>I'd like to know how can I add the capability of them to edit their posts, even after admin approval or admin edit. I don't want to use any plugin for that..</p>
<p><a href="https://i.stack.imgur.com/vlq7L.jpg" rel="nof... | [
{
"answer_id": 281082,
"author": "Piyush Rawat",
"author_id": 73600,
"author_profile": "https://wordpress.stackexchange.com/users/73600",
"pm_score": 0,
"selected": false,
"text": "<p>Author role provides this functionality by default.\nElse you can use any user role editor plugin to cus... | 2017/09/26 | [
"https://wordpress.stackexchange.com/questions/281081",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102182/"
] | Contributors loses the ability to edit their posts after one admin approves their post.
I'd like to know how can I add the capability of them to edit their posts, even after admin approval or admin edit. I don't want to use any plugin for that..
[](... | You need to add a the `edit_published_posts` capability for the `contributor` role in the `functions.php`
```
add_filter('init', function () {
$role = get_role('contributor');
$role->add_cap('edit_published_posts');
});
``` |
281,088 | <p>I have been trying but its not working.</p>
<p>but if i try </p>
<pre><code><?php echo do_shortcode("[mimo]"); ?> <?php echo do_shortcode("[mibaby]"); ?>
</code></pre>
<p>it will work fine.</p>
<p>But to apply it in post content using <code>[mimo] [mibaby]</code></p>
<p>it won't work.</p>
<p>Here i... | [
{
"answer_id": 281082,
"author": "Piyush Rawat",
"author_id": 73600,
"author_profile": "https://wordpress.stackexchange.com/users/73600",
"pm_score": 0,
"selected": false,
"text": "<p>Author role provides this functionality by default.\nElse you can use any user role editor plugin to cus... | 2017/09/26 | [
"https://wordpress.stackexchange.com/questions/281088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128516/"
] | I have been trying but its not working.
but if i try
```
<?php echo do_shortcode("[mimo]"); ?> <?php echo do_shortcode("[mibaby]"); ?>
```
it will work fine.
But to apply it in post content using `[mimo] [mibaby]`
it won't work.
Here is the Functions i am using...
```
function wpb_custom_new_menuw() {
remove... | You need to add a the `edit_published_posts` capability for the `contributor` role in the `functions.php`
```
add_filter('init', function () {
$role = get_role('contributor');
$role->add_cap('edit_published_posts');
});
``` |
281,093 | <p>I would like to have my index or <a href="https://publiqly.com/blog/" rel="nofollow noreferrer">posts overview page</a> load each post teaser starting at char 206 of each post's body content. This as all posts start with a general introduction in the post body content that is the same. To load that on the index.php ... | [
{
"answer_id": 281082,
"author": "Piyush Rawat",
"author_id": 73600,
"author_profile": "https://wordpress.stackexchange.com/users/73600",
"pm_score": 0,
"selected": false,
"text": "<p>Author role provides this functionality by default.\nElse you can use any user role editor plugin to cus... | 2017/09/26 | [
"https://wordpress.stackexchange.com/questions/281093",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12260/"
] | I would like to have my index or [posts overview page](https://publiqly.com/blog/) load each post teaser starting at char 206 of each post's body content. This as all posts start with a general introduction in the post body content that is the same. To load that on the index.php teaser is useless information.
With `g... | You need to add a the `edit_published_posts` capability for the `contributor` role in the `functions.php`
```
add_filter('init', function () {
$role = get_role('contributor');
$role->add_cap('edit_published_posts');
});
``` |
281,102 | <p>I am using the default WordPress embed to embed a couple of videos in the content. </p>
<p>I want to extract the video link from <code>[embed]https://www.youtube.com/watch?v=Z9QbYZh1YXY[/embed]</code>, can anyone help with the regex?</p>
| [
{
"answer_id": 281082,
"author": "Piyush Rawat",
"author_id": 73600,
"author_profile": "https://wordpress.stackexchange.com/users/73600",
"pm_score": 0,
"selected": false,
"text": "<p>Author role provides this functionality by default.\nElse you can use any user role editor plugin to cus... | 2017/09/26 | [
"https://wordpress.stackexchange.com/questions/281102",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am using the default WordPress embed to embed a couple of videos in the content.
I want to extract the video link from `[embed]https://www.youtube.com/watch?v=Z9QbYZh1YXY[/embed]`, can anyone help with the regex? | You need to add a the `edit_published_posts` capability for the `contributor` role in the `functions.php`
```
add_filter('init', function () {
$role = get_role('contributor');
$role->add_cap('edit_published_posts');
});
``` |
281,127 | <p>Here I created a custom profile page based on the current logged user to check only his own data inserted in a custom database.</p>
<p>You can see that in every row, I added a button "Delete" missing the appropriate code.</p>
<p>Everything is working well except that part where I want to add a function to Delete t... | [
{
"answer_id": 281150,
"author": "IBRAHIM EZZAT",
"author_id": 120259,
"author_profile": "https://wordpress.stackexchange.com/users/120259",
"pm_score": 0,
"selected": false,
"text": "<ul>\n<li><p>client side -> user click delete button/link</p></li>\n<li><p>AJAX ->send this action from ... | 2017/09/26 | [
"https://wordpress.stackexchange.com/questions/281127",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126576/"
] | Here I created a custom profile page based on the current logged user to check only his own data inserted in a custom database.
You can see that in every row, I added a button "Delete" missing the appropriate code.
Everything is working well except that part where I want to add a function to Delete the record. Maybe ... | Yes, you can use wpdb to delete the record in the custom table. Something like this in the wordpress function.
```
require_once ('../../../../wp-load.php');
if (!empty($_POST['id'])) {
global $wpdb;
$table='table_name';
$id = $_POST['id'];
$wpdb->delete( $table, array( 'id' => $id ) );
}
``` |
281,134 | <p>I am using a customised archive template for a custom post type.</p>
<p>At the top of the page, I'd like to show a specific post, found using a new <code>wp_query()</code> call.</p>
<pre><code>$args = [
'posts_per_page' => 1,
'post_type' => 'document',
'order' => 'DESC',
'orderby' => 'd... | [
{
"answer_id": 281150,
"author": "IBRAHIM EZZAT",
"author_id": 120259,
"author_profile": "https://wordpress.stackexchange.com/users/120259",
"pm_score": 0,
"selected": false,
"text": "<ul>\n<li><p>client side -> user click delete button/link</p></li>\n<li><p>AJAX ->send this action from ... | 2017/09/26 | [
"https://wordpress.stackexchange.com/questions/281134",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127925/"
] | I am using a customised archive template for a custom post type.
At the top of the page, I'd like to show a specific post, found using a new `wp_query()` call.
```
$args = [
'posts_per_page' => 1,
'post_type' => 'document',
'order' => 'DESC',
'orderby' => 'date',
];
$query = new WP_Query( $args );
if ... | Yes, you can use wpdb to delete the record in the custom table. Something like this in the wordpress function.
```
require_once ('../../../../wp-load.php');
if (!empty($_POST['id'])) {
global $wpdb;
$table='table_name';
$id = $_POST['id'];
$wpdb->delete( $table, array( 'id' => $id ) );
}
``` |
281,140 | <p>I already tried in several ways to remove the last slash of the url that I created with <code>add_rewrite_rule</code>.</p>
<p>below is the implementation of my code</p>
<pre><code>function master_load_ads_txt_template_include($template) {
$is_load_ads_txt = (bool)get_query_var('ads-txt');
if( $is_load_ads_txt ... | [
{
"answer_id": 281815,
"author": "Elton Peetz",
"author_id": 128979,
"author_profile": "https://wordpress.stackexchange.com/users/128979",
"pm_score": 0,
"selected": false,
"text": "<pre><code>/* ORIGINAL CODE */\nfunction master_load_ads_txt_template_include($template) {\n $is_load_a... | 2017/09/26 | [
"https://wordpress.stackexchange.com/questions/281140",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128543/"
] | I already tried in several ways to remove the last slash of the url that I created with `add_rewrite_rule`.
below is the implementation of my code
```
function master_load_ads_txt_template_include($template) {
$is_load_ads_txt = (bool)get_query_var('ads-txt');
if( $is_load_ads_txt ) {
$template = get_template... | Replace all your above code with the one below:
```
<?php
function master_load_ads_txt_template_include( $template ) {
$is_load_ads_txt = (bool) get_query_var( 'ads-txt' );
if ( $is_load_ads_txt ) {
$template = locate_template( 'template-parts/ads-txt.php' );
}
return $template;
}
add_filte... |
281,157 | <p>I'm not entirely sure where I can even ask this question as it pertains to both HTML and WP.</p>
<p>Anyways, our old intranet solution basically held a bunch of .htm documents that we made in Word and then turned into .htm.</p>
<p>We have switched to a WP solution and have begun uploading these .htm docs as media ... | [
{
"answer_id": 281815,
"author": "Elton Peetz",
"author_id": 128979,
"author_profile": "https://wordpress.stackexchange.com/users/128979",
"pm_score": 0,
"selected": false,
"text": "<pre><code>/* ORIGINAL CODE */\nfunction master_load_ads_txt_template_include($template) {\n $is_load_a... | 2017/09/26 | [
"https://wordpress.stackexchange.com/questions/281157",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128554/"
] | I'm not entirely sure where I can even ask this question as it pertains to both HTML and WP.
Anyways, our old intranet solution basically held a bunch of .htm documents that we made in Word and then turned into .htm.
We have switched to a WP solution and have begun uploading these .htm docs as media as it is the easi... | Replace all your above code with the one below:
```
<?php
function master_load_ads_txt_template_include( $template ) {
$is_load_ads_txt = (bool) get_query_var( 'ads-txt' );
if ( $is_load_ads_txt ) {
$template = locate_template( 'template-parts/ads-txt.php' );
}
return $template;
}
add_filte... |
281,182 | <p>Inside my loop, I'm trying to have a link show and it won't I'm not sure why</p>
<p>Here is the code:</p>
<pre><code><?php the_title('<h2 class="wow"><a href="<?php the_permalink(); ?>"', '</a></h2>'); ?>
</code></pre>
<p>I understand this is maybe because of the <code>''</code> q... | [
{
"answer_id": 281186,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": false,
"text": "<p>You can't nest these functions. Change your code to</p>\n\n<pre><code><h2 class=\"wow\"><a href=... | 2017/09/26 | [
"https://wordpress.stackexchange.com/questions/281182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83544/"
] | Inside my loop, I'm trying to have a link show and it won't I'm not sure why
Here is the code:
```
<?php the_title('<h2 class="wow"><a href="<?php the_permalink(); ?>"', '</a></h2>'); ?>
```
I understand this is maybe because of the `''` quotations instead of `""`, but how would I achieve this general thing with ju... | because `the_title()` expects a string for the `$before` and `$after` args, you need to use the string version of the permalink, in a string concatenation;
`<?php the_title('<h2 class="wow"><a href="'.get_permalink().'">', '</a></h2>'); ?>`
you also had a missing `>`.
<https://developer.wordpress.org/reference/funct... |