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 |
|---|---|---|---|---|---|---|
152,658 | <p>I want to show what scripts and styles have loaded on a page and which plugin / theme / file has added them to the page.</p>
<p>We can show all scripts and styles using:</p>
<pre><code><?php
global $wp_scripts, $wp_styles;
var_dump( $wp_scripts );
var_dump( $wp_styles );
?>
</code></pre>
<p>Or more el... | [
{
"answer_id": 152661,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 4,
"selected": true,
"text": "<p>This is not possible the way you think. It <em>would maybe</em> be possible if you use <a href=\"http://www.php.net... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152658",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38077/"
] | I want to show what scripts and styles have loaded on a page and which plugin / theme / file has added them to the page.
We can show all scripts and styles using:
```
<?php
global $wp_scripts, $wp_styles;
var_dump( $wp_scripts );
var_dump( $wp_styles );
?>
```
Or more elegantly using this answer: [How do I ge... | This is not possible the way you think. It *would maybe* be possible if you use [Reflections](http://www.php.net/manual/en/book.reflection.php) or [`debug_backtrace()`](http://www.php.net/manual/en/function.debug-backtrace.php), but there's no reliable way to do this. WordPress does not keep a stack or queue where it t... |
152,666 | <p>I have some questions about the loop. I'm using "twentyfourteen" theme as an example.
I'm creating 2 php files with basic loop. One is home.php, and one is a template page called sample-page.php . Both contains this code;</p>
<pre><code>if( have_posts() ) :
while( have_posts() ) : the_post();
the_conten... | [
{
"answer_id": 152671,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>Why is it that 2, identical php file produce different results? In my example, the \"sample-page.ph... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152666",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54895/"
] | I have some questions about the loop. I'm using "twentyfourteen" theme as an example.
I'm creating 2 php files with basic loop. One is home.php, and one is a template page called sample-page.php . Both contains this code;
```
if( have_posts() ) :
while( have_posts() ) : the_post();
the_content;
endwhil... | This quite a broad question to answer. I'm not going to go into detail here and into core code, you'll need to go and read the links I'm going to provide. I'm going to try to keep my answer sweet and short and useful :-)
Take the bundled theme twentyfourteen for example, when you open any page template, you'll find th... |
152,675 | <p>I am using the Hueman Theme. What I want to do is that the background of all the posts should change according to the category of the post.</p>
<p>Please suggest something</p>
| [
{
"answer_id": 152679,
"author": "rellampec",
"author_id": 55124,
"author_profile": "https://wordpress.stackexchange.com/users/55124",
"pm_score": 1,
"selected": false,
"text": "<p>I do not know this theme. But you must use this two functions somewhere:</p>\n\n<pre><code> get_theme_mod (... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55138/"
] | I am using the Hueman Theme. What I want to do is that the background of all the posts should change according to the category of the post.
Please suggest something | I do not know this theme. But you must use this two functions somewhere:
```
get_theme_mod ('background_image', $default);
set_theme_mod ('background_image', $_category_image_absolute_path);
```
Maybe, you can define new modification names with this functions. For example, 'backgroud\_image\_entertainment', 'backg... |
152,677 | <p>Im trying to do something with an admin_init hook if - and only if - the user is editing a post (post.php) with post type "event". My problem is that, even though wordpress points to a global variable calls $post_type. if i do:</p>
<pre><code>global $post_type;
var_dump($post_type);
</code></pre>
<p>It returns NUL... | [
{
"answer_id": 152681,
"author": "Alessandro Benoit",
"author_id": 16637,
"author_profile": "https://wordpress.stackexchange.com/users/16637",
"pm_score": 6,
"selected": true,
"text": "<pre><code>add_action( 'admin_init', 'do_something_152677' );\nfunction do_something_152677 () {\n /... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38440/"
] | Im trying to do something with an admin\_init hook if - and only if - the user is editing a post (post.php) with post type "event". My problem is that, even though wordpress points to a global variable calls $post\_type. if i do:
```
global $post_type;
var_dump($post_type);
```
It returns NULL.
but if I do this:
... | ```
add_action( 'admin_init', 'do_something_152677' );
function do_something_152677 () {
// Global object containing current admin page
global $pagenow;
// If current page is post.php and post isset than query for its post type
// if the post type is 'event' do something
if ( 'post.php' === $pagen... |
152,680 | <p>I have created a plugin in wordpress. I am making a cURL request to the server and server response is coming to new index.php. Which is in my_plugin/newfolder/newfolder/index.php.</p>
<p>Now from the server side it post the response to my_plugin/newfolder/newfolder/ but it makes problem to other workflows in my app... | [
{
"answer_id": 152681,
"author": "Alessandro Benoit",
"author_id": 16637,
"author_profile": "https://wordpress.stackexchange.com/users/16637",
"pm_score": 6,
"selected": true,
"text": "<pre><code>add_action( 'admin_init', 'do_something_152677' );\nfunction do_something_152677 () {\n /... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152680",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54898/"
] | I have created a plugin in wordpress. I am making a cURL request to the server and server response is coming to new index.php. Which is in my\_plugin/newfolder/newfolder/index.php.
Now from the server side it post the response to my\_plugin/newfolder/newfolder/ but it makes problem to other workflows in my application... | ```
add_action( 'admin_init', 'do_something_152677' );
function do_something_152677 () {
// Global object containing current admin page
global $pagenow;
// If current page is post.php and post isset than query for its post type
// if the post type is 'event' do something
if ( 'post.php' === $pagen... |
152,689 | <p>For security reasons I need to block access to scripts that will not be executed on a fresh WordPress installation.</p>
<p>Example:</p>
<ul>
<li>/index.php --> needs to be executable</li>
<li>/wp-includes/cache.php --> should not be executed (it's included in other files)</li>
</ul>
<p>Anyone has information on w... | [
{
"answer_id": 152694,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>The WordPress file / folder permissions should be as following.</p>\n\n<p>For Directories: 755</p>\n\n<p>... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152689",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31140/"
] | For security reasons I need to block access to scripts that will not be executed on a fresh WordPress installation.
Example:
* /index.php --> needs to be executable
* /wp-includes/cache.php --> should not be executed (it's included in other files)
Anyone has information on which files are **included** and which actu... | Due to WP admin architecture this would be *really* inconvenient list to compile and maintain reliably.
My best educated guess is that many (but possibly not all and not just) of these files would need to require admin bootstrap (`wp-admin/admin.php`) to function.
I ran a quick search on respective directive with fol... |
152,695 | <p>I have three loops I want to stop them from displaying the same posts in each one.</p>
<p>any help would be greatly appreciated</p>
<pre><code><?php
$i;
$args = array( 'numberposts' => 8);
$posts= get_posts( $args );
if ($posts) {
foreach ( $posts as $i => $post )
{
setup_postdata($po... | [
{
"answer_id": 152694,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 0,
"selected": false,
"text": "<p>The WordPress file / folder permissions should be as following.</p>\n\n<p>For Directories: 755</p>\n\n<p>... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152695",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44408/"
] | I have three loops I want to stop them from displaying the same posts in each one.
any help would be greatly appreciated
```
<?php
$i;
$args = array( 'numberposts' => 8);
$posts= get_posts( $args );
if ($posts) {
foreach ( $posts as $i => $post )
{
setup_postdata($post);
}
}
?>
<div class="i... | Due to WP admin architecture this would be *really* inconvenient list to compile and maintain reliably.
My best educated guess is that many (but possibly not all and not just) of these files would need to require admin bootstrap (`wp-admin/admin.php`) to function.
I ran a quick search on respective directive with fol... |
152,703 | <p>How to show featured image (medium sized) relative URL (relative to the website root)?</p>
<p>I need something like this: <code>uploads/214/07/image-600x400.png</code></p>
<p>I tried with this:</p>
<pre><code>if ( has_post_thumbnail()) {
$medium_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($... | [
{
"answer_id": 152708,
"author": "jack",
"author_id": 55148,
"author_profile": "https://wordpress.stackexchange.com/users/55148",
"pm_score": 3,
"selected": true,
"text": "<p>You're on the right track with your first snippet - from there it's easy to remove parts of the url: check what W... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152703",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25053/"
] | How to show featured image (medium sized) relative URL (relative to the website root)?
I need something like this: `uploads/214/07/image-600x400.png`
I tried with this:
```
if ( has_post_thumbnail()) {
$medium_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium');
echo $medium_... | You're on the right track with your first snippet - from there it's easy to remove parts of the url: check what WP has stored as the site root, then use php's string functions to snip that part out of your image url.
```
// inside the post loop, in a template file
if ( has_post_thumbnail()) {
$medium_image_url = wp_... |
152,710 | <p>I made a basic ajax request to 2 variables. I want the values to be sent and manipulated in the back-end in order to use them in a database query. All that should happen on page load. My main.js code:</p>
<p>main.js file</p>
<pre><code>var lat = 21.458965;
var lng = -11.336985;
jQuery.ajax({
type:"POST",... | [
{
"answer_id": 152714,
"author": "Will",
"author_id": 17940,
"author_profile": "https://wordpress.stackexchange.com/users/17940",
"pm_score": 0,
"selected": false,
"text": "<p>when form (or other) data is submitted via AJAX, it can be accessed via the <code>$_POST</code> or <code>$_GET</... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152710",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55149/"
] | I made a basic ajax request to 2 variables. I want the values to be sent and manipulated in the back-end in order to use them in a database query. All that should happen on page load. My main.js code:
main.js file
```
var lat = 21.458965;
var lng = -11.336985;
jQuery.ajax({
type:"POST",
url: ajaxu... | Yes you should use `die();` in ajax function call, but because you're not returning data and don't care what is returned it's not necessary
You should be using nonce, it's good practice to get used to always using it regardless of the situation.
<http://codex.wordpress.org/WordPress_Nonces>
<http://codex.wordpress.or... |
152,713 | <p>I had this code working as I needed it to...but now I need to add a post count where the "<strong>____</strong>" is, beside "posters", so I can manipulate the css depending on how many posters are showing, for example: <code><div id="posters1"></code> or <code><div id="posters2"></code> or <code><div ... | [
{
"answer_id": 152715,
"author": "MEDZ",
"author_id": 55149,
"author_profile": "https://wordpress.stackexchange.com/users/55149",
"pm_score": 0,
"selected": false,
"text": "<p>Before your you have to create a new query then count the results:</p>\n\n<pre><code>global $wpdb;\n$count = $w... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152713",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40679/"
] | I had this code working as I needed it to...but now I need to add a post count where the "**\_\_\_\_**" is, beside "posters", so I can manipulate the css depending on how many posters are showing, for example: `<div id="posters1">` or `<div id="posters2">` or `<div id="posters3">`, etc.
I believe this can be done with... | rearrange your code and use `post_count`;
example:
```
<?php
$movieNumber = 1;
$today = date('Ymd');
$posts = array (
'post_type' => 'movie',
'posts_per_page' => -1,
);
$loop = new WP_Query( $posts ); ?>
<div id="posters<?php echo $loop->post_c... |
152,719 | <p>I am trying to use an existing shortcode for an accordion element in a custom template for my wordpress site. Basically, I need to insert PHP arrays inside this shortcode, like so:</p>
<pre><code><php do_shortcode('[vc_accordion]';>
PHP arrays here
<php do_shortcode('[/vc_accordion]';>
</code></pre>
... | [
{
"answer_id": 152721,
"author": "HamedPC",
"author_id": 55155,
"author_profile": "https://wordpress.stackexchange.com/users/55155",
"pm_score": -1,
"selected": false,
"text": "<p>This is Correct Format: </p>\n\n<pre><code><?php echo do_shortcode( $content ) ?>\n</code></pre>\n\n<p... | 2014/07/04 | [
"https://wordpress.stackexchange.com/questions/152719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55156/"
] | I am trying to use an existing shortcode for an accordion element in a custom template for my wordpress site. Basically, I need to insert PHP arrays inside this shortcode, like so:
```
<php do_shortcode('[vc_accordion]';>
PHP arrays here
<php do_shortcode('[/vc_accordion]';>
```
Does anyone know if a solution? | This is the code I would use:
```
$open_shortcode = '[vc_accordion]';
$shortcode_data = '';
$close_shortcode = '[/vc_accordion]';
$myarray = array(
'tabs' =>
array(
'title' => 'Section 1',
'content' => 'Any text here'
),
array(
'title' => 'Section 2',
... |
152,755 | <p>I am trying to add a wp rewrite for my plugin that allows users to include a shortcode on a page that will then display a calendar. This calendar then requires url params in order to navigate the dates. All this is working fine without issues...it is now getting it to work if a user includes the shortcode on a page ... | [
{
"answer_id": 152721,
"author": "HamedPC",
"author_id": 55155,
"author_profile": "https://wordpress.stackexchange.com/users/55155",
"pm_score": -1,
"selected": false,
"text": "<p>This is Correct Format: </p>\n\n<pre><code><?php echo do_shortcode( $content ) ?>\n</code></pre>\n\n<p... | 2014/07/05 | [
"https://wordpress.stackexchange.com/questions/152755",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38434/"
] | I am trying to add a wp rewrite for my plugin that allows users to include a shortcode on a page that will then display a calendar. This calendar then requires url params in order to navigate the dates. All this is working fine without issues...it is now getting it to work if a user includes the shortcode on a page tha... | This is the code I would use:
```
$open_shortcode = '[vc_accordion]';
$shortcode_data = '';
$close_shortcode = '[/vc_accordion]';
$myarray = array(
'tabs' =>
array(
'title' => 'Section 1',
'content' => 'Any text here'
),
array(
'title' => 'Section 2',
... |
152,768 | <p>In which database table and column do I need to insert an image path, in order to display product images in wp-admin (not on the front end)? I insert products by query in WordPress, rather than insert products by admin. </p>
<pre><code>$insert = $wpdb->insert( $prefix."posts", array(
"post_title" => $po... | [
{
"answer_id": 152778,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>While this is theoretically possible it is going to be <em>very</em> unpleasant to get right.</p>\n\n<p>The \"image... | 2014/07/05 | [
"https://wordpress.stackexchange.com/questions/152768",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/46005/"
] | In which database table and column do I need to insert an image path, in order to display product images in wp-admin (not on the front end)? I insert products by query in WordPress, rather than insert products by admin.
```
$insert = $wpdb->insert( $prefix."posts", array(
"post_title" => $posTitle,
"post_co... | While this is theoretically possible it is going to be *very* unpleasant to get right.
The "image" in WordPress view would be attachment post with considerable amount of metadata, recording information about physical file for image itself, image sizes, EXIF info from image, and so on.
You should really be using API f... |
152,786 | <p>I am creating a coupon site from scratch. I have reviewed many code examples on the Internet, but have not found anything that will work, as my requirements are little different.</p>
<p>I need help in creating an expiry function that would delete the "coupon" (post_type) automatically.</p>
<p>As a coupon site, all... | [
{
"answer_id": 152805,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 4,
"selected": true,
"text": "<p>I did something similar a while ago. I'm not sure deleting a post is a good solution, maybe you can change only... | 2014/07/06 | [
"https://wordpress.stackexchange.com/questions/152786",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34354/"
] | I am creating a coupon site from scratch. I have reviewed many code examples on the Internet, but have not found anything that will work, as my requirements are little different.
I need help in creating an expiry function that would delete the "coupon" (post\_type) automatically.
As a coupon site, all coupons are imp... | I did something similar a while ago. I'm not sure deleting a post is a good solution, maybe you can change only the post status to a custom one called Expired for example. But for an example, the code below will delete the post.
First create a daily cron job:
```
add_action( 'wp', 'delete_expired_coupons_daily' );
fu... |
152,793 | <p>I want to display a select box to switch to SUBCATEGORIES of the current CATEGORY when i'm on a category page.</p>
<p>I've the following category structure </p>
<pre><code>Category 1
Subcategory 1
Subcategory 2
Subcategory 3
Category 2
Subcategory 1
Subcategory 2
</code></pre>
<p>I've created ... | [
{
"answer_id": 152795,
"author": "deflime",
"author_id": 18907,
"author_profile": "https://wordpress.stackexchange.com/users/18907",
"pm_score": 2,
"selected": true,
"text": "<p>If you are referring to the categories from the post type <code>post</code> (the blog) then this would do the ... | 2014/07/06 | [
"https://wordpress.stackexchange.com/questions/152793",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54764/"
] | I want to display a select box to switch to SUBCATEGORIES of the current CATEGORY when i'm on a category page.
I've the following category structure
```
Category 1
Subcategory 1
Subcategory 2
Subcategory 3
Category 2
Subcategory 1
Subcategory 2
```
I've created a custom template using the categ... | If you are referring to the categories from the post type `post` (the blog) then this would do the trick:
For a drop-down: [wp\_dropdown\_categories()](http://codex.wordpress.org/Function_Reference/wp_dropdown_categories)
For a list: [wp\_list\_categories()](http://codex.wordpress.org/Template_Tags/wp_list_categories... |
152,882 | <p>So, I have been looking EVERYWHERE. I tried every kind of combination. So far, nothing. I have to query two posts to show on my front page, of post post-type, not in one category but, most importantly, of the standard post-format. I work with wp 3.9.1. This is the syntax I use:</p>
<pre><code>$query = new WP_Query(... | [
{
"answer_id": 152888,
"author": "jack",
"author_id": 55148,
"author_profile": "https://wordpress.stackexchange.com/users/55148",
"pm_score": 4,
"selected": true,
"text": "<p>It looks like your syntax is a little off for the tax query. Try this: </p>\n\n<pre><code>$query = new WP_Query( ... | 2014/07/07 | [
"https://wordpress.stackexchange.com/questions/152882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55133/"
] | So, I have been looking EVERYWHERE. I tried every kind of combination. So far, nothing. I have to query two posts to show on my front page, of post post-type, not in one category but, most importantly, of the standard post-format. I work with wp 3.9.1. This is the syntax I use:
```
$query = new WP_Query( array(
... | It looks like your syntax is a little off for the tax query. Try this:
```
$query = new WP_Query( array(
'post_type' => 'post',
'cat' => '-1',
'posts_per_page' => 2,
'tax_query' => array( array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms'... |
152,897 | <p>After the holiday weekend, one of the larger sites I manage had a brute force attack on it. The attacker was attempting to use the <code>wp.getUsersBlogs</code> function and a list of popular usernames and passwords. A quick bit of research shows me that after a successful attempt this function will return whether o... | [
{
"answer_id": 153054,
"author": "Tejas Ranpura",
"author_id": 39301,
"author_profile": "https://wordpress.stackexchange.com/users/39301",
"pm_score": -1,
"selected": false,
"text": "<p>I have same issue for hacking my wordpress websites.\nThen i have create new user for administrator ac... | 2014/07/07 | [
"https://wordpress.stackexchange.com/questions/152897",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50492/"
] | After the holiday weekend, one of the larger sites I manage had a brute force attack on it. The attacker was attempting to use the `wp.getUsersBlogs` function and a list of popular usernames and passwords. A quick bit of research shows me that after a successful attempt this function will return whether or not the user... | This is the most specific solution I could find as it disables only the single function being attacked.
functions.php:
```
function Remove_Unneeded_XMLRPC( $methods ) {
unset( $methods['wp.getUsersBlogs'] );
return $methods;
}
add_filter( 'xmlrpc_methods', 'Remove_Unneeded_XMLRPC' );
```
found this at: <htt... |
152,910 | <p>I am trying to convert this piece of code into a shortcode so it can be used inside my posts.
Is it possible? I cant think of how to do it as I am beginner in wordpress and learning via books/youtube and wordpress documentation.</p>
<p>The code is:</p>
<pre><code> global $userpro;
$userpro->permalink( get_th... | [
{
"answer_id": 153054,
"author": "Tejas Ranpura",
"author_id": 39301,
"author_profile": "https://wordpress.stackexchange.com/users/39301",
"pm_score": -1,
"selected": false,
"text": "<p>I have same issue for hacking my wordpress websites.\nThen i have create new user for administrator ac... | 2014/07/07 | [
"https://wordpress.stackexchange.com/questions/152910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54180/"
] | I am trying to convert this piece of code into a shortcode so it can be used inside my posts.
Is it possible? I cant think of how to do it as I am beginner in wordpress and learning via books/youtube and wordpress documentation.
The code is:
```
global $userpro;
$userpro->permalink( get_the_author_meta('ID') );
... | This is the most specific solution I could find as it disables only the single function being attacked.
functions.php:
```
function Remove_Unneeded_XMLRPC( $methods ) {
unset( $methods['wp.getUsersBlogs'] );
return $methods;
}
add_filter( 'xmlrpc_methods', 'Remove_Unneeded_XMLRPC' );
```
found this at: <htt... |
152,952 | <p>I am kind of new to WordPress coding. I'm trying to edit the wp-login.php file so if a user clicks the register button, it registers the user and stores the information in a different database table. </p>
<p>My code to insert new data into the database is below.</p>
<pre><code>global $wpdb;
$wpdb->insert(
'... | [
{
"answer_id": 152955,
"author": "тнє Sufi",
"author_id": 28744,
"author_profile": "https://wordpress.stackexchange.com/users/28744",
"pm_score": 2,
"selected": true,
"text": "<p>You can hook your function with <code>user_register</code>. It will fire immediately after an user registrati... | 2014/07/08 | [
"https://wordpress.stackexchange.com/questions/152952",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55290/"
] | I am kind of new to WordPress coding. I'm trying to edit the wp-login.php file so if a user clicks the register button, it registers the user and stores the information in a different database table.
My code to insert new data into the database is below.
```
global $wpdb;
$wpdb->insert(
'wp_classes',
array(
... | You can hook your function with `user_register`. It will fire immediately after an user registration is done. And user id is passed to hook as an argument.
```
add_action( 'user_register', 'my_custom_function' );
function my_custom_function ( $user_id ) {
//here goes your code
}
``` |
152,969 | <p>I'm creating a WordPress theme in which I've allowed users to add some custom css from the Theme Options. This css code then directly gets echoed out in the head section of the page, with the following code:</p>
<pre><code>add_action('wp_head', 'theme_dynamic_css');
function theme_dynamic_css(){
global $my_theme_... | [
{
"answer_id": 272279,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>Instead of directly printing the CSS in the header (which is not the best practice) you can add your CSS vi... | 2014/07/08 | [
"https://wordpress.stackexchange.com/questions/152969",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43834/"
] | I'm creating a WordPress theme in which I've allowed users to add some custom css from the Theme Options. This css code then directly gets echoed out in the head section of the page, with the following code:
```
add_action('wp_head', 'theme_dynamic_css');
function theme_dynamic_css(){
global $my_theme_options;
$cu... | What you (and probably 99% of the theme authors) are trying to do is just wrong. Users should not be expected to know CSS to customize a theme, and if they do need to go into such a low level, the right thing for them to do is to create a child theme and insert their modifications into its CSS file.
Inputting a CSS in... |
152,971 | <p>Here is my situation: I am trying to filter the content of the title column in my custom post type edit table but I can't get it working. </p>
<p>Here is what I have tried:</p>
<pre><code>add_filter('manage_edit-mycpt_columns', 'replace_title_products');
function replace_title_products() {
$oldtitle = get_the... | [
{
"answer_id": 152978,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 6,
"selected": true,
"text": "<h3>1. Change post title in post list column</h3>\n<p>I misunderstood what you wanted - obviously. You ... | 2014/07/08 | [
"https://wordpress.stackexchange.com/questions/152971",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54879/"
] | Here is my situation: I am trying to filter the content of the title column in my custom post type edit table but I can't get it working.
Here is what I have tried:
```
add_filter('manage_edit-mycpt_columns', 'replace_title_products');
function replace_title_products() {
$oldtitle = get_the_title();
$newtit... | ### 1. Change post title in post list column
I misunderstood what you wanted - obviously. You can do that like this:
```
add_action(
'admin_head-edit.php',
'wpse152971_edit_post_change_title_in_list'
);
function wpse152971_edit_post_change_title_in_list() {
add_filter(
'the_title',
'wpse15... |
152,975 | <p>Guided by <a href="http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme" rel="nofollow">the Codex doc on Child Themes</a> I have created a <code>twentythirteen-child</code> theme for <a href="http://slova.de" rel="nofollow">my website</a> by copying the unchanged <code>index.php</code> file from the p... | [
{
"answer_id": 152978,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 6,
"selected": true,
"text": "<h3>1. Change post title in post list column</h3>\n<p>I misunderstood what you wanted - obviously. You ... | 2014/07/08 | [
"https://wordpress.stackexchange.com/questions/152975",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41372/"
] | Guided by [the Codex doc on Child Themes](http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme) I have created a `twentythirteen-child` theme for [my website](http://slova.de) by copying the unchanged `index.php` file from the parent theme and by creating this simple `style.css` file:
```
/*
Theme Name... | ### 1. Change post title in post list column
I misunderstood what you wanted - obviously. You can do that like this:
```
add_action(
'admin_head-edit.php',
'wpse152971_edit_post_change_title_in_list'
);
function wpse152971_edit_post_change_title_in_list() {
add_filter(
'the_title',
'wpse15... |
152,986 | <p>I found this solution to <a href="https://wordpress.stackexchange.com/questions/100707/automatically-assign-parent-terms-when-a-child-term-is-selected">automatically assign parent terms when a child term is selected</a>, which is working fine for the <strong>save_post</strong> hook:</p>
<pre><code>add_action('save_... | [
{
"answer_id": 152990,
"author": "engelen",
"author_id": 40403,
"author_profile": "https://wordpress.stackexchange.com/users/40403",
"pm_score": 0,
"selected": false,
"text": "<p><code>save_post</code> is actually called on saving a post through the Quick Edit feature as well. As we find... | 2014/07/08 | [
"https://wordpress.stackexchange.com/questions/152986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51307/"
] | I found this solution to [automatically assign parent terms when a child term is selected](https://wordpress.stackexchange.com/questions/100707/automatically-assign-parent-terms-when-a-child-term-is-selected), which is working fine for the **save\_post** hook:
```
add_action('save_post', 'assign_parent_terms');
funct... | There are two flaws in the code that I can see. The first one is a bug in this code
```
if($post->post_type != 'product')
```
If no post exists, you get the following error
>
> Notice: Trying to get property of non-object...
>
>
>
This can be fixed by first checking if a post `isset`
```
if(isset($post) && $p... |
153,002 | <p>I'm sorry for my english.
I'm trying to add some functionalities at my Wordpress website and to do this i have added a function in my function.php theme. The idea is to save in a custom table some datas and create a wp_post for any element added in the custom table.</p>
<p>I hooked the function in this way:</p>
<p... | [
{
"answer_id": 153017,
"author": "eyoung100",
"author_id": 51113,
"author_profile": "https://wordpress.stackexchange.com/users/51113",
"pm_score": 1,
"selected": false,
"text": "<p>The use of <code>wpdb->insert</code> and <code>wp_insert_post</code> both accomplish an SQL Insert, whic... | 2014/07/08 | [
"https://wordpress.stackexchange.com/questions/153002",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42747/"
] | I'm sorry for my english.
I'm trying to add some functionalities at my Wordpress website and to do this i have added a function in my function.php theme. The idea is to save in a custom table some datas and create a wp\_post for any element added in the custom table.
I hooked the function in this way:
```
add_action ... | The use of `wpdb->insert` and `wp_insert_post` both accomplish an SQL Insert, which is why you're seeing 2 records each time. You must use only one instance of an insert method, and then Pass `$my_post` to `WP_Query`
**CLARIFICATION**
As Milo points out in his comment `wpdb->insert` will insert into any table, while ... |
153,004 | <p>I'm working on a child theme, I strongly prefer not to override the main template files in order to maintain simplicity of the child theme as well as minimize the amount of code and maintenance over time.</p>
<p>In the loop, the index.php template in parent theme uses:
<code>get_template_part( 'content' );</code></... | [
{
"answer_id": 153006,
"author": "Justin R",
"author_id": 55311,
"author_profile": "https://wordpress.stackexchange.com/users/55311",
"pm_score": 0,
"selected": false,
"text": "<p>If you want to pull in a file called content-aside.php you call the function like this:</p>\n\n<pre><code>ge... | 2014/07/08 | [
"https://wordpress.stackexchange.com/questions/153004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4968/"
] | I'm working on a child theme, I strongly prefer not to override the main template files in order to maintain simplicity of the child theme as well as minimize the amount of code and maintenance over time.
In the loop, the index.php template in parent theme uses:
`get_template_part( 'content' );`
which will bring in *... | There is no hook to do this. Copy the index.php to the child theme and make the single line change. Also, tell the parent theme's author that they should make the same change in their theme, for flexibility. |
153,013 | <p>To remove a metabox from all post types at once, using a <code>foreach</code> seems like the logical thing to do. However it doesn't always work and I don't understand why.</p>
<p>For examlple viewing the "Post" post type the following only removes the <code>trackbacksdiv</code> :</p>
<pre><code>function remove_me... | [
{
"answer_id": 153015,
"author": "ungestaltbar",
"author_id": 12449,
"author_profile": "https://wordpress.stackexchange.com/users/12449",
"pm_score": 4,
"selected": true,
"text": "<p>Remember Apple's \"Goto Fail\"?</p>\n\n<p>Similar situation:</p>\n\n<p>Your code actually does this, when... | 2014/07/08 | [
"https://wordpress.stackexchange.com/questions/153013",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38123/"
] | To remove a metabox from all post types at once, using a `foreach` seems like the logical thing to do. However it doesn't always work and I don't understand why.
For examlple viewing the "Post" post type the following only removes the `trackbacksdiv` :
```
function remove_metabox_from_all_post_types() {
$post_types =... | Remember Apple's "Goto Fail"?
Similar situation:
Your code actually does this, when indentation is corrected:
```
foreach ( $post_types as $post_type )
remove_meta_box('trackbacksdiv', $post_type, 'normal');
remove_meta_box('postcustom', $post_type, 'normal');
remove_meta_box('authordiv', $post_type, 'no... |
153,018 | <p>Is there a way to put javascript in the URL portion of a WordPress menu item? I have a live chat function on my site, and I am supposed to put this code onto the site to make a link to open the live chat (as suggested here).</p>
<pre><code><!-- BEGIN OLARK CHAT LINK -->
<a href="javascript:void(0);" onclic... | [
{
"answer_id": 153022,
"author": "mcography",
"author_id": 39184,
"author_profile": "https://wordpress.stackexchange.com/users/39184",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Solution #1 (not ideal, but it works):</strong></p>\n\n<pre><code>// Live Chat Utility Link\nadd_fi... | 2014/07/08 | [
"https://wordpress.stackexchange.com/questions/153018",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39184/"
] | Is there a way to put javascript in the URL portion of a WordPress menu item? I have a live chat function on my site, and I am supposed to put this code onto the site to make a link to open the live chat (as suggested here).
```
<!-- BEGIN OLARK CHAT LINK -->
<a href="javascript:void(0);" onclick="olark('api.box.expan... | Good that it works. If it's for a client or if you just want a cleaner code, you can do it as @Tom J Nowell suggested.
Add a custom menu item, link it to nowhere or anywhere. Find out the menu item ID (every item has one), and then target that ID with jQuery.
```
$("#menu-item-num").on("click", function(e){
... |
153,020 | <p>I'd like to set my WordPress (self-hosted) site up so that you can only view images if you're logged in. I want it to be impossible to view the images without being authorized as a user of the site. <a href="https://wordpress.org/plugins/private-files/" rel="nofollow noreferrer" title="WordPress Plugin: Private File... | [
{
"answer_id": 153022,
"author": "mcography",
"author_id": 39184,
"author_profile": "https://wordpress.stackexchange.com/users/39184",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Solution #1 (not ideal, but it works):</strong></p>\n\n<pre><code>// Live Chat Utility Link\nadd_fi... | 2014/07/08 | [
"https://wordpress.stackexchange.com/questions/153020",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52811/"
] | I'd like to set my WordPress (self-hosted) site up so that you can only view images if you're logged in. I want it to be impossible to view the images without being authorized as a user of the site. [This plugin](https://wordpress.org/plugins/private-files/ "WordPress Plugin: Private Files") is exactly what I need, but... | Good that it works. If it's for a client or if you just want a cleaner code, you can do it as @Tom J Nowell suggested.
Add a custom menu item, link it to nowhere or anywhere. Find out the menu item ID (every item has one), and then target that ID with jQuery.
```
$("#menu-item-num").on("click", function(e){
... |
153,051 | <p>I have the below code which filters search results to only return those of a specific parent page:</p>
<pre><code>function SearchFilter($query) {
if ($query->is_search) {
//$query->set('post_type', 'page');
global $post;
$query->set( 'post_parent', '1548' );
}
return $query;
}
add_filter('pre_g... | [
{
"answer_id": 153055,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": true,
"text": "<p>Themes bundled with WordPress are licensed under \"GPLv2 or any later version\" in full (both code and assets).</p>\... | 2014/07/09 | [
"https://wordpress.stackexchange.com/questions/153051",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55327/"
] | I have the below code which filters search results to only return those of a specific parent page:
```
function SearchFilter($query) {
if ($query->is_search) {
//$query->set('post_type', 'page');
global $post;
$query->set( 'post_parent', '1548' );
}
return $query;
}
add_filter('pre_get_posts','SearchFilter... | Themes bundled with WordPress are licensed under "GPLv2 or any later version" in full (both code and assets).
You can reuse and resell that code, as long as you abide by the GPL license, effectively meaning — resulting product's code (and assets if you use them) must be under either of:
* GPLv2 or later
* GPLv2 stric... |
153,060 | <p>I am working on the design of a blog with the below(just a sample) category hierarchy.
<br /><br /></p>
<pre><code> PARENT
|
|------------------------------------------------|
Food ... | [
{
"answer_id": 153055,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": true,
"text": "<p>Themes bundled with WordPress are licensed under \"GPLv2 or any later version\" in full (both code and assets).</p>\... | 2014/07/09 | [
"https://wordpress.stackexchange.com/questions/153060",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54737/"
] | I am working on the design of a blog with the below(just a sample) category hierarchy.
```
PARENT
|
|------------------------------------------------|
Food ... | Themes bundled with WordPress are licensed under "GPLv2 or any later version" in full (both code and assets).
You can reuse and resell that code, as long as you abide by the GPL license, effectively meaning — resulting product's code (and assets if you use them) must be under either of:
* GPLv2 or later
* GPLv2 stric... |
153,080 | <p>I'm making some of our widgets customiser friendly, so they work on the customise page and support widget previews. Usually when you update a widget the save button becomes usable and changes to 'save and publish'. </p>
<p>However, I'm using some javascript (token input <a href="http://loopj.com/jquery-tokeninput/"... | [
{
"answer_id": 153131,
"author": "Weston Ruter",
"author_id": 8521,
"author_profile": "https://wordpress.stackexchange.com/users/8521",
"pm_score": 1,
"selected": false,
"text": "<p>Make sure that you trigger a <code>change</code> event on the <code>input</code> element. Otherwise, the C... | 2014/07/09 | [
"https://wordpress.stackexchange.com/questions/153080",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16885/"
] | I'm making some of our widgets customiser friendly, so they work on the customise page and support widget previews. Usually when you update a widget the save button becomes usable and changes to 'save and publish'.
However, I'm using some javascript (token input <http://loopj.com/jquery-tokeninput/>) on the widget te... | I was experiencing a similar problem with one of my custom widgets. It seems that dynamically inserted field values do not trigger the widget form to update. I wound up adding the following to the js that inserts the dynamic value:
```
$(input).trigger('change');
```
where input is the field you are updating.
Not s... |
153,083 | <p>I researched but did not find right answer to my question </p>
<p>I have custom post type for states, cities and countries and would like to set the default value in the country list for "Argentina", but do not know how to solve it. </p>
<p>see my code:</p>
<pre><code> <select name="pais" class="pais-se... | [
{
"answer_id": 153084,
"author": "Bysander",
"author_id": 47618,
"author_profile": "https://wordpress.stackexchange.com/users/47618",
"pm_score": 1,
"selected": true,
"text": "<p>should be <code>selected=\"selected\"</code> NOT \"selected=selected\"</p>\n\n<p>EDIT:</p>\n\n<p>Ok I see - i... | 2014/07/09 | [
"https://wordpress.stackexchange.com/questions/153083",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55341/"
] | I researched but did not find right answer to my question
I have custom post type for states, cities and countries and would like to set the default value in the country list for "Argentina", but do not know how to solve it.
see my code:
```
<select name="pais" class="pais-select">
<op... | should be `selected="selected"` NOT "selected=selected"
EDIT:
Ok I see - it's because you are using a foreach arguement to say that it's selected. Meaning that it prints the HTML showing that everything should be selected.
Try something like this:
```
<select name="pais" class="pais-select">
<option value="" disabl... |
153,093 | <p>I have a taxonomy with posts assigned to terms,
and on the term archive page i get no found post </p>
<pre><code>$rewrite = array(
'slug' => 'mytax',
'with_front' => true,
'hierarchical' => false,
);
$args = array(
'labels' ... | [
{
"answer_id": 153084,
"author": "Bysander",
"author_id": 47618,
"author_profile": "https://wordpress.stackexchange.com/users/47618",
"pm_score": 1,
"selected": true,
"text": "<p>should be <code>selected=\"selected\"</code> NOT \"selected=selected\"</p>\n\n<p>EDIT:</p>\n\n<p>Ok I see - i... | 2014/07/09 | [
"https://wordpress.stackexchange.com/questions/153093",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/492/"
] | I have a taxonomy with posts assigned to terms,
and on the term archive page i get no found post
```
$rewrite = array(
'slug' => 'mytax',
'with_front' => true,
'hierarchical' => false,
);
$args = array(
'labels' => $labels,
'h... | should be `selected="selected"` NOT "selected=selected"
EDIT:
Ok I see - it's because you are using a foreach arguement to say that it's selected. Meaning that it prints the HTML showing that everything should be selected.
Try something like this:
```
<select name="pais" class="pais-select">
<option value="" disabl... |
153,116 | <p>I use the Options Tree. Just to use a Meta Box only. And I do not use his Theme Options. </p>
<p>In the picture below, how to throw Theme Options menu?
Is it possible?</p>
<p><img src="https://i.stack.imgur.com/61z86.png" alt="Option Tree Theme Options"></p>
| [
{
"answer_id": 153120,
"author": "тнє Sufi",
"author_id": 28744,
"author_profile": "https://wordpress.stackexchange.com/users/28744",
"pm_score": 3,
"selected": true,
"text": "<p>This can be removed using <code>remove_submenu_page</code> function. Put following codes in your <code>functi... | 2014/07/09 | [
"https://wordpress.stackexchange.com/questions/153116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54567/"
] | I use the Options Tree. Just to use a Meta Box only. And I do not use his Theme Options.
In the picture below, how to throw Theme Options menu?
Is it possible?
 | This can be removed using `remove_submenu_page` function. Put following codes in your `functions.php`
```
function remove_ot_menu () {
remove_submenu_page( 'themes.php', 'ot-theme-options' );
}
add_action( 'admin_init', 'remove_ot_menu' );
``` |
154,157 | <p>I would like to get the images from the_content(), I know I could use a regex to get the images but I wanted to know if there is any other more 'wordpress way' for doing this?</p>
<p>I have this within a plugin and I have a filter </p>
<pre><code> add_filter('the_content', 'myTestContentFunction');
</code></pre>
... | [
{
"answer_id": 153120,
"author": "тнє Sufi",
"author_id": 28744,
"author_profile": "https://wordpress.stackexchange.com/users/28744",
"pm_score": 3,
"selected": true,
"text": "<p>This can be removed using <code>remove_submenu_page</code> function. Put following codes in your <code>functi... | 2014/07/10 | [
"https://wordpress.stackexchange.com/questions/154157",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56388/"
] | I would like to get the images from the\_content(), I know I could use a regex to get the images but I wanted to know if there is any other more 'wordpress way' for doing this?
I have this within a plugin and I have a filter
```
add_filter('the_content', 'myTestContentFunction');
```
Thank you | This can be removed using `remove_submenu_page` function. Put following codes in your `functions.php`
```
function remove_ot_menu () {
remove_submenu_page( 'themes.php', 'ot-theme-options' );
}
add_action( 'admin_init', 'remove_ot_menu' );
``` |
154,166 | <p>I'm using WooCommerce and it created a page called "Shop" which I've attributed to my custom template "Store" through the "page attributes" module in the dashboard.</p>
<pre><code><?php
/*
Template Name: Store
*/
?>
<?php get_header();?>
<section id="content">
... | [
{
"answer_id": 154168,
"author": "sharma chelluri",
"author_id": 50829,
"author_profile": "https://wordpress.stackexchange.com/users/50829",
"pm_score": -1,
"selected": false,
"text": "<p>Please set the template to <strong>Default template</strong> in the page edit.\n<img src=\"https://i... | 2014/07/10 | [
"https://wordpress.stackexchange.com/questions/154166",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18320/"
] | I'm using WooCommerce and it created a page called "Shop" which I've attributed to my custom template "Store" through the "page attributes" module in the dashboard.
```
<?php
/*
Template Name: Store
*/
?>
<?php get_header();?>
<section id="content">
<?php if (have_posts()) : whil... | WooCommerce uses a custom post type called **product** for its product. Your shop page appears to be looking for a products archive. I can tell this because of the slug - post-type-archive-**product**
Have you tried renaming your custom shop template file `archive-product.php`? This should override the default archive... |
154,167 | <p>My visual editor is missing in a project</p>
<p>I've tried <a href="https://wordpress.org/support/topic/how-to-troubleshoot-visual-editor-issues?replies=3&view=all" rel="nofollow">this guide</a> which includes deactivating ALL plugins, changing the theme, empting the cache and still at that point there was no V... | [
{
"answer_id": 176682,
"author": "Nicolas 4dg.cl",
"author_id": 66856,
"author_profile": "https://wordpress.stackexchange.com/users/66856",
"pm_score": 2,
"selected": false,
"text": "<p>I had the same problem and the solutions was to check \"Disable the visual editor when writing\", save... | 2014/07/10 | [
"https://wordpress.stackexchange.com/questions/154167",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47901/"
] | My visual editor is missing in a project
I've tried [this guide](https://wordpress.org/support/topic/how-to-troubleshoot-visual-editor-issues?replies=3&view=all) which includes deactivating ALL plugins, changing the theme, empting the cache and still at that point there was no Visual Editor, only the plain HTML editor... | I had the same problem and the solutions was to check "Disable the visual editor when writing", save, uncheck it, save again, and then it worked. |
154,191 | <p>My wordpress header.php and function.php is given below.please help me to modify my php code to stop problems due to loading jquery multiple times. My plugins and themes are loading jquery multiple times. </p>
<p>My files<br>
<a href="http://pastebin.com/raw.php?i=KTqj6LJT" rel="nofollow">Header.php </a><br>
<a hre... | [
{
"answer_id": 154195,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>The simple answer is to never add script tags directly to template files. This is exactly why the WordPress script... | 2014/07/10 | [
"https://wordpress.stackexchange.com/questions/154191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31074/"
] | My wordpress header.php and function.php is given below.please help me to modify my php code to stop problems due to loading jquery multiple times. My plugins and themes are loading jquery multiple times.
My files
[Header.php](http://pastebin.com/raw.php?i=KTqj6LJT)
[Function.php](http://pastebin.com/raw.php?i... | You should remove these lines from your header.php
```
<script language="javascript" type="text/javascript" src="<?php bloginfo('template_url'); ?>/javascripts/jquery.js"></script>
<script language="javascript" type="text/javascript" src="<?php bloginfo('template_url'); ?>/javascripts/tabber.js"></script>
<script lang... |
154,197 | <p>OK,</p>
<p>So I have created a custom WP_Query that gets the post_type <code>post</code> and outputs it as a styled list. It works well and outputs the styled list but then underneath it displays all the posts again but in a completely different format (unstyled).</p>
<pre><code><?php
// get all post types
$ar... | [
{
"answer_id": 154210,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/wp_reset_query\" rel=\"nofollow\"><code>wp_reset_query(... | 2014/07/10 | [
"https://wordpress.stackexchange.com/questions/154197",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51569/"
] | OK,
So I have created a custom WP\_Query that gets the post\_type `post` and outputs it as a styled list. It works well and outputs the styled list but then underneath it displays all the posts again but in a completely different format (unstyled).
```
<?php
// get all post types
$args = array (
'post_type' ... | Use [`wp_reset_query()`](http://codex.wordpress.org/Function_Reference/wp_reset_query) to restore the original query. This also calls `wp_reset_postdata`, so you can just replace that. |
154,209 | <p>I'm trying to get my code to:</p>
<ul>
<li>Get a post's thumbnail url</li>
<li><em>or</em> (if no thumbnail there) to</li>
<li>Echo a default url</li>
</ul>
<p>I'm not sure if I am going the easiest way or right way about this.</p>
<p>This is the code so far. <code>$postid</code> being the attribute for the id of... | [
{
"answer_id": 154210,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/wp_reset_query\" rel=\"nofollow\"><code>wp_reset_query(... | 2014/07/10 | [
"https://wordpress.stackexchange.com/questions/154209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51030/"
] | I'm trying to get my code to:
* Get a post's thumbnail url
* *or* (if no thumbnail there) to
* Echo a default url
I'm not sure if I am going the easiest way or right way about this.
This is the code so far. `$postid` being the attribute for the id of the post I want the url from.
```
<?php
// Add Shortcode
function... | Use [`wp_reset_query()`](http://codex.wordpress.org/Function_Reference/wp_reset_query) to restore the original query. This also calls `wp_reset_postdata`, so you can just replace that. |
154,211 | <p>I'm have the 2 seperate block of codes as shown below and the one below doesn't work except if I cut off the first one. Any ideas what the problem could be?</p>
<p><strong>Conditinal script</strong></p>
<pre><code><?php { ?>
<?php
if ( is_front_page() ) {
get_template_part('home-pag... | [
{
"answer_id": 154216,
"author": "Shawn",
"author_id": 35677,
"author_profile": "https://wordpress.stackexchange.com/users/35677",
"pm_score": 0,
"selected": false,
"text": "<p>Looks like a PHP error to me with random braces:</p>\n\n<pre><code><?php { ?>\n<?php } ?>\n</code><... | 2014/07/10 | [
"https://wordpress.stackexchange.com/questions/154211",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4401/"
] | I'm have the 2 seperate block of codes as shown below and the one below doesn't work except if I cut off the first one. Any ideas what the problem could be?
**Conditinal script**
```
<?php { ?>
<?php
if ( is_front_page() ) {
get_template_part('home-page-content');
} elseif ... | You have a lot of PHP tag spam, e.g.:
```
?><?php
```
This is bad, confusing, makes your code difficult to read, and a waste of your time to type. It's the difficulty reading your code that has lead to your problem, including the lack of indentation. These are important, and any good editor will do them for you effo... |
154,248 | <p><strong>What I'm trying to do:</strong> Passing POST data by using wp_remote_post.</p>
<pre><code>foreach ( $articles as $article_id ) {
$postarray = array(
'method' => 'POST',
'timeout' => 5,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true... | [
{
"answer_id": 166925,
"author": "Nich",
"author_id": 52523,
"author_profile": "https://wordpress.stackexchange.com/users/52523",
"pm_score": 4,
"selected": true,
"text": "<p>After quite some time letting the error message bugging my screen, I figured out a way to solve this.</p>\n\n<p>Y... | 2014/07/11 | [
"https://wordpress.stackexchange.com/questions/154248",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52523/"
] | **What I'm trying to do:** Passing POST data by using wp\_remote\_post.
```
foreach ( $articles as $article_id ) {
$postarray = array(
'method' => 'POST',
'timeout' => 5,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'b... | After quite some time letting the error message bugging my screen, I figured out a way to solve this.
Yes, it's a timeout issue, and the codex didn't help me much. So I tried another approach, by setting a filter;
```
add_filter( 'http_request_timeout', 'wp9838c_timeout_extend' );
function wp9838c_timeout_extend( $t... |
154,257 | <p>I'm working with wp 3.9.1 and plugin Custom Content Type Manager. I'm creating my own theme. I created a custom type called "aggregato". I also use custom taxonomies. I then created a WP_query for my front-page:</p>
<pre><code>$query = new WP_Query( array(
'post_type' => array ('post', 'aggregato'),
'cat' ... | [
{
"answer_id": 154266,
"author": "Berend",
"author_id": 20044,
"author_profile": "https://wordpress.stackexchange.com/users/20044",
"pm_score": 0,
"selected": false,
"text": "<p>I believe you just want to loop through the posts returned by the query? You create a loop from the query like... | 2014/07/11 | [
"https://wordpress.stackexchange.com/questions/154257",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55133/"
] | I'm working with wp 3.9.1 and plugin Custom Content Type Manager. I'm creating my own theme. I created a custom type called "aggregato". I also use custom taxonomies. I then created a WP\_query for my front-page:
```
$query = new WP_Query( array(
'post_type' => array ('post', 'aggregato'),
'cat' => '-1',
'pos... | I believe you are trying to check post type inside the Loop. To check the post type, try this:
```
global $post;
if('post' == $post->post_type ){
// post stuff here
}
else{
// aggregato stuff here
}
```
Alternatively, you can also use `get_post_type()` function to get post type of current post. |
154,276 | <p>I´m building a actors/movies sites and I got stuck with one thing. I have several pages with actors biography (featured image, name, about, date of birth, etc) and I have a menu with the option "actors". I would like to create a page called "actors" that could loop all actors pages with pagination, organizing them i... | [
{
"answer_id": 154278,
"author": "Romain",
"author_id": 56396,
"author_profile": "https://wordpress.stackexchange.com/users/56396",
"pm_score": 1,
"selected": true,
"text": "<p>If I understand, you need to create a template that list all your pages (actors) on one template.</p>\n\n<p>If ... | 2014/07/11 | [
"https://wordpress.stackexchange.com/questions/154276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56441/"
] | I´m building a actors/movies sites and I got stuck with one thing. I have several pages with actors biography (featured image, name, about, date of birth, etc) and I have a menu with the option "actors". I would like to create a page called "actors" that could loop all actors pages with pagination, organizing them in o... | If I understand, you need to create a template that list all your pages (actors) on one template.
If this is the case, you need to create the actor archive template to allow you to:
* Add a page where you can list all your actors
* Left the page template intact
So, the template that you need to create is archive-act... |
154,282 | <p>Is there a way to remove the 'Check Compatibility' link that appears under plugins in the plugin menu?</p>
<p>If so, how can I remove the link from a given set of plugins, and alternatively from all plugins at once?</p>
| [
{
"answer_id": 154278,
"author": "Romain",
"author_id": 56396,
"author_profile": "https://wordpress.stackexchange.com/users/56396",
"pm_score": 1,
"selected": true,
"text": "<p>If I understand, you need to create a template that list all your pages (actors) on one template.</p>\n\n<p>If ... | 2014/07/11 | [
"https://wordpress.stackexchange.com/questions/154282",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55152/"
] | Is there a way to remove the 'Check Compatibility' link that appears under plugins in the plugin menu?
If so, how can I remove the link from a given set of plugins, and alternatively from all plugins at once? | If I understand, you need to create a template that list all your pages (actors) on one template.
If this is the case, you need to create the actor archive template to allow you to:
* Add a page where you can list all your actors
* Left the page template intact
So, the template that you need to create is archive-act... |
154,298 | <p>I've been trying to get the latest Page, not post, by author ID and display it on a page. </p>
<p>The reason it has to be a page and not a post is that the user will only be posting one page and a whole bunch of posts. </p>
<p>This also needs to be done dynamically and be based on the current logged in user. </p>
... | [
{
"answer_id": 154278,
"author": "Romain",
"author_id": 56396,
"author_profile": "https://wordpress.stackexchange.com/users/56396",
"pm_score": 1,
"selected": true,
"text": "<p>If I understand, you need to create a template that list all your pages (actors) on one template.</p>\n\n<p>If ... | 2014/07/11 | [
"https://wordpress.stackexchange.com/questions/154298",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56445/"
] | I've been trying to get the latest Page, not post, by author ID and display it on a page.
The reason it has to be a page and not a post is that the user will only be posting one page and a whole bunch of posts.
This also needs to be done dynamically and be based on the current logged in user.
I've got the followi... | If I understand, you need to create a template that list all your pages (actors) on one template.
If this is the case, you need to create the actor archive template to allow you to:
* Add a page where you can list all your actors
* Left the page template intact
So, the template that you need to create is archive-act... |
154,324 | <p>It's not easy to count the amount of posts an image is attached to - WordPress simply doesn't keep track of that. It just keeps track of the post an attachment was originally uploaded to (not necessarily even using it there).</p>
<p><img src="https://i.stack.imgur.com/BHd1n.png" alt="enter image description here" />... | [
{
"answer_id": 154325,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 3,
"selected": true,
"text": "<p><strong>Second pass</strong>. Known issues:</p>\n\n<ul>\n<li>Needs caching (and the cache needs to be tid... | 2014/07/11 | [
"https://wordpress.stackexchange.com/questions/154324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | It's not easy to count the amount of posts an image is attached to - WordPress simply doesn't keep track of that. It just keeps track of the post an attachment was originally uploaded to (not necessarily even using it there).

Plugin
======
To get y... | **Second pass**. Known issues:
* Needs caching (and the cache needs to be tidied up where possible)
* Post types are hard-coded
* Which post statuses are we interested in?
Here's the function:
```
/**
* Given an attachment ID, searches for any post with that attachment used
* as a featured image, or if it is prese... |
154,330 | <p>I'm trying to add a text input to the "Insert Media" modal in the hopes of being able to add an html5 <code>data-</code> attribute to the images' parent anchor.</p>
<p><code><a class="fancybox" href="..." data-fancybox-group=" "></code> <-- This part<br>
<code><img class="wp-image-871" src="..." alt=... | [
{
"answer_id": 154474,
"author": "nothingtosee",
"author_id": 11117,
"author_profile": "https://wordpress.stackexchange.com/users/11117",
"pm_score": 2,
"selected": false,
"text": "<p>You should be able pull the field using <code>get_post_meta</code>.</p>\n\n<pre><code>function give_link... | 2014/07/12 | [
"https://wordpress.stackexchange.com/questions/154330",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44244/"
] | I'm trying to add a text input to the "Insert Media" modal in the hopes of being able to add an html5 `data-` attribute to the images' parent anchor.
`<a class="fancybox" href="..." data-fancybox-group=" ">` <-- This part
`<img class="wp-image-871" src="..." alt="..." width="245" height="333" />`
`</a>`
So far ... | I have taken a look at the source, unfortunately I haven't seen a nice way to pass the information without saving it. Which sucks - big time - because this really isn't anything that needs to be saved.
A workaround would be to enable [PHP Sessions](http://php.net/manual/en/book.session.php) by putting the following at... |
154,344 | <p>I have table that save in it the user id and post id.</p>
<p>Now in some page i need to show all post for user_id (1) for example.</p>
<p>how can i display all post that user_id is 1 </p>
| [
{
"answer_id": 154474,
"author": "nothingtosee",
"author_id": 11117,
"author_profile": "https://wordpress.stackexchange.com/users/11117",
"pm_score": 2,
"selected": false,
"text": "<p>You should be able pull the field using <code>get_post_meta</code>.</p>\n\n<pre><code>function give_link... | 2014/07/12 | [
"https://wordpress.stackexchange.com/questions/154344",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52632/"
] | I have table that save in it the user id and post id.
Now in some page i need to show all post for user\_id (1) for example.
how can i display all post that user\_id is 1 | I have taken a look at the source, unfortunately I haven't seen a nice way to pass the information without saving it. Which sucks - big time - because this really isn't anything that needs to be saved.
A workaround would be to enable [PHP Sessions](http://php.net/manual/en/book.session.php) by putting the following at... |
154,360 | <p>I am trying to make a custom page template that shows the most viewed posts. I can return posts but I am having trouble figuring out how to paginate it. Here is what I have:</p>
<pre><code>$args = array('orderby' => 'meta_value_num', 'meta_key' => 'post_views_count', 'posts_per_page' => 36 );
$... | [
{
"answer_id": 154361,
"author": "Abhik",
"author_id": 26991,
"author_profile": "https://wordpress.stackexchange.com/users/26991",
"pm_score": 0,
"selected": false,
"text": "<p>Try this.. </p>\n\n<pre><code>$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;\... | 2014/07/12 | [
"https://wordpress.stackexchange.com/questions/154360",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50522/"
] | I am trying to make a custom page template that shows the most viewed posts. I can return posts but I am having trouble figuring out how to paginate it. Here is what I have:
```
$args = array('orderby' => 'meta_value_num', 'meta_key' => 'post_views_count', 'posts_per_page' => 36 );
$loop = new WP_Query( $a... | This is a local/global variable problem. It can be solved either by changing the pagination function to work with local variable, or by promoting the local variable into global scope. As you are using `wp_reset_postdata()`, i guess you want to keep the original query.
### Change the pagination function to accept argum... |
154,389 | <p>I am having some issues trying to get featured image to appear on my front page.</p>
<p>I am using Genesis, then genesis child theme. I only want the featured image to appear on my <code>front-page.php</code>. I know I need to write a custom loop in order for the featured image to appear only. However I am having ... | [
{
"answer_id": 154361,
"author": "Abhik",
"author_id": 26991,
"author_profile": "https://wordpress.stackexchange.com/users/26991",
"pm_score": 0,
"selected": false,
"text": "<p>Try this.. </p>\n\n<pre><code>$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;\... | 2014/07/13 | [
"https://wordpress.stackexchange.com/questions/154389",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56494/"
] | I am having some issues trying to get featured image to appear on my front page.
I am using Genesis, then genesis child theme. I only want the featured image to appear on my `front-page.php`. I know I need to write a custom loop in order for the featured image to appear only. However I am having trouble completing it.... | This is a local/global variable problem. It can be solved either by changing the pagination function to work with local variable, or by promoting the local variable into global scope. As you are using `wp_reset_postdata()`, i guess you want to keep the original query.
### Change the pagination function to accept argum... |
154,409 | <p>I followed the guideline from <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install" rel="nofollow">WP Codex</a>.</p>
<ul>
<li>Changed the site url in general settings</li>
<li>Copied the .haccess and the index.php files from the subdirectory to the root</l... | [
{
"answer_id": 154361,
"author": "Abhik",
"author_id": 26991,
"author_profile": "https://wordpress.stackexchange.com/users/26991",
"pm_score": 0,
"selected": false,
"text": "<p>Try this.. </p>\n\n<pre><code>$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;\... | 2014/07/13 | [
"https://wordpress.stackexchange.com/questions/154409",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56505/"
] | I followed the guideline from [WP Codex](http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install).
* Changed the site url in general settings
* Copied the .haccess and the index.php files from the subdirectory to the root
* Edited the root index.php (new copied file in r... | This is a local/global variable problem. It can be solved either by changing the pagination function to work with local variable, or by promoting the local variable into global scope. As you are using `wp_reset_postdata()`, i guess you want to keep the original query.
### Change the pagination function to accept argum... |
154,420 | <p>I am working on a WordPress theme and I have some problem with the pages\posts layout.</p>
<p>For example if you go here: <a href="http://lnx.asper-eritrea.com/lassociazione/" rel="nofollow">http://lnx.asper-eritrea.com/lassociazione/</a></p>
<p>This is a static page that show some text (and it is ok) but why unde... | [
{
"answer_id": 154361,
"author": "Abhik",
"author_id": 26991,
"author_profile": "https://wordpress.stackexchange.com/users/26991",
"pm_score": 0,
"selected": false,
"text": "<p>Try this.. </p>\n\n<pre><code>$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;\... | 2014/07/13 | [
"https://wordpress.stackexchange.com/questions/154420",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I am working on a WordPress theme and I have some problem with the pages\posts layout.
For example if you go here: <http://lnx.asper-eritrea.com/lassociazione/>
This is a static page that show some text (and it is ok) but why under the text it is shown the possibility to let a comment and under it a calendar, categor... | This is a local/global variable problem. It can be solved either by changing the pagination function to work with local variable, or by promoting the local variable into global scope. As you are using `wp_reset_postdata()`, i guess you want to keep the original query.
### Change the pagination function to accept argum... |
154,427 | <p>I've been looking for minutes how to pass arguments in the <code>register_deactivation_hook</code> as follow :</p>
<pre><code>register_deactivation_hook( __FILE__, array( new Cpt, 'delete_cpt') ) );
class Cpt
{
/**
* Delete a custom post type
*/
public function delete_cpt($name = 'test') {
... | [
{
"answer_id": 154431,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": -1,
"selected": false,
"text": "<p>You should replace the <code>register_deactivation_hook</code> code line with below code:</p>\n\n<p><code>reg... | 2014/07/13 | [
"https://wordpress.stackexchange.com/questions/154427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48384/"
] | I've been looking for minutes how to pass arguments in the `register_deactivation_hook` as follow :
```
register_deactivation_hook( __FILE__, array( new Cpt, 'delete_cpt') ) );
class Cpt
{
/**
* Delete a custom post type
*/
public function delete_cpt($name = 'test') {
/**
* delete a... | Use a complete function as callback, so you can pass the argument to the method. Example:
```
register_deactivation_hook(
__FILE__,
function() {
$cpt = new Cpt;
$cpt->delete_cpt( 'post_type_name' );
}
);
``` |
154,435 | <p>If someone put a comment to post, that post should be the first post of blog. ( Forums works like this).</p>
<p>I don't want to use forum plugin also. I need only, when a user submit a comment, that post goes to up as the first post of my blog.</p>
<p>Is it possible?</p>
| [
{
"answer_id": 154431,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": -1,
"selected": false,
"text": "<p>You should replace the <code>register_deactivation_hook</code> code line with below code:</p>\n\n<p><code>reg... | 2014/07/13 | [
"https://wordpress.stackexchange.com/questions/154435",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56520/"
] | If someone put a comment to post, that post should be the first post of blog. ( Forums works like this).
I don't want to use forum plugin also. I need only, when a user submit a comment, that post goes to up as the first post of my blog.
Is it possible? | Use a complete function as callback, so you can pass the argument to the method. Example:
```
register_deactivation_hook(
__FILE__,
function() {
$cpt = new Cpt;
$cpt->delete_cpt( 'post_type_name' );
}
);
``` |
154,453 | <p>How can I hide a widget from a certain page (one page). After spending an hour, all I can find is with the plugins. The problem is, that I know with them how to do it, but one widget (ad widget) is placed inside my theme panel not like a drag/drop widget, so I cant set it up with widget.</p>
<p>This is my code of w... | [
{
"answer_id": 188114,
"author": "Raj",
"author_id": 72740,
"author_profile": "https://wordpress.stackexchange.com/users/72740",
"pm_score": -1,
"selected": false,
"text": "<p>Simply search & activate plugin \"Widget Logic\" from wordpress dashboard--> plugins, which creates \"Widget... | 2014/07/14 | [
"https://wordpress.stackexchange.com/questions/154453",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35867/"
] | How can I hide a widget from a certain page (one page). After spending an hour, all I can find is with the plugins. The problem is, that I know with them how to do it, but one widget (ad widget) is placed inside my theme panel not like a drag/drop widget, so I cant set it up with widget.
This is my code of widget whic... | You can use this snippet. Just make sure you change the widget id :
```
<?php
add_filter( 'widget_display_callback', 'widget_display', 50, 3 );
function widget_display( $instance, $widget, $args ){
if ( is_page() && $widget->id == 'text-39' ) {
return false;
}
return $instance;
}
?>
```
The easie... |
154,463 | <p>I'm working on a site, largely managed by categories. Two of the categories have apostrophes in them... ex. "Joe's Place" and "Tina's Lounge". (Actual titles changed, these are examples...) The category slugs are "joes-place" and "tinas-lounge". </p>
<p>The customer asked for a breadcrumb on the site... Unfortu... | [
{
"answer_id": 188114,
"author": "Raj",
"author_id": 72740,
"author_profile": "https://wordpress.stackexchange.com/users/72740",
"pm_score": -1,
"selected": false,
"text": "<p>Simply search & activate plugin \"Widget Logic\" from wordpress dashboard--> plugins, which creates \"Widget... | 2014/07/14 | [
"https://wordpress.stackexchange.com/questions/154463",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45680/"
] | I'm working on a site, largely managed by categories. Two of the categories have apostrophes in them... ex. "Joe's Place" and "Tina's Lounge". (Actual titles changed, these are examples...) The category slugs are "joes-place" and "tinas-lounge".
The customer asked for a breadcrumb on the site... Unfortunately the bre... | You can use this snippet. Just make sure you change the widget id :
```
<?php
add_filter( 'widget_display_callback', 'widget_display', 50, 3 );
function widget_display( $instance, $widget, $args ){
if ( is_page() && $widget->id == 'text-39' ) {
return false;
}
return $instance;
}
?>
```
The easie... |
154,475 | <p>I am trying to select posts that have category id <code>4</code> but exclude posts that also have category id <code>2</code></p>
<p>Here's what i'm trying</p>
<pre><code>$query = new WP_Query(array(
"cat__in" => array(4),
"cat__not_in" => array(2),
"post_type" => "post",
"post_st... | [
{
"answer_id": 154477,
"author": "jojo",
"author_id": 55321,
"author_profile": "https://wordpress.stackexchange.com/users/55321",
"pm_score": -1,
"selected": false,
"text": "<p>Suppose you have posts with cat id 4. </p>\n\n<pre><code>query_posts('cat=4');\n while (have_posts()) : the_po... | 2014/07/14 | [
"https://wordpress.stackexchange.com/questions/154475",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am trying to select posts that have category id `4` but exclude posts that also have category id `2`
Here's what i'm trying
```
$query = new WP_Query(array(
"cat__in" => array(4),
"cat__not_in" => array(2),
"post_type" => "post",
"post_status" => "publish",
"orderby" => "date... | As it turns out, this can be done in 4 separate ways
**Using `cat` with a negative number**
```
$query = new WP_Query(array(
"cat" => "4, -2",
// ...
));
```
**Using `category__in` and `category__not_in`**
I was mistakenly using `cat__in` and `cat__not_in` which are **not** valid WP\_Query parameters
```
$que... |
154,478 | <p>I have to create a option page in my custom theme wordpress. here is is a sample of code</p>
<pre><code><?php
function bguru_register_settings(){
$default_options=array(
'bguru_logo'=>'http://templategraphy.com/demo/businessguru/images/logo.png',
'bguru_vimeo'=>'',
'bguru_s... | [
{
"answer_id": 154482,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>I think that you have added <code>bguru_options</code> option before. If <code>bguru_options</code> already e... | 2014/07/14 | [
"https://wordpress.stackexchange.com/questions/154478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54434/"
] | I have to create a option page in my custom theme wordpress. here is is a sample of code
```
<?php
function bguru_register_settings(){
$default_options=array(
'bguru_logo'=>'http://templategraphy.com/demo/businessguru/images/logo.png',
'bguru_vimeo'=>'',
'bguru_skype'=>'',
'bgu... | I think that you have added `bguru_options` option before. If `bguru_options` already exists, `add_option()` does nothing. To modify the value of existing options you should use `update_option()` instead.
**EDIT**
I confirm what I thought. You are running `add_option('bguru_options', $default_options);` in every `adm... |
154,491 | <p>I'm using a wordpress theme which uses custom post types for portfolio items and "sets" to categorize them. When I hover over a "set" to edit, it reveals this at the bottom of the browser: taxonomy=portfoliosets, &tag-id=37 &post_type=portfolios.</p>
<p>I am trying to make it so the header image will chan... | [
{
"answer_id": 154502,
"author": "sabarnix",
"author_id": 56542,
"author_profile": "https://wordpress.stackexchange.com/users/56542",
"pm_score": 0,
"selected": false,
"text": "<p>I think portfoliosets is custom taxonomy and videos and magazines are terms.</p>\n\n<p>So your code should b... | 2014/07/14 | [
"https://wordpress.stackexchange.com/questions/154491",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22537/"
] | I'm using a wordpress theme which uses custom post types for portfolio items and "sets" to categorize them. When I hover over a "set" to edit, it reveals this at the bottom of the browser: taxonomy=portfoliosets, &tag-id=37 &post\_type=portfolios.
I am trying to make it so the header image will change depending on the... | Two things are important here, your taxonomy is `portfoliosets`, which mean this is not a built-in category. `videos` and `magazines` are terms of your taxonomy. From what I can make from your question, you need to show different header image for different single post page view depending on the term a post belongs to. ... |
154,507 | <p>I have a custom field called "website_url". It should be unique.</p>
<p>Ex: If a author set "<a href="https://wordpress.stackexchange.com/questions/ask">https://wordpress.stackexchange.com/questions/ask</a>" as the custom field value as a post, "<a href="https://wordpress.stackexchange.com/questions/ask">https://wo... | [
{
"answer_id": 154555,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the filter hooks <code>'add_post_metadata'</code> and <code>'update_post_meta'</code>, when a fun... | 2014/07/14 | [
"https://wordpress.stackexchange.com/questions/154507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56546/"
] | I have a custom field called "website\_url". It should be unique.
Ex: If a author set "<https://wordpress.stackexchange.com/questions/ask>" as the custom field value as a post, "<https://wordpress.stackexchange.com/questions/ask>" can't be used any other post.
How to do it? | You can use the filter hooks `'add_post_metadata'` and `'update_post_meta'`, when a function hooked there return anything but `NULL` the process of adding/updating metadata is stopped.
The two hooks passes almost same args:
1. NULL
2. post id
3. the meta key
4. the meta value being added/updated
Only last argument i... |
154,509 | <p>I am working on a foreach loop in Wordpress and want to add 'post_class()' to a div within it. Currently the code looks like this:</p>
<pre><code>if ( is_array( $posts ) && !empty( $posts ) ) {
echo '<ul class="tribe-related-events tribe-clearfix hfeed vcalendar">';
foreach ( $posts as $post ... | [
{
"answer_id": 154513,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>The <a href=\"https://github.com/WordPress/WordPress/blob/3.9.1/wp-includes/post-template.php#L369\" rel=\"nofollo... | 2014/07/14 | [
"https://wordpress.stackexchange.com/questions/154509",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31033/"
] | I am working on a foreach loop in Wordpress and want to add 'post\_class()' to a div within it. Currently the code looks like this:
```
if ( is_array( $posts ) && !empty( $posts ) ) {
echo '<ul class="tribe-related-events tribe-clearfix hfeed vcalendar">';
foreach ( $posts as $post ) {
echo '<li>';
... | The solution has actually been less complicated than I initially thought. The post\_class() function does not return a string, but instead it "echoes" the string.
Therefore, when you write.
```
echo '<div ' . post_class() . '>';
```
The effect is the following:
First, the system execute post\_class(), generating a... |
154,516 | <p>Currently i am using:</p>
<pre><code><?php echo wp_nav_menu( array( 'menu' => 'main-menu','depth'=> 1,'items_wrap' => '<ul class="navigation_ul">%3$s</ul>' ) ); ?>
</code></pre>
<p>I want to achieve: </p>
<pre><code><ul class="navigation_ul">
<li id="menu_1">
... | [
{
"answer_id": 154519,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 3,
"selected": false,
"text": "<p>According to the Codex, <a href=\"http://codex.wordpress.org/Function_Reference/wp_nav_menu\" rel=\"nofollo... | 2014/07/14 | [
"https://wordpress.stackexchange.com/questions/154516",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55239/"
] | Currently i am using:
```
<?php echo wp_nav_menu( array( 'menu' => 'main-menu','depth'=> 1,'items_wrap' => '<ul class="navigation_ul">%3$s</ul>' ) ); ?>
```
I want to achieve:
```
<ul class="navigation_ul">
<li id="menu_1">
<a href="" class="active">
<span class="left_arrow"></span>
... | According to the Codex, [`wp_nav_menu()`](http://codex.wordpress.org/Function_Reference/wp_nav_menu) has a couple parameters to add HTML or entities before and after the generated HTML. The parameters you want is `link_before` and `link_after` and to get the effect you're after looks like this:
```
'link_before' => '<... |
154,522 | <p>I started building a plugin in which I need to build some custom queries with <code>wpdb</code> object. It's the first time I use it. So I checked out how to use it. I watched some examples and there is something which is messing up my mind : <code>upgrade.php</code></p>
<p>Actually when I create a custom query, th... | [
{
"answer_id": 154668,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 2,
"selected": true,
"text": "<p>No, and in fact you should not include the wp-admin/includes/upgrade.php file in a plugin. There is no real valid u... | 2014/07/14 | [
"https://wordpress.stackexchange.com/questions/154522",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48384/"
] | I started building a plugin in which I need to build some custom queries with `wpdb` object. It's the first time I use it. So I checked out how to use it. I watched some examples and there is something which is messing up my mind : `upgrade.php`
Actually when I create a custom query, this one only works when I include... | No, and in fact you should not include the wp-admin/includes/upgrade.php file in a plugin. There is no real valid use case for doing so. It doesn't do anything for you or add any useful functions for a plugin.
As for your question, you say "it doesn't work" but you fail to define what that means. Providing the error ... |
154,554 | <p>I'm wondering if it's possible to determine WP_Query parameters by <strong>only</strong> using the given page URL. The reason I'm trying to do this because I'm developing a SPA theme (and ultimately a JSON response) and would need to be able to determine a query without reloading the page.</p>
<p>Thought it's prett... | [
{
"answer_id": 154558,
"author": "Shazzad",
"author_id": 42967,
"author_profile": "https://wordpress.stackexchange.com/users/42967",
"pm_score": 1,
"selected": false,
"text": "<p>There's a simple solution using a Good and an Odd Mechanism.</p>\n\n<h2>The Good Part</h2>\n\n<pre><code>func... | 2014/07/14 | [
"https://wordpress.stackexchange.com/questions/154554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33576/"
] | I'm wondering if it's possible to determine WP\_Query parameters by **only** using the given page URL. The reason I'm trying to do this because I'm developing a SPA theme (and ultimately a JSON response) and would need to be able to determine a query without reloading the page.
Thought it's pretty hacky, I've been suc... | **Edited Jul, 07 2014 at 6:28**
---
There are a lot of gotchas with your approach. It will not work if there are any custom rewrite rule, it (probably) will not work if server is IIS and pretty permalink are active, it will not work for custom post types, it will not work for archive or search urls and so on.
To obt... |
154,570 | <p>if</p>
<pre><code> function wpse_custom_header_setup() {
add_theme_support( 'custom-header', apply_filters( 'wpse_header_args', array(
'width' => 1460,
'height' => 220,
) ) );
}
add_action( 'after_setup_theme', 'wpse_custom_header_setup' );
</code></pre>
<p>can help d... | [
{
"answer_id": 154578,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": true,
"text": "<p>The header image is already set to 100% width by default. Check lines 571-578 in style.css of the twenty... | 2014/07/15 | [
"https://wordpress.stackexchange.com/questions/154570",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3327/"
] | if
```
function wpse_custom_header_setup() {
add_theme_support( 'custom-header', apply_filters( 'wpse_header_args', array(
'width' => 1460,
'height' => 220,
) ) );
}
add_action( 'after_setup_theme', 'wpse_custom_header_setup' );
```
can help define the width of the header in... | The header image is already set to 100% width by default. Check lines 571-578 in style.css of the twenty fourteen theme
```
#site-header img {
max-width: 100%;
}
```
If you need a bigger header, you'll need to set the sizes accordingly in the code in your question, which I suppose you got from one of my previous... |
154,575 | <p>I have a select list in a metabox which value is saved successfully after clicking "Update" when editing post. Of course, the values are custom taxonomies. <strong>But i don't know how to add another select list and make it save its values successfully too...</strong></p>
<pre><code>add_action( 'add_meta_boxes', 's... | [
{
"answer_id": 154585,
"author": "Oleg Butuzov",
"author_id": 14536,
"author_profile": "https://wordpress.stackexchange.com/users/14536",
"pm_score": 1,
"selected": false,
"text": "<p>Well they share a same name... try to declare name as array.</p>\n\n<pre><code><select name=\"custom_... | 2014/07/15 | [
"https://wordpress.stackexchange.com/questions/154575",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56570/"
] | I have a select list in a metabox which value is saved successfully after clicking "Update" when editing post. Of course, the values are custom taxonomies. **But i don't know how to add another select list and make it save its values successfully too...**
```
add_action( 'add_meta_boxes', 'so_custom_meta_box' );
func... | Well they share a same name... try to declare name as array.
```
<select name="custom_element_grid_class[]" id="custom_element_grid_class">
``` |
154,579 | <p>WordPress default setting is, most recent post is the first post of the blog.</p>
<p>But, I need to "Most commented post should be the first post in the blog". ( Categories page as well as home page)</p>
| [
{
"answer_id": 154581,
"author": "Bindiya Patoliya",
"author_id": 34932,
"author_profile": "https://wordpress.stackexchange.com/users/34932",
"pm_score": 1,
"selected": false,
"text": "<p>WP Query has a comment_count parameter since 2.9.</p>\n\n<p>You can use <code>'orderby' => 'comme... | 2014/07/15 | [
"https://wordpress.stackexchange.com/questions/154579",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56576/"
] | WordPress default setting is, most recent post is the first post of the blog.
But, I need to "Most commented post should be the first post in the blog". ( Categories page as well as home page) | Alex, the codex is your friend. You have a parameter `orderby` which you can set to order posts by `comment_count`. You can get the complete list of parameters accepted by `orderby` in the codex page about [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query)
There is no need for any custom query, you can ... |
154,595 | <p>I've read the codex article about <a href="http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters" rel="nofollow"><code>WP_Query</code>'s <code>orderby</code> parameters</a> and I understood that it is possible to order by Modified date. But I couldn't find where should I edit. </p>
<p>How... | [
{
"answer_id": 154596,
"author": "Nilambar Sharma",
"author_id": 27998,
"author_profile": "https://wordpress.stackexchange.com/users/27998",
"pm_score": 3,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>function my_custom_ordering( $query ) {\n if($query->is_main_query(... | 2014/07/15 | [
"https://wordpress.stackexchange.com/questions/154595",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56576/"
] | I've read the codex article about [`WP_Query`'s `orderby` parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters) and I understood that it is possible to order by Modified date. But I couldn't find where should I edit.
How WordPress post order by modified date including home page... | Try this:
```
function my_custom_ordering( $query ) {
if($query->is_main_query() AND !is_admin() ) {
if ( $query->is_home() || $query->is_category() || $query->is_tag() ){
$query->set( 'orderby', 'modified' );
}
}
}
add_action( 'pre_get_posts', 'my_custom_ordering' );
```
This will ... |
154,598 | <p>For the plugin I'm building I have added a submenu as a child to a custom main menu item in admin. The submenu page is an <code>edit-tags.php</code> page. This shows up as intended under the main menu item. When clicking on this sub menu item, the user is taken to the correct page, however, the main menu item collap... | [
{
"answer_id": 154596,
"author": "Nilambar Sharma",
"author_id": 27998,
"author_profile": "https://wordpress.stackexchange.com/users/27998",
"pm_score": 3,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>function my_custom_ordering( $query ) {\n if($query->is_main_query(... | 2014/07/15 | [
"https://wordpress.stackexchange.com/questions/154598",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31382/"
] | For the plugin I'm building I have added a submenu as a child to a custom main menu item in admin. The submenu page is an `edit-tags.php` page. This shows up as intended under the main menu item. When clicking on this sub menu item, the user is taken to the correct page, however, the main menu item collapses back down,... | Try this:
```
function my_custom_ordering( $query ) {
if($query->is_main_query() AND !is_admin() ) {
if ( $query->is_home() || $query->is_category() || $query->is_tag() ){
$query->set( 'orderby', 'modified' );
}
}
}
add_action( 'pre_get_posts', 'my_custom_ordering' );
```
This will ... |
154,612 | <p>I'm trying to remove some cookies set to control persistent login when the user specifically wants to log out of a website.</p>
<p>I thought it would be as simple as:</p>
<pre><code>function remove_user_cookie() {
unset($_COOKIE['woai']);
unset($_COOKIE['woak']);
}
add_action('wp_logout', 'remove_user_co... | [
{
"answer_id": 154645,
"author": "TBI Infotech",
"author_id": 52417,
"author_profile": "https://wordpress.stackexchange.com/users/52417",
"pm_score": 1,
"selected": false,
"text": "<p>pls try below code</p>\n\n<pre><code>function remove_user_cookie() {\n\nsetcookie(\"woak\");\nsetcookie(... | 2014/07/15 | [
"https://wordpress.stackexchange.com/questions/154612",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56585/"
] | I'm trying to remove some cookies set to control persistent login when the user specifically wants to log out of a website.
I thought it would be as simple as:
```
function remove_user_cookie() {
unset($_COOKIE['woai']);
unset($_COOKIE['woak']);
}
add_action('wp_logout', 'remove_user_cookie');
```
I've al... | pls try below code
```
function remove_user_cookie() {
setcookie("woak");
setcookie("woai");
}
add_action('wp_logout', 'remove_user_cookie');
```
apart why you use cookie to storing some value ? suggest you to use session |
154,615 | <p>I can make a simple translation string like this:</p>
<pre><code><?php _e('Hello world','text-domain'); ?>
</code></pre>
<p>But how to make a translation string if there is a markup in it? For example this:</p>
<pre><code><?php _e('<span>Hello</span> world','text-domain'); ?>
</code></pre>... | [
{
"answer_id": 154626,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>Localizing a string with html markup inside the string can be a very opinionated story as you can see fr... | 2014/07/15 | [
"https://wordpress.stackexchange.com/questions/154615",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56588/"
] | I can make a simple translation string like this:
```
<?php _e('Hello world','text-domain'); ?>
```
But how to make a translation string if there is a markup in it? For example this:
```
<?php _e('<span>Hello</span> world','text-domain'); ?>
```
Is the above correct? | Localizing a string with html markup inside the string can be a very opinionated story as you can see from one of [my questions](https://wordpress.stackexchange.com/q/135866/31545) when I started out.
I would not say you are right, neither would I say that you are wrong, but I would say that your method is not prefere... |
154,624 | <p>My custom post type name is movie_reviews. Inside movie reviews there are multiple post but i need only that post whose id is 244. My code for it is </p>
<pre><code><?php
$my_query = new WP_Query('post_type=movie_reviews&ID=244');
while ($my_query->have_posts()) : $my_query->the_post();
... | [
{
"answer_id": 154631,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 5,
"selected": true,
"text": "<p>Have a look at the Post & Page Parameters Section in the <a href=\"http://codex.wordpress.org/Clas... | 2014/07/15 | [
"https://wordpress.stackexchange.com/questions/154624",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/53974/"
] | My custom post type name is movie\_reviews. Inside movie reviews there are multiple post but i need only that post whose id is 244. My code for it is
```
<?php
$my_query = new WP_Query('post_type=movie_reviews&ID=244');
while ($my_query->have_posts()) : $my_query->the_post();
the_content();
endwhile ?... | Have a look at the Post & Page Parameters Section in the [`WP_Query` Documentation](http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters)
For getting a Post by Post ID, you need to use this:
```
$my_query = new WP_Query('post_type=movie_reviews&p=244');
```
If you only need the content of on... |
154,638 | <p>I've noticed that wordpress allows me to send the wordpress options to javascript via wp_localize_script:</p>
<pre><code>wp_localize_script( $this->plugin_slug . '-plugin-script', 'wp_options', wp_load_alloptions() );
</code></pre>
<p>This way, my javascript can access different settings such as what day the we... | [
{
"answer_id": 154640,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 2,
"selected": true,
"text": "<p>Definitely a <em>really</em> bad idea. Just send what you need, exposing all this data publicly opens a lot (... | 2014/07/15 | [
"https://wordpress.stackexchange.com/questions/154638",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38440/"
] | I've noticed that wordpress allows me to send the wordpress options to javascript via wp\_localize\_script:
```
wp_localize_script( $this->plugin_slug . '-plugin-script', 'wp_options', wp_load_alloptions() );
```
This way, my javascript can access different settings such as what day the week start on and what date f... | Definitely a *really* bad idea. Just send what you need, exposing all this data publicly opens a lot (and some more) attack vectors. |
154,688 | <p>I'm trying to add a custom post type to a custom page called slides (admin.php?page=slides) and it doesn't want to work. This is my first attempt at a technical plugin using pages. The custom page gets created fine however when I include the function to generate the custom post type it doesn't load into the view. My... | [
{
"answer_id": 154640,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 2,
"selected": true,
"text": "<p>Definitely a <em>really</em> bad idea. Just send what you need, exposing all this data publicly opens a lot (... | 2014/07/15 | [
"https://wordpress.stackexchange.com/questions/154688",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27569/"
] | I'm trying to add a custom post type to a custom page called slides (admin.php?page=slides) and it doesn't want to work. This is my first attempt at a technical plugin using pages. The custom page gets created fine however when I include the function to generate the custom post type it doesn't load into the view. My pa... | Definitely a *really* bad idea. Just send what you need, exposing all this data publicly opens a lot (and some more) attack vectors. |
154,719 | <p>I'm using <a href="https://github.com/olefredrik/foundationpress/" rel="nofollow">Foundation</a> as a base and starter theme. I'm trying to build and I can't seem to figure out how to hook into the menu that WordPress outputs and add a custom attribute to that menu's <code><li></code> tags. </p>
<p>The curren... | [
{
"answer_id": 156236,
"author": "Sarah",
"author_id": 57313,
"author_profile": "https://wordpress.stackexchange.com/users/57313",
"pm_score": -1,
"selected": false,
"text": "<p>This looks like <a href=\"https://stackoverflow.com/questions/6215797/wordpress-post-id-in-wp-nav-menu\">this<... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40873/"
] | I'm using [Foundation](https://github.com/olefredrik/foundationpress/) as a base and starter theme. I'm trying to build and I can't seem to figure out how to hook into the menu that WordPress outputs and add a custom attribute to that menu's `<li>` tags.
The current menu outputs like this:
```
<ul id="menu-main-menu... | Actually you can Achieve something similar pretty easy,but also for me was not that easy find an answer. I needed a similar thing for fullpage.js navigation.So i achived like this : i used an alreday existing wordpress menu field that i was not using and i've used its value to fullfil my needs
```
function add_specifi... |
154,725 | <p>I have to display custom taxonomy for every product which is i have selected for every product from back end.</p>
<p>I have created custom taxonomy <code>city</code> in that custom taxonomy i have added the <code>Nashik ,Mumbai</code> city.</p>
<p>In product page i have assigned custom taxonomy city <code>Nashik<... | [
{
"answer_id": 154727,
"author": "TBI Infotech",
"author_id": 52417,
"author_profile": "https://wordpress.stackexchange.com/users/52417",
"pm_score": 2,
"selected": true,
"text": "<p>Instead of using <a href=\"http://codex.wordpress.org/Function_Reference/wp_tag_cloud\" rel=\"nofollow\">... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154725",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39122/"
] | I have to display custom taxonomy for every product which is i have selected for every product from back end.
I have created custom taxonomy `city` in that custom taxonomy i have added the `Nashik ,Mumbai` city.
In product page i have assigned custom taxonomy city `Nashik` to that product that assigned city `Nashik` ... | Instead of using [wp\_tag\_cloud](http://codex.wordpress.org/Function_Reference/wp_tag_cloud)
pls try this in product page
```
<?php $terms = get_the_terms( $post->ID , 'city' );
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, 'city' );
... |
154,737 | <p>I have the following doubt related to the WordPress posts showed in the home page.</p>
<p>I know that in the home page I can show the latest published posts. But can I also show (before the latest posts) a specified number of "important" posts?</p>
<p>What can I do to implement this feature in my blog?</p>
<p>Tnx... | [
{
"answer_id": 154742,
"author": "Maartje",
"author_id": 34616,
"author_profile": "https://wordpress.stackexchange.com/users/34616",
"pm_score": 3,
"selected": true,
"text": "<p>Yes of course. One of the ways to achieve this is by adding an extra category to your posts which you call 'st... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154737",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I have the following doubt related to the WordPress posts showed in the home page.
I know that in the home page I can show the latest published posts. But can I also show (before the latest posts) a specified number of "important" posts?
What can I do to implement this feature in my blog?
Tnx | Yes of course. One of the ways to achieve this is by adding an extra category to your posts which you call 'sticky' or 'important' or something like that.
For the example I will choose 'important'. To only get the important posts you can write a loop which loops through this category.
For example:
```
<?php
$args =... |
154,743 | <p>At this <a href="http://www.ultimatefijivacations.com/destinations/coral-coast/royal-davui-island-resort/" rel="nofollow noreferrer">site</a> I have an error using the parent theme's <code>jquery.PrettyPhoto.js</code> This causes tabs not to load well nor gallery to work well it seems. The error states</p>
<pre><co... | [
{
"answer_id": 154753,
"author": "sabarnix",
"author_id": 56542,
"author_profile": "https://wordpress.stackexchange.com/users/56542",
"pm_score": 2,
"selected": false,
"text": "<p>I have checked your site jQuery migrate is not enqueued as the version of jquery enqueued is 1.8.3 and jquer... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154743",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12260/"
] | At this [site](http://www.ultimatefijivacations.com/destinations/coral-coast/royal-davui-island-resort/) I have an error using the parent theme's `jquery.PrettyPhoto.js` This causes tabs not to load well nor gallery to work well it seems. The error states
```
TypeError: $.browser is undefined
http://www.domain.com/wp-... | Something is messing up your queue. Your jQuery URL has 1.8.3 version, while that is neither default in WP 3.9.1 or actual file it points to (1.11.0). Migrate is not showing up for me either, likely because of issues there.
Effectively you are missing `jQuery.browser` because it was removed in version 1.9+ and migrate... |
154,758 | <p>i want to relation to custom post types.</p>
<p>I register post types with this code</p>
<pre><code>add_action('init', function(){
$args = array(
'public' => true,
'query_var' => true,
'rewrite' => array( 'slug' => '/' ),
'supports' => array( 'title... | [
{
"answer_id": 154753,
"author": "sabarnix",
"author_id": 56542,
"author_profile": "https://wordpress.stackexchange.com/users/56542",
"pm_score": 2,
"selected": false,
"text": "<p>I have checked your site jQuery migrate is not enqueued as the version of jquery enqueued is 1.8.3 and jquer... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154758",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37077/"
] | i want to relation to custom post types.
I register post types with this code
```
add_action('init', function(){
$args = array(
'public' => true,
'query_var' => true,
'rewrite' => array( 'slug' => '/' ),
'supports' => array( 'title', 'excerpt'),
'query_var' ... | Something is messing up your queue. Your jQuery URL has 1.8.3 version, while that is neither default in WP 3.9.1 or actual file it points to (1.11.0). Migrate is not showing up for me either, likely because of issues there.
Effectively you are missing `jQuery.browser` because it was removed in version 1.9+ and migrate... |
154,765 | <p>In my archive page I want a certain category not to display. The rest of the code I'm adding, but it goes to a custom page </p>
<p>The logic is like, if is <code>category=33</code>, then include photo.php</p>
<pre><code><div class="latest_from_category">
<h2 class="latest_frm_cat_title archive_title">... | [
{
"answer_id": 154797,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 0,
"selected": false,
"text": "<p>Well, the template hierarchy allows you to use a custom template file for categories. </p>\n\n<p><a h... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154765",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54788/"
] | In my archive page I want a certain category not to display. The rest of the code I'm adding, but it goes to a custom page
The logic is like, if is `category=33`, then include photo.php
```
<div class="latest_from_category">
<h2 class="latest_frm_cat_title archive_title"><?php if (have_posts()) : ?>
<?php $post = $... | You could use [`template_include`](http://codex.wordpress.org/Plugin_API/Filter_Reference/template_include) conditionally.
```
add_filter( 'template_include', 'wpsites_photo_page_template', 99 );
function wpsites_photo_page_template( $template ) {
if ( is_category('33') ) {
$new_template = locate_templat... |
154,767 | <p>I'm facing the following:</p>
<p>I need to create a page with all authors and exclude multiple (id's). Strangely I'm using 'subscribers' to list the authors but it's working.</p>
<pre><code> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<h1><?php the_title() ?>... | [
{
"answer_id": 154769,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 3,
"selected": true,
"text": "<p>First, let me say that it is not \"Strangely\" working using 'subscribers' role. Note that you are taking out ... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154767",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20548/"
] | I'm facing the following:
I need to create a page with all authors and exclude multiple (id's). Strangely I'm using 'subscribers' to list the authors but it's working.
```
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<h1><?php the_title() ?></h1>
<?php the_content(); ?>
... | First, let me say that it is not "Strangely" working using 'subscribers' role. Note that you are taking out the 'subscriber' role from the results.
The correct way to get only authors and exclude some IDs is using the `role` and `exclude` arguments of [`get_users()`](http://codex.wordpress.org/Function_Reference/get_u... |
154,771 | <p>Is it possible to calculate the percentage of posts in each given category? I'd like to make a bar chart to visualize the amout of posts in those categories.</p>
<p>I thought what one needs would be the total amount of posts, the amount of posts in each category and then a PHP function that calculates percentages w... | [
{
"answer_id": 154798,
"author": "deflime",
"author_id": 18907,
"author_profile": "https://wordpress.stackexchange.com/users/18907",
"pm_score": 3,
"selected": true,
"text": "<p>With a little CSS, this will create a list of categories like so:</p>\n\n<p><img src=\"https://i.stack.imgur.c... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52621/"
] | Is it possible to calculate the percentage of posts in each given category? I'd like to make a bar chart to visualize the amout of posts in those categories.
I thought what one needs would be the total amount of posts, the amount of posts in each category and then a PHP function that calculates percentages with those ... | With a little CSS, this will create a list of categories like so:

Basic CSS:
```
<style>
.bar { height:4px; background:blue; }
</style>
```
The PHP:
```
<?php
// To customize visit http://codex.wordpress.org/Function_Reference/get_categ... |
154,773 | <p>Bit of background: I am building an autocompleting-search box for a list of Trades (a Custom Taxonomy). I asked <a href="https://wordpress.stackexchange.com/questions/154693/jquery-ui-autocomplete-showing-all-results?noredirect=1#comment222899_154693">this question</a> and very helpfully got a much better understand... | [
{
"answer_id": 154798,
"author": "deflime",
"author_id": 18907,
"author_profile": "https://wordpress.stackexchange.com/users/18907",
"pm_score": 3,
"selected": true,
"text": "<p>With a little CSS, this will create a list of categories like so:</p>\n\n<p><img src=\"https://i.stack.imgur.c... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154773",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27548/"
] | Bit of background: I am building an autocompleting-search box for a list of Trades (a Custom Taxonomy). I asked [this question](https://wordpress.stackexchange.com/questions/154693/jquery-ui-autocomplete-showing-all-results?noredirect=1#comment222899_154693) and very helpfully got a much better understanding of how Wor... | With a little CSS, this will create a list of categories like so:

Basic CSS:
```
<style>
.bar { height:4px; background:blue; }
</style>
```
The PHP:
```
<?php
// To customize visit http://codex.wordpress.org/Function_Reference/get_categ... |
154,780 | <p>hey wordpress experts,</p>
<p>We have coded a table using php, javascript and css which pulls up information from a text file and displays it in the browser.
We have everything working as desired when we set up our files on a local server.</p>
<p>However, we are trying to integrate our finished product into a page... | [
{
"answer_id": 154798,
"author": "deflime",
"author_id": 18907,
"author_profile": "https://wordpress.stackexchange.com/users/18907",
"pm_score": 3,
"selected": true,
"text": "<p>With a little CSS, this will create a list of categories like so:</p>\n\n<p><img src=\"https://i.stack.imgur.c... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154780",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56661/"
] | hey wordpress experts,
We have coded a table using php, javascript and css which pulls up information from a text file and displays it in the browser.
We have everything working as desired when we set up our files on a local server.
However, we are trying to integrate our finished product into a page on a wordpress w... | With a little CSS, this will create a list of categories like so:

Basic CSS:
```
<style>
.bar { height:4px; background:blue; }
</style>
```
The PHP:
```
<?php
// To customize visit http://codex.wordpress.org/Function_Reference/get_categ... |
154,799 | <p>I'm using the following code to display categories on my homepage, what I'd like to do is add the ability for paging with previous and next links, I haven't been able to figure out how to do this with a <code>foreach</code> can anyone point me in the right direction?</p>
<p><strong>Original Code:</strong></p>
<pre... | [
{
"answer_id": 154835,
"author": "user3325126",
"author_id": 56674,
"author_profile": "https://wordpress.stackexchange.com/users/56674",
"pm_score": -1,
"selected": false,
"text": "<p>Here's some pagination I used for a foreach loop:</p>\n\n<pre><code>function foreach_pagination( $curren... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154799",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9820/"
] | I'm using the following code to display categories on my homepage, what I'd like to do is add the ability for paging with previous and next links, I haven't been able to figure out how to do this with a `foreach` can anyone point me in the right direction?
**Original Code:**
```
<?php
$cat = get_cat_ID("Photos")... | I figured it out!
After a lot of research and trial and error, I managed to figure out how to get the paging to work for both versions...my original code and the simplified code update.
**Original Code Solution:**
```
<?php
$cat = get_cat_ID("Photos");
$categories = get_categories("child_of=$cat");
$lim... |
154,803 | <p>I need to create a blank PHP page that processes a POST request. Basically, a site will send me a few post variables. I need to use these variables with the mycred plugin.
Here is my code:</p>
<pre><code>require_once("../../../../wp-load.php");
if (isset($_POST['reward_amount'])) {
$toaward = $_POST['reward_amount... | [
{
"answer_id": 154813,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>You see a lot of code out there which includes <code>wp-load.php</code> or <code>wp-blog-header.php</code> to use t... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154803",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56664/"
] | I need to create a blank PHP page that processes a POST request. Basically, a site will send me a few post variables. I need to use these variables with the mycred plugin.
Here is my code:
```
require_once("../../../../wp-load.php");
if (isset($_POST['reward_amount'])) {
$toaward = $_POST['reward_amount'];
$user ... | You see a lot of code out there which includes `wp-load.php` or `wp-blog-header.php` to use the WordPress API within a php page loaded outside the context of WordPress. There's often a better way to accomplish this. It's also worth noting that any plugin which does that will get rejected from the WordPress.org plugin r... |
154,820 | <p>I have a custom post type set up (two, actually) that are not displaying properly. I am hoping that it is the same issue with both post types.</p>
<p>Here is my code for one of the post types (portfolio). The second is quite similar.</p>
<pre><code><?php
add_action('init', 'ccd_portfolio');
function ccd_portfo... | [
{
"answer_id": 167344,
"author": "DavGarcia",
"author_id": 48539,
"author_profile": "https://wordpress.stackexchange.com/users/48539",
"pm_score": 0,
"selected": false,
"text": "<p>I had a similar issue - added a new Custom Post Type whose slug was an old page. After permanently deleting... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154820",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36204/"
] | I have a custom post type set up (two, actually) that are not displaying properly. I am hoping that it is the same issue with both post types.
Here is my code for one of the post types (portfolio). The second is quite similar.
```
<?php
add_action('init', 'ccd_portfolio');
function ccd_portfolio() {
$labels = a... | As per the OP's answer that was added in their question, I've separated it instead. In short:
>
> *...deactivating and reactivating plugins, commenting and uncommenting, I now have my site working as intended.*
>
>
>
Here's the elaboration given by the OP as well:
>
> *I have a couple of custom post types in my... |
154,825 | <p>I am creating a plugin (my first) which allows the site admin to display the most used post tags over the last X number of days. This plugin is an evolution of the WP Development question here - <a href="https://wordpress.stackexchange.com/questions/48557/display-list-of-most-used-tags-in-the-last-30-days">Display l... | [
{
"answer_id": 167344,
"author": "DavGarcia",
"author_id": 48539,
"author_profile": "https://wordpress.stackexchange.com/users/48539",
"pm_score": 0,
"selected": false,
"text": "<p>I had a similar issue - added a new Custom Post Type whose slug was an old page. After permanently deleting... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154825",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14558/"
] | I am creating a plugin (my first) which allows the site admin to display the most used post tags over the last X number of days. This plugin is an evolution of the WP Development question here - [Display list of most used tags in the last 30 days](https://wordpress.stackexchange.com/questions/48557/display-list-of-most... | As per the OP's answer that was added in their question, I've separated it instead. In short:
>
> *...deactivating and reactivating plugins, commenting and uncommenting, I now have my site working as intended.*
>
>
>
Here's the elaboration given by the OP as well:
>
> *I have a couple of custom post types in my... |
154,829 | <p>I'm trying to create a page that holds all categories of my custom post type as tabs, with a tab content.</p>
<p>I am able to display all the category names as tabs, but i need to run a query in each tab content area to the corresponding category.</p>
<p>So when I click on tab named "1" the tab content area should... | [
{
"answer_id": 154841,
"author": "deflime",
"author_id": 18907,
"author_profile": "https://wordpress.stackexchange.com/users/18907",
"pm_score": 3,
"selected": true,
"text": "<p>Try <code>'category_name' => $category->slug</code> instead of <code>'category_name' => $cat_name</co... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50121/"
] | I'm trying to create a page that holds all categories of my custom post type as tabs, with a tab content.
I am able to display all the category names as tabs, but i need to run a query in each tab content area to the corresponding category.
So when I click on tab named "1" the tab content area should only show posts ... | Try `'category_name' => $category->slug` instead of `'category_name' => $cat_name`.
You are also missing `wp_reset_postdata();` just after `endwhile;`. |
154,839 | <p>In wordpress theme twentyfourteen, I am wondering how to remove the sticky behavior of the top navigation with a 100% width header background image like <a href="http://braidingfreedom.com" rel="nofollow">this site</a>?</p>
<p>I would love to have a top image with full width and a max-height with the navigation jus... | [
{
"answer_id": 154867,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>Before I answer this question, I would believe that you have already created a <a href=\"http://codex.wo... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3327/"
] | In wordpress theme twentyfourteen, I am wondering how to remove the sticky behavior of the top navigation with a 100% width header background image like [this site](http://braidingfreedom.com)?
I would love to have a top image with full width and a max-height with the navigation just placed under it, but the navigatio... | Before I answer this question, I would believe that you have already created a [**child theme**](http://codex.wordpress.org/Child_Themes). **Reason:** You should **never** make any changes to a theme/plugin that you are not the author of. This includes core files
With that sorted, the behavior of the navigation menu i... |
154,843 | <p>OK I'm using this plugin: <a href="https://github.com/WP-API/WP-API/" rel="nofollow">https://github.com/WP-API/WP-API/</a> to turn my site into a rest full API and it's working great..
Then I'm using ths plugin to add custom post meta:
<a href="https://wordpress.org/plugins/types/" rel="nofollow">https://wordpress... | [
{
"answer_id": 168535,
"author": "user3159159",
"author_id": 48867,
"author_profile": "https://wordpress.stackexchange.com/users/48867",
"pm_score": 2,
"selected": false,
"text": "<p>If you know the key of your meta field then you can use this filter:</p>\n\n<pre><code>add_filter( 'json_... | 2014/07/16 | [
"https://wordpress.stackexchange.com/questions/154843",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25710/"
] | OK I'm using this plugin: <https://github.com/WP-API/WP-API/> to turn my site into a rest full API and it's working great..
Then I'm using ths plugin to add custom post meta:
<https://wordpress.org/plugins/types/>
My problem is i can't seem to query the url endpoint to return my my post meta as if i was querying this... | Custom posts ignore the normal filter - have a look at `class-wp-json-pages.php` to see how to do build one for custom posts.
```
<?php
/**
* Page post type handlers
*
* @package WordPress
* @subpackage JSON API
*/
/**
* Page post type handlers
*
* This class serves as a small addition on top of the basic pos... |
154,855 | <p>If I set <strong>Reading Settings</strong> > <strong>Posts Page</strong> (in other words, the <code>page_for_posts</code> option) to a static page, and then attempt to pass its URL through <code>url_to_postid()</code> it will return <code>0</code> - why is it?</p>
<p>I understand that it's technically no longer a s... | [
{
"answer_id": 172105,
"author": "Arnis",
"author_id": 64725,
"author_profile": "https://wordpress.stackexchange.com/users/64725",
"pm_score": 0,
"selected": false,
"text": "<p>Take a look a this function, it may be useful.\n<a href=\"http://codex.wordpress.org/Function_Reference/get_pag... | 2014/07/17 | [
"https://wordpress.stackexchange.com/questions/154855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33576/"
] | If I set **Reading Settings** > **Posts Page** (in other words, the `page_for_posts` option) to a static page, and then attempt to pass its URL through `url_to_postid()` it will return `0` - why is it?
I understand that it's technically no longer a static/post page, but is the posts page, however that page *still has ... | The reason you get 0 back is because of the test at the end of the function:
```
if ( ! empty( $query->posts ) && $query->is_singular )
return $query->post->ID;
else
return 0;
```
The posts page doesn't pass the `is_singular` test so 0 is returned.
If you have a URL and want to know if it's the posts page, ... |
154,861 | <p>I have followed the instructions from</p>
<ul>
<li><a href="https://help.ubuntu.com/community/WordPress" rel="nofollow">https://help.ubuntu.com/community/WordPress</a></li>
<li><a href="https://www.digitalocean.com/community/tutorials/how-to-configure-secure-updates-and-installations-in-wordpress-on-ubuntu" rel="no... | [
{
"answer_id": 155101,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": true,
"text": "<p>You are using Ubuntu package for WordPress right? Had you tried conventional install (just downloading official WP a... | 2014/07/17 | [
"https://wordpress.stackexchange.com/questions/154861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56687/"
] | I have followed the instructions from
* <https://help.ubuntu.com/community/WordPress>
* <https://www.digitalocean.com/community/tutorials/how-to-configure-secure-updates-and-installations-in-wordpress-on-ubuntu>
Every time I try to update or install a new plugin, I get the following error:
```
Downloading update fro... | You are using Ubuntu package for WordPress right? Had you tried conventional install (just downloading official WP archive and setting it up with LAMP)?
While it's not very "Linux way" maybe, it's commonly suggested to stick with that for WordPress. I briefly dealt with Ubuntu WP package in the past and ended up doin... |
154,873 | <p>How to make Next and Previous attached image navigation on the attachment page?</p>
<p>
' . __( 'Previous Image', '$text_domain' ) . '' ); ?>
' . __( 'Next Image', '$text_domain' ) . '' ); ?>
</p>
<p>working great :)</p>
| [
{
"answer_id": 154932,
"author": "keesiemeijer",
"author_id": 26057,
"author_profile": "https://wordpress.stackexchange.com/users/26057",
"pm_score": 0,
"selected": false,
"text": "<p>Use a <a href=\"http://codex.wordpress.org/Function_Reference/WP_Query#Date_Parameters\" rel=\"nofollow\... | 2014/07/17 | [
"https://wordpress.stackexchange.com/questions/154873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45239/"
] | How to make Next and Previous attached image navigation on the attachment page?
' . \_\_( 'Previous Image', '$text\_domain' ) . '' ); ?>
' . \_\_( 'Next Image', '$text\_domain' ) . '' ); ?>
working great :) | Use [`previous_image_link`](http://codex.wordpress.org/Function_Reference/previous_image_link) and [`next_image_link`](http://codex.wordpress.org/Function_Reference/next_image_link) in a image.php or attachment.php file.
```
<nav id="image-navigation" class="navigation image-navigation">
<div class="na... |
154,878 | <p>I am pretty new in WordPress development and I am trying to implement this custom theme that handle the so called <a href="http://lnx.asper-eritrea.com/" rel="nofollow"><strong>featured posts</strong></a></p>
<p>As you can see in the posts area of the homepage I have the <em>Articoli in evidenza</em> sub area that ... | [
{
"answer_id": 154883,
"author": "AndreaNobili",
"author_id": 29275,
"author_profile": "https://wordpress.stackexchange.com/users/29275",
"pm_score": -1,
"selected": false,
"text": "<p>Solved by myselfe using:</p>\n\n<pre><code><?\n // get the term using the slug and the tag taxono... | 2014/07/17 | [
"https://wordpress.stackexchange.com/questions/154878",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I am pretty new in WordPress development and I am trying to implement this custom theme that handle the so called [**featured posts**](http://lnx.asper-eritrea.com/)
As you can see in the posts area of the homepage I have the *Articoli in evidenza* sub area that contains my *featured posts* and under it the *Ultimi Ar... | There are a few errors which I want to address
First of all, you should never use [`query_posts`](http://codex.wordpress.org/Function_Reference/query_posts) to construct custom queries. This is not just my emphasis, but the codex as well. The one big problem with `query_posts` is, it many circumstances, pagination fai... |
154,898 | <p>What I'd like to achieve is to have images resize responsively – and for that I have to set 'width: 100%' – and at the same time set a maximum width to not have the image as wide as the content</p>
<p>To do that I use: </p>
<pre><code>img {
max-width: 100%;
height: auto;
width: 100%; /* to mak... | [
{
"answer_id": 154901,
"author": "Zammuuz",
"author_id": 40999,
"author_profile": "https://wordpress.stackexchange.com/users/40999",
"pm_score": 1,
"selected": false,
"text": "<p>From the link that you given the css properties applying to that image is</p>\n\n<pre><code>#content img{ max... | 2014/07/17 | [
"https://wordpress.stackexchange.com/questions/154898",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47229/"
] | What I'd like to achieve is to have images resize responsively – and for that I have to set 'width: 100%' – and at the same time set a maximum width to not have the image as wide as the content
To do that I use:
```
img {
max-width: 100%;
height: auto;
width: 100%; /* to make the image responsive ... | >
> The CSS
>
>
> Add the following code to your CSS file. That will make the images scalable according to screen size.
>
>
>
Obviously change the class tag if you want to set up just for a specific image class
>
> `img{ max-width: 100%; }`
>
>
> `img{ -ms-interpolation-mode: bicubic; }`
>
>
>
Then you n... |
154,910 | <p>I am trying to create Testimonial custom post and display using shortcode </p>
<pre><code>function create_post_type() {
register_post_type(
'testimonials',//new post type
array(
'labels' => array(
'name' => __( 'Testimonials' ),
'singular_name' =... | [
{
"answer_id": 154914,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 0,
"selected": false,
"text": "<p>Well, maybe you shouldn't set $args['posts id'] as this is not a supported argument for the get_posts... | 2014/07/17 | [
"https://wordpress.stackexchange.com/questions/154910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54434/"
] | I am trying to create Testimonial custom post and display using shortcode
```
function create_post_type() {
register_post_type(
'testimonials',//new post type
array(
'labels' => array(
'name' => __( 'Testimonials' ),
'singular_name' => __( 'Testimonial' ... | Well, maybe you shouldn't set $args['posts id'] as this is not a supported argument for the get\_posts function and instead use the "posts\_\_in" argument or instead switch to the "get\_post" function if you get the id parameter. Also, i'm not quite sure but i think you have to use quotes in the shortcode.
So your Sho... |
154,938 | <p>I am trying to programmatically log in a wordpress user, using the following function for that.</p>
<pre><code> public function auto_login( $user ) {
$username = $user;
if ( !is_user_logged_in() ) {
$user = get_user_by( 'login', $username );
wp_set_current_user( $u... | [
{
"answer_id": 154952,
"author": "sabarnix",
"author_id": 56542,
"author_profile": "https://wordpress.stackexchange.com/users/56542",
"pm_score": 2,
"selected": true,
"text": "<p>Do this on template_redirect hook. You can use wp_safe_redirect to redirect to different page in the blog. I ... | 2014/07/17 | [
"https://wordpress.stackexchange.com/questions/154938",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54952/"
] | I am trying to programmatically log in a wordpress user, using the following function for that.
```
public function auto_login( $user ) {
$username = $user;
if ( !is_user_logged_in() ) {
$user = get_user_by( 'login', $username );
wp_set_current_user( $user->ID, $user... | Do this on template\_redirect hook. You can use wp\_safe\_redirect to redirect to different page in the blog. I can't give you the code because I don't from where you are getting the $user |
154,956 | <p>I am trying to remove the margin-left:10px; from the first menu item in my main navigation. I am ussing a wordpress custom navigation for my site. </p>
<p>I have tried the :first-child method but this seems to remove the margin for all links not just the first. Is there another method you know of that can do this? ... | [
{
"answer_id": 154952,
"author": "sabarnix",
"author_id": 56542,
"author_profile": "https://wordpress.stackexchange.com/users/56542",
"pm_score": 2,
"selected": true,
"text": "<p>Do this on template_redirect hook. You can use wp_safe_redirect to redirect to different page in the blog. I ... | 2014/07/17 | [
"https://wordpress.stackexchange.com/questions/154956",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56730/"
] | I am trying to remove the margin-left:10px; from the first menu item in my main navigation. I am ussing a wordpress custom navigation for my site.
I have tried the :first-child method but this seems to remove the margin for all links not just the first. Is there another method you know of that can do this? Below is t... | Do this on template\_redirect hook. You can use wp\_safe\_redirect to redirect to different page in the blog. I can't give you the code because I don't from where you are getting the $user |