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
60,463
<p>I am using the following simple get attachment code to display all images attached to a certain post but I want to be able to exclude the images uploaded via a couple of custom meta boxes that are also attached to the post.</p> <p>For example, how could I exclude an image uploaded with a meta key of sample_image_1 ...
[ { "answer_id": 60477, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": true, "text": "<p>Get all of the attachment IDs from your meta fields, put them in an array, and pass that as <code>exclude</code> par...
2012/08/01
[ "https://wordpress.stackexchange.com/questions/60463", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18547/" ]
I am using the following simple get attachment code to display all images attached to a certain post but I want to be able to exclude the images uploaded via a couple of custom meta boxes that are also attached to the post. For example, how could I exclude an image uploaded with a meta key of sample\_image\_1 from thi...
Get all of the attachment IDs from your meta fields, put them in an array, and pass that as `exclude` parameter of `get_posts`.
60,464
<p>I need to have different tag titles for each category of my website. I've tried all in one SEO but it looks like i cannot change it individually.</p> <p>Thanks in advance</p>
[ { "answer_id": 60467, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": true, "text": "<p>Would you mind using the \"description\" field for tags as the SEO title? If so:</p>\n\n<pre><code>add_filte...
2012/08/01
[ "https://wordpress.stackexchange.com/questions/60464", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18809/" ]
I need to have different tag titles for each category of my website. I've tried all in one SEO but it looks like i cannot change it individually. Thanks in advance
Would you mind using the "description" field for tags as the SEO title? If so: ``` add_filter( 'single_term_title', 'wpse_60464_title_from_description' ); function wpse_60464_title_from_description( $title ) { if ( ( $obj = get_queried_object() ) && ! empty( $obj->description ) ) $title = $obj->description...
60,468
<p>I'm developing a system where user can buy scratch card number using pre-paid balance. I already created balance system using user meta. Now I need to delivery card number to users upon payment. As payment system is ready, I need an idea which will help me to deliver card number. Card numbers will be stored in datab...
[ { "answer_id": 60535, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 3, "selected": true, "text": "<p>Here is an idea how we can sort the post based on custom field value and also I'd given some functions to change/d...
2012/08/01
[ "https://wordpress.stackexchange.com/questions/60468", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8096/" ]
I'm developing a system where user can buy scratch card number using pre-paid balance. I already created balance system using user meta. Now I need to delivery card number to users upon payment. As payment system is ready, I need an idea which will help me to deliver card number. Card numbers will be stored in database...
Here is an idea how we can sort the post based on custom field value and also I'd given some functions to change/delete custom field values. ``` <?php $args = array( 'post_type' => 'card', // custom post type name - card 'meta_query' => array( 'relation' => 'AND', // return post with meta-field key sta...
60,473
<p>I have a landing page that, among other things, features an excerpt from the most recent post with a "Continue Reading" link that should take the reader to the most recent post.</p> <p>In my search, I've found a lot of guides on how to link to the most recent post within a specified category, but not much on the mo...
[ { "answer_id": 60476, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>If you query for a single post, you'll get the latest by default:</p>\n\n<pre><code>$latest = new WP_Query( array( ...
2012/08/01
[ "https://wordpress.stackexchange.com/questions/60473", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14606/" ]
I have a landing page that, among other things, features an excerpt from the most recent post with a "Continue Reading" link that should take the reader to the most recent post. In my search, I've found a lot of guides on how to link to the most recent post within a specified category, but not much on the most recent ...
This code uses snippet from @Milo to suit your requirement. **Replace the code you've provided in question with this -** ``` <li> <h2><a href="http://growingedgecoaching.com/blog">Growing Edge Blog</a></h2> <?php $latest = new WP_Query( array( 'posts_per_page' => 1 ) ); while( $latest->have_posts() ) ...
60,490
<p>How does one get a custom post by id? FYI: I am passing a particular post id through a form and it's performing an ajax call.</p> <p>I'd like to retrieve just one post and grab the title:</p> <pre><code>&lt;?php // E.g. $loc = 700 $args = array('post_id'=&gt;$loc, 'post_type'=&gt;'seminars', 'limit'=&gt; '1'); $...
[ { "answer_id": 60483, "author": "mrwweb", "author_id": 9844, "author_profile": "https://wordpress.stackexchange.com/users/9844", "pm_score": 3, "selected": false, "text": "<p>The contents of a shortcode should always be <code>return</code>ed rather than <code>echo</code>ed. You can read ...
2012/08/01
[ "https://wordpress.stackexchange.com/questions/60490", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5149/" ]
How does one get a custom post by id? FYI: I am passing a particular post id through a form and it's performing an ajax call. I'd like to retrieve just one post and grab the title: ``` <?php // E.g. $loc = 700 $args = array('post_id'=>$loc, 'post_type'=>'seminars', 'limit'=> '1'); $loop = new WP_Query($args); // St...
The contents of a shortcode should always be `return`ed rather than `echo`ed. You can read more about [shortcode output on the Codex](http://codex.wordpress.org/Shortcode_API#Output). A while ago, I asked a question about ["How to Return Loop Contents"](https://wordpress.stackexchange.com/questions/57000/how-to-return...
60,511
<p>This is my first time playing with WPMU, I'm trying to move an entire WPMU site into a subdomain of itself for a development environment. The site itself is using subdomains so I'm having a bit of trouble getting it working. Has anyone had this task/problem before?</p> <p>I need to move <code>http://example.com</...
[ { "answer_id": 60512, "author": "SickHippie", "author_id": 5434, "author_profile": "https://wordpress.stackexchange.com/users/5434", "pm_score": 3, "selected": true, "text": "<p>Multisite is meant to be either one or the other, and it's not meant to be changed. If I were you, I'd move i...
2012/08/01
[ "https://wordpress.stackexchange.com/questions/60511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18821/" ]
This is my first time playing with WPMU, I'm trying to move an entire WPMU site into a subdomain of itself for a development environment. The site itself is using subdomains so I'm having a bit of trouble getting it working. Has anyone had this task/problem before? I need to move `http://example.com` to `http://dev.ex...
Multisite is meant to be either one or the other, and it's not meant to be changed. If I were you, I'd move it to a testing domain rather than a subdomain, since you're going to have to change it back when it's time to move, and I don't know what sort of behaviors you'll see. [Tutorial here](http://welcome.totheinter....
60,521
<p>Im sorry that I am asking this but I have been searching for ages and for some reaseon the suggested custom user table dosn't work, it just gives me a username error.</p> <p>This is the code I am taking about:</p> <pre><code>define('CUSTOM_USER_TABLE','new_user_table'); define('CUSTOM_USER_META_TABLE', 'new_userme...
[ { "answer_id": 60534, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>When you create a new user in such a shared user table, the roles and capabilities are set for one site only. The <em>...
2012/08/01
[ "https://wordpress.stackexchange.com/questions/60521", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18824/" ]
Im sorry that I am asking this but I have been searching for ages and for some reaseon the suggested custom user table dosn't work, it just gives me a username error. This is the code I am taking about: ``` define('CUSTOM_USER_TABLE','new_user_table'); define('CUSTOM_USER_META_TABLE', 'new_usermeta_table'); ``` So ...
OK Guys. There is a way to do this without editing the core files! 1) Open up your WP-config.php file and add to the file the following code. This will change where WordPress gets it's users from. ``` define('CUSTOM_USER_TABLE','wp_users'); define('CUSTOM_USER_META_TABLE', 'wp_usermeta'); ``` Remember to replace th...
60,546
<h2>Task: What I'm trying to do</h2> <p>I'm fetching data via the <a href="http://codex.wordpress.org/HTTP_API" rel="nofollow">WP Http API</a> from a remote server. The data I'm getting back is <code>JSON</code> encoded. In one of my methods, I'm converting them back and then push it into a class variable, so I can us...
[ { "answer_id": 60548, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p><em><strong>Disclaimer</strong>: This doesn't answer my question completely.</em></p>\n\n<p>I just found out, that ...
2012/08/02
[ "https://wordpress.stackexchange.com/questions/60546", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/385/" ]
Task: What I'm trying to do --------------------------- I'm fetching data via the [WP Http API](http://codex.wordpress.org/HTTP_API) from a remote server. The data I'm getting back is `JSON` encoded. In one of my methods, I'm converting them back and then push it into a class variable, so I can use it later in some sc...
How does core do it? -------------------- After thinking again about it, I thought there [might be a case](https://github.com/WordPress/WordPress/blob/3.4.1/wp-includes/script-loader.php#L342) where WP does the same thing internally. And right: It does it. ### Example `~/wp-admin/load-scripts.php` ``` $wp_scripts = ...
60,572
<p>I don't get it why jQuery function is not working. I read on the interned how to load jQuery in wordpress, but with no success. Can anyone help me?</p> <p>What I did so far: I've put this in header.php inside tags:</p> <pre><code>&lt;?php wp_enqueue_script("jquery"); ?&gt; &lt;?php wp_head(); ?&gt; &lt;script t...
[ { "answer_id": 60622, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 2, "selected": false, "text": "<p>Wrap the code like this to make it <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQue...
2012/08/02
[ "https://wordpress.stackexchange.com/questions/60572", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18841/" ]
I don't get it why jQuery function is not working. I read on the interned how to load jQuery in wordpress, but with no success. Can anyone help me? What I did so far: I've put this in header.php inside tags: ``` <?php wp_enqueue_script("jquery"); ?> <?php wp_head(); ?> <script type="text/javascript" src="<?php blog...
Used this approach and it worked: ``` var $j = jQuery.noConflict(); ``` // code ``` $j(function() { ``` //code });
60,581
<p>I was wondering if there is any direct hook to inject some javascript into tinymce iframe?</p>
[ { "answer_id": 60619, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 0, "selected": false, "text": "<p>Not possible, Tinymce uses this <a href=\"http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/js/tinymc...
2012/08/02
[ "https://wordpress.stackexchange.com/questions/60581", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/421/" ]
I was wondering if there is any direct hook to inject some javascript into tinymce iframe?
WordPress injects its own external script files in the TinyMCE editor `iframe`, see for example the `wp-includes/js/tinymce/plugins/wpembed/plugin.js` file: ``` (function ( tinymce ) { 'use strict'; tinymce.PluginManager.add( 'wpembed', function ( editor, url ) { editor.on( 'init', function () { ...
60,599
<p>I want WordPress to return the first post image or a default image if no featured image has been set. My theme uses <code>the_post_thumbnail</code> many times, so I don't want to go through and change all references to a new function. I'd rather filter the core. Here's what I've added to <code>functions.php</code>:<...
[ { "answer_id": 60604, "author": "nvartolomei", "author_id": 18848, "author_profile": "https://wordpress.stackexchange.com/users/18848", "pm_score": 2, "selected": false, "text": "<p>Actually there isn't <code>the_post_thumbnail</code> filter applied anywhere.</p>\n\n<p>The one you could ...
2012/08/02
[ "https://wordpress.stackexchange.com/questions/60599", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11807/" ]
I want WordPress to return the first post image or a default image if no featured image has been set. My theme uses `the_post_thumbnail` many times, so I don't want to go through and change all references to a new function. I'd rather filter the core. Here's what I've added to `functions.php`: ``` add_filter('post_thu...
Figured it out: ``` function get_attachment_id_from_src( $image_src ) { global $wpdb; $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'"; $id = $wpdb->get_var($query); return $id; } add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 5 ); function my_post_image_html( $html, $po...
60,605
<p>Would like to change</p> <p>'label_username' => __( 'Username' ) on line 258 of wp-includes/general-template.php to 'label_username' => __( 'Username or Email' )</p> <p>Changing core files is a not recommended --- never never</p> <p>So any help to code a function to achieve this would really be appreciated.</p>
[ { "answer_id": 60606, "author": "nvartolomei", "author_id": 18848, "author_profile": "https://wordpress.stackexchange.com/users/18848", "pm_score": 1, "selected": false, "text": "<p>You should hook to the <code>gettext</code> filter which is called by <code>__()</code> function on domain...
2012/08/02
[ "https://wordpress.stackexchange.com/questions/60605", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6303/" ]
Would like to change 'label\_username' => \_\_( 'Username' ) on line 258 of wp-includes/general-template.php to 'label\_username' => \_\_( 'Username or Email' ) Changing core files is a not recommended --- never never So any help to code a function to achieve this would really be appreciated.
Try putting this in your functions.php ``` function wpse60605_change_username_label( $defaults ){ $defaults['label_username'] = __( 'Username or Email' ); return $defaults; } add_filter( 'login_form_defaults', 'wpse60605_change_username_label' ); ```
60,618
<p>I've read umpteen answers and questions about things that are very similar to this but I just can't get it to work for my specific situation.</p> <p>I have some posts with a category of "property". In <code>category.php</code> I want these posts to appear in ascending date order initially (as per usual). </p> <p>I...
[ { "answer_id": 88329, "author": "user1576978", "author_id": 23576, "author_profile": "https://wordpress.stackexchange.com/users/23576", "pm_score": 0, "selected": false, "text": "<p>i had this problem once, i believe you custom fiel is not set as INT right? for meta_value_num work it sho...
2012/08/02
[ "https://wordpress.stackexchange.com/questions/60618", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18851/" ]
I've read umpteen answers and questions about things that are very similar to this but I just can't get it to work for my specific situation. I have some posts with a category of "property". In `category.php` I want these posts to appear in ascending date order initially (as per usual). I then want to have a dropdow...
`'meta_value_num'` is not magic, it *casts* a value as numeric, however, to be properly cast as numeric, a value must be numeric compatible. In OP it's said that the field values are "numeric" but I bet there's something not numeric, e.g. a currency symbol like "10 $" or "$ 10.00", or other symbol like "10-". Also co...
60,621
<p>I have a problem with showing sticky posts in a custom loop. This is the code I'm using to for the custom loop: </p> <pre><code>&lt;?php $post_from_cat_a = new WP_Query(array( 'category_name' =&gt; 'events', //Get posts from category a 'posts_per_page'=&gt; 2 //Limit it to the latest one )); ...
[ { "answer_id": 60630, "author": "mrwweb", "author_id": 9844, "author_profile": "https://wordpress.stackexchange.com/users/9844", "pm_score": 0, "selected": false, "text": "<h2>Some background</h2>\n\n<p>You're trying to use <code>query_posts</code> AND <code>WP_Query</code> at the same t...
2012/08/02
[ "https://wordpress.stackexchange.com/questions/60621", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13214/" ]
I have a problem with showing sticky posts in a custom loop. This is the code I'm using to for the custom loop: ``` <?php $post_from_cat_a = new WP_Query(array( 'category_name' => 'events', //Get posts from category a 'posts_per_page'=> 2 //Limit it to the latest one )); if( $post_from_cat_a->h...
if you use `'post__in' => get_option('sticky_posts')` then you are only filtering on posts that are sticky. As mrwweb said you need to look at your query. Then think of the 'loop' you want. Do you want to show all posts in a specific query or all posts that are sticky in all categories? 1. You might need to do 2 ...
60,627
<p>I have the following code that I can't get working. I have two cloneable fields that are being output as one entity (URL and thumbnail image). These are cloned fields using the Meta Box Plugin by Deluxe Blogging, so I need to be able to do an if statement if there is nothing at all and then I need to be able to repe...
[ { "answer_id": 60629, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 0, "selected": false, "text": "<p>Set the last paramter as <code>false</code> to return multiple values for same custom field. Read more about <a h...
2012/08/02
[ "https://wordpress.stackexchange.com/questions/60627", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7662/" ]
I have the following code that I can't get working. I have two cloneable fields that are being output as one entity (URL and thumbnail image). These are cloned fields using the Meta Box Plugin by Deluxe Blogging, so I need to be able to do an if statement if there is nothing at all and then I need to be able to repeat ...
amit helped you out, but while we're at it you really shouldn't be echoing everything like that. Should probably try this instead: ``` <?php foreach ( $videoID as $value ) { ?> <div class="video-pops"> <a class="thumb video-pop-lb" data-video-pid="<?php echo $videoID; ?>"></a> <?php } ?> ``` And so on. ...
60,645
<p>I used WCK Custom Fields Creator to create a repeatable custom field for uploading pairs of images (one color, one black and white) to posts. So for example, one post may have three fields, with two images (one color and one bw) each making a total of six images per post. </p> <p>I am trying to create a page that o...
[ { "answer_id": 60729, "author": "Colin", "author_id": 6222, "author_profile": "https://wordpress.stackexchange.com/users/6222", "pm_score": 2, "selected": true, "text": "<p>Here is the code that worked. I had to get rid of the foreach loop and reference the array directly:\n </p>\n\n<...
2012/08/02
[ "https://wordpress.stackexchange.com/questions/60645", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6222/" ]
I used WCK Custom Fields Creator to create a repeatable custom field for uploading pairs of images (one color, one black and white) to posts. So for example, one post may have three fields, with two images (one color and one bw) each making a total of six images per post. I am trying to create a page that outputs the...
Here is the code that worked. I had to get rid of the foreach loop and reference the array directly: ``` <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $productimgs = get_post_meta( $post->ID, 'productimg', true ); $image_color = $productimgs[0]['product-image-color']; $image_bw = $productimgs[0][...
60,654
<p>Here's my setup:</p> <ul> <li>Parent "Gallery" page: _regular page, not custom type or anything _</li> <li>Several "Project" child pages (could be as few as 1, unlimited<br> number): <em>also normal pages</em></li> </ul> <p>Child pages will either have meta boxes or custom fields for entering stuff into my pre-for...
[ { "answer_id": 60729, "author": "Colin", "author_id": 6222, "author_profile": "https://wordpress.stackexchange.com/users/6222", "pm_score": 2, "selected": true, "text": "<p>Here is the code that worked. I had to get rid of the foreach loop and reference the array directly:\n </p>\n\n<...
2012/08/02
[ "https://wordpress.stackexchange.com/questions/60654", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18862/" ]
Here's my setup: * Parent "Gallery" page: \_regular page, not custom type or anything \_ * Several "Project" child pages (could be as few as 1, unlimited number): *also normal pages* Child pages will either have meta boxes or custom fields for entering stuff into my pre-formatted areas. I don't care if it's meta b...
Here is the code that worked. I had to get rid of the foreach loop and reference the array directly: ``` <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $productimgs = get_post_meta( $post->ID, 'productimg', true ); $image_color = $productimgs[0]['product-image-color']; $image_bw = $productimgs[0][...
60,656
<p>How can I display a gallery shortcode for pages who are children of the page with an ID of 9, and the regular content for pages who aren't? This is what I've tried so far, but it's not working:</p> <pre><code>&lt;?php global $wp_query; if( (9 == $ $wp_query-&gt;post-&gt;post_parent ) :?&gt; &lt;?php echo do_sho...
[ { "answer_id": 60660, "author": "pcarvalho", "author_id": 18559, "author_profile": "https://wordpress.stackexchange.com/users/18559", "pm_score": 2, "selected": true, "text": "<pre><code>$thispageid = get_the_ID();\n$thispageparent = get_ancestors($thispageid);\nif( in_array( 9, $thispag...
2012/08/02
[ "https://wordpress.stackexchange.com/questions/60656", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18862/" ]
How can I display a gallery shortcode for pages who are children of the page with an ID of 9, and the regular content for pages who aren't? This is what I've tried so far, but it's not working: ``` <?php global $wp_query; if( (9 == $ $wp_query->post->post_parent ) :?> <?php echo do_shortcode('[gallery link="file" ...
``` $thispageid = get_the_ID(); $thispageparent = get_ancestors($thispageid); if( in_array( 9, $thispageparent ) ) echo do_shortcode('[gallery link="file" columns="1" size="large"]'); else the_content(); ``` reference [get\_ancestors()](http://codex.wordpress.org/Function_Reference/get_ancestors)
60,666
<p>I will soon be building a site for a local Non-Profit Art Community, and they would like a to have a powerful <strong>contact/member management system</strong> that can do these key things:</p> <ol> <li>Store User Contact info (Address, Phone, Email, Website, regdate, etc.)</li> <li>Synchronize with a newsletter ma...
[ { "answer_id": 60660, "author": "pcarvalho", "author_id": 18559, "author_profile": "https://wordpress.stackexchange.com/users/18559", "pm_score": 2, "selected": true, "text": "<pre><code>$thispageid = get_the_ID();\n$thispageparent = get_ancestors($thispageid);\nif( in_array( 9, $thispag...
2012/08/03
[ "https://wordpress.stackexchange.com/questions/60666", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16368/" ]
I will soon be building a site for a local Non-Profit Art Community, and they would like a to have a powerful **contact/member management system** that can do these key things: 1. Store User Contact info (Address, Phone, Email, Website, regdate, etc.) 2. Synchronize with a newsletter mailing service, their preference ...
``` $thispageid = get_the_ID(); $thispageparent = get_ancestors($thispageid); if( in_array( 9, $thispageparent ) ) echo do_shortcode('[gallery link="file" columns="1" size="large"]'); else the_content(); ``` reference [get\_ancestors()](http://codex.wordpress.org/Function_Reference/get_ancestors)
60,669
<p>I am trying to display a logout link when users are logged in and make it disappear when they are not logged in. </p> <p>The code I have so far works for the login and register links due to a plugin that I have installed, so 'login' and 'register' disappear just fine, now for logout I need some assistance... Here i...
[ { "answer_id": 60674, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 2, "selected": false, "text": "<p>Try using <a href=\"http://codex.wordpress.org/Function_Reference/wp_loginout\" rel=\"nofollow\"><code...
2012/08/03
[ "https://wordpress.stackexchange.com/questions/60669", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18492/" ]
I am trying to display a logout link when users are logged in and make it disappear when they are not logged in. The code I have so far works for the login and register links due to a plugin that I have installed, so 'login' and 'register' disappear just fine, now for logout I need some assistance... Here is the code...
Try using [`wp_loginout()`](http://codex.wordpress.org/Function_Reference/wp_loginout). It automatically handles those conditions.
60,671
<p>I just can't win with this project! All of a sudden, each post's gallery photos are showing up in the excerpt/preview of the post. Each post has a gallery of images that should only be visible on the actual post's page. Can anyone see what might be causing this? </p> <p>Here is my code:</p> <pre><code>if ( has_po...
[ { "answer_id": 60676, "author": "pcarvalho", "author_id": 18559, "author_profile": "https://wordpress.stackexchange.com/users/18559", "pm_score": 2, "selected": true, "text": "<pre><code> if( ( is_page() || is_single() ) &amp;&amp; ( !is_home() &amp;&amp; !is_front_page() ) ){\n ...
2012/08/03
[ "https://wordpress.stackexchange.com/questions/60671", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17837/" ]
I just can't win with this project! All of a sudden, each post's gallery photos are showing up in the excerpt/preview of the post. Each post has a gallery of images that should only be visible on the actual post's page. Can anyone see what might be causing this? Here is my code: ``` if ( has_post_thumbnail() ) { ...
``` if( ( is_page() || is_single() ) && ( !is_home() && !is_front_page() ) ){ $content = strip_shortcodes( $original_content); } ``` **if its home or front page don't show gallery** ``` if( is_home() || is_front_page() ) { // don't show gallery $content = strip_shortcodes( ...
60,673
<p>I found this code on WPSE:</p> <pre><code>global $current_user, $post; $args = array( 'user_id' =&gt; $current_user-&gt;ID, 'post_id' =&gt; $post-&gt;ID ); $usercomment = get_comments( $args ); if ( 1 &lt;= count( $usercomment ) ) { echo 'disabled'; } else { comment_form(); } </code></pre> <p><sup>Note: It...
[ { "answer_id": 60676, "author": "pcarvalho", "author_id": 18559, "author_profile": "https://wordpress.stackexchange.com/users/18559", "pm_score": 2, "selected": true, "text": "<pre><code> if( ( is_page() || is_single() ) &amp;&amp; ( !is_home() &amp;&amp; !is_front_page() ) ){\n ...
2012/08/03
[ "https://wordpress.stackexchange.com/questions/60673", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18868/" ]
I found this code on WPSE: ``` global $current_user, $post; $args = array( 'user_id' => $current_user->ID, 'post_id' => $post->ID ); $usercomment = get_comments( $args ); if ( 1 <= count( $usercomment ) ) { echo 'disabled'; } else { comment_form(); } ``` Note: It seems to limit the number of comments per pos...
``` if( ( is_page() || is_single() ) && ( !is_home() && !is_front_page() ) ){ $content = strip_shortcodes( $original_content); } ``` **if its home or front page don't show gallery** ``` if( is_home() || is_front_page() ) { // don't show gallery $content = strip_shortcodes( ...
60,705
<p>I've encountered a strange error while developing a custom theme.</p> <p>After finishing editing the template for a custom post type single view, I passed onto working at the template files for pages and I ealized that Wordpress was actually pointing to index.php template file rather than page.php in my theme for g...
[ { "answer_id": 60709, "author": "vmassuchetto", "author_id": 7385, "author_profile": "https://wordpress.stackexchange.com/users/7385", "pm_score": 1, "selected": false, "text": "<p>First of all, enable <code>WP_DEBUG</code> in <code>wp-config.php</code>.</p>\n\n<p>Maybe you're changing t...
2012/08/03
[ "https://wordpress.stackexchange.com/questions/60705", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8421/" ]
I've encountered a strange error while developing a custom theme. After finishing editing the template for a custom post type single view, I passed onto working at the template files for pages and I ealized that Wordpress was actually pointing to index.php template file rather than page.php in my theme for generating ...
I'm going to answer my own question for the sake of people who might run in the same issue as me in my setup I had a plugin handling taxonomies; one of these had the rewrite slug set to "year" - well, it turns out this conflicts probably with date based archives (?) and caused my posts and pages not loading but rather...
60,754
<p>I have installed a WP on website A and I want the last post's links in site B. I haven't in site B any WP and I want to get the link of last post from website A. so I can't use WP API like WP_Query and so on..</p> <p>Is there possible I do this with remote connection to MuSql and get the last post link?</p> <p>How...
[ { "answer_id": 60765, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 1, "selected": false, "text": "<p>Assuming each site is WP, they'll both have RSS feeds. You're better off just to fetch the RSS feed and g...
2012/08/03
[ "https://wordpress.stackexchange.com/questions/60754", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8732/" ]
I have installed a WP on website A and I want the last post's links in site B. I haven't in site B any WP and I want to get the link of last post from website A. so I can't use WP API like WP\_Query and so on.. Is there possible I do this with remote connection to MuSql and get the last post link? How do this?
Assuming each site is WP, they'll both have RSS feeds. You're better off just to fetch the RSS feed and get the latest post link from that. WP even has some built in support RSS parsing! ``` <?php /** * An example of how to use fetch feed * * @uses fetch_feed * @return bool|string False on failure, the permal...
60,758
<p>I'm new to wordpress and hence facing some issues. </p> <p><strong>The use case scenario is as follows:</strong></p> <ol> <li>A user is displayed an application form to start a club in his school.</li> <li>The user fills the form and hits the 'Submit' button.</li> <li>The form needs to be validated.</li> <li>If th...
[ { "answer_id": 60760, "author": "pcarvalho", "author_id": 18559, "author_profile": "https://wordpress.stackexchange.com/users/18559", "pm_score": 2, "selected": false, "text": "<p>first, let me tell you that javascript validation works on client side. so if the user, disables js, you're ...
2012/08/03
[ "https://wordpress.stackexchange.com/questions/60758", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18901/" ]
I'm new to wordpress and hence facing some issues. **The use case scenario is as follows:** 1. A user is displayed an application form to start a club in his school. 2. The user fills the form and hits the 'Submit' button. 3. The form needs to be validated. 4. If the validation is successful, then data is stored in ...
You should use the `wp_ajax` or the `wp_ajax_nopriv` function. First of all you should put the the admin ajax url as the action attribute value in the submission form. ``` <form id="" action="<?php echo admin_url('admin-ajax.php'); ?>" method="post" class="form" > ``` That way the the form will be submitted to the ...
60,769
<p>If a plugin stores data in the usermeta tables what is the best practice method to delete these entries for all users in uninstall.php? I could access the database directly but is there another way?</p>
[ { "answer_id": 60770, "author": "bgallagh3r", "author_id": 18905, "author_profile": "https://wordpress.stackexchange.com/users/18905", "pm_score": 2, "selected": false, "text": "<p>Best practice is to prefix the meta data your plugin enters that way you can simply do something like a sea...
2012/08/03
[ "https://wordpress.stackexchange.com/questions/60769", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2178/" ]
If a plugin stores data in the usermeta tables what is the best practice method to delete these entries for all users in uninstall.php? I could access the database directly but is there another way?
You should not access the database directly, if at all possible. There are two main reasons for this: * If the database structure changes (unlikely), your queries may become outdated. Using functions like `delete_user_meta()` will ensure that your query should work properly for all WordPress versions (past, present, a...
60,776
<p>We have a plugin that allows us to manage custom post types and we'd like to add AJAX functionality in saving, editing, and deleting posts. I couldn't find similar problems in the internet so I'm wondering if this isn't something easily doable? </p>
[ { "answer_id": 60779, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 3, "selected": true, "text": "<p>You can technically make a XHR to post.php via JavaScript. Below is a proof-of-concept for saving/editing po...
2012/08/04
[ "https://wordpress.stackexchange.com/questions/60776", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6232/" ]
We have a plugin that allows us to manage custom post types and we'd like to add AJAX functionality in saving, editing, and deleting posts. I couldn't find similar problems in the internet so I'm wondering if this isn't something easily doable?
You can technically make a XHR to post.php via JavaScript. Below is a proof-of-concept for saving/editing posts only. I haven't tested it at all, so I'm sure you will need to tweak it. I wanted to give you a basic workflow for accomplishing something like this. You can take it and run with it if you need to extend it. ...
60,792
<p>I want to apply jquery lazyload plugin. For this to work I have to create a new attribute which is data-src place there the src value and then replace the src value with a specific value <code>'...nothing.gif'</code>. I found a <a href="http://wordpress.org/support/topic/add-new-data-attribute-into-get_image_tag-fun...
[ { "answer_id": 60841, "author": "pcarvalho", "author_id": 18559, "author_profile": "https://wordpress.stackexchange.com/users/18559", "pm_score": 4, "selected": true, "text": "<p>instead of replacing the alt tag you could <a href=\"https://stackoverflow.com/questions/3983029/regex-add-an...
2012/08/04
[ "https://wordpress.stackexchange.com/questions/60792", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16533/" ]
I want to apply jquery lazyload plugin. For this to work I have to create a new attribute which is data-src place there the src value and then replace the src value with a specific value `'...nothing.gif'`. I found a [solution on wordpress.org support](http://wordpress.org/support/topic/add-new-data-attribute-into-get_...
instead of replacing the alt tag you could [add-an-attribute-to-a-tag](https://stackoverflow.com/questions/3983029/regex-add-an-attribute-to-a-tag-in-html-php) ``` function add_lazyload($content) { $dom = new DOMDocument(); @$dom->loadHTML($content); foreach ($dom->getElementsByTagName('img') as $node)...
60,802
<p>I'm using my own upload.php file to upload images to:</p> <pre><code>$upload_dir = wp_upload_dir(); $targetDir = $upload_dir['path'].'/'; </code></pre> <p>It works like it should with this exception that images uploaded to <code>uploads/2012/08/</code> don't appear in <code>Media Library</code>. Is there any funct...
[ { "answer_id": 60806, "author": "nvartolomei", "author_id": 18848, "author_profile": "https://wordpress.stackexchange.com/users/18848", "pm_score": 0, "selected": false, "text": "<p>I think you should start digging in <a href=\"http://codex.wordpress.org/Function_Reference/media_handle_u...
2012/08/04
[ "https://wordpress.stackexchange.com/questions/60802", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17167/" ]
I'm using my own upload.php file to upload images to: ``` $upload_dir = wp_upload_dir(); $targetDir = $upload_dir['path'].'/'; ``` It works like it should with this exception that images uploaded to `uploads/2012/08/` don't appear in `Media Library`. Is there any function to "register" them there and in WP's databas...
It's because you're not registering them as a media type. Every upload is a WordPress post of the `attachment` type. To start, it would be something like this: ``` $file_name = 'Some Name'; $file_path = '/path/to/uploads/2012/08/04/newfile.jpg'; $file_url = 'http://url/to/uploads/2012/08/04/newfile.jpg'; $wp_filetype...
60,803
<p>How can I make the wordpress comments work with:</p> <pre><code>include(TEMPLATEPATH."/comments.php"); </code></pre> <p>instead of:</p> <pre><code>comments_template( '', true ); </code></pre> <p>Ay ideas? Ty</p>
[ { "answer_id": 60805, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 0, "selected": false, "text": "<p>That wont work because we cannot include the <code>comments.php</code> file as a template file. Our <code>comment...
2012/08/04
[ "https://wordpress.stackexchange.com/questions/60803", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2979/" ]
How can I make the wordpress comments work with: ``` include(TEMPLATEPATH."/comments.php"); ``` instead of: ``` comments_template( '', true ); ``` Ay ideas? Ty
Short answer: you *can't*. Longer answer: You can *include* `comments.php` as a *template-part* file inside another template, via: ``` get_template_part( 'comments.php' ) ``` ...but that won't actually make comments *work*, because the `comments_template()` template tag does far more than merely include the `comme...
60,817
<p>I have declared a variable in my single.php </p> <pre><code>$title = 'myvar'; </code></pre> <p>Can I get it in my comments.php without re-declaring it again?</p> <p>I use this code to get the comments.php templage:</p> <pre><code>&lt;? comments_template( '', true ); ?&gt; </code></pre> <p>Ty</p>
[ { "answer_id": 60818, "author": "John-Michael", "author_id": 12086, "author_profile": "https://wordpress.stackexchange.com/users/12086", "pm_score": -1, "selected": false, "text": "<p>You can use php session variables to utilize the myvar variable anywhere you want.</p>\n\n<pre><code>if(...
2012/08/04
[ "https://wordpress.stackexchange.com/questions/60817", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2979/" ]
I have declared a variable in my single.php ``` $title = 'myvar'; ``` Can I get it in my comments.php without re-declaring it again? I use this code to get the comments.php templage: ``` <? comments_template( '', true ); ?> ``` Ty
The [**`comments_template()`**](http://codex.wordpress.org/Function_Reference/comments_template) only accepts two parameters: `$file` (string) and `$separate_comments` (Boolean). So, it does not have a way to pass an arbitrary variable as a parameter. The two methods I generally use are: 1. Globalize the variable 2. ...
60,831
<p>I'm currently working on a Magazine style website and on the main page I have three different sections where I display the latest news. Slider, latest news and more news.</p> <p>The problem is I can't figure out how to avoid duplicate posts on each one.</p> <p>Here is a sample of the query:</p> <pre><code>// buil...
[ { "answer_id": 60832, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>First, you should be using <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow\"><code>W...
2012/08/04
[ "https://wordpress.stackexchange.com/questions/60831", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17913/" ]
I'm currently working on a Magazine style website and on the main page I have three different sections where I display the latest news. Slider, latest news and more news. The problem is I can't figure out how to avoid duplicate posts on each one. Here is a sample of the query: ``` // build query query_posts( $this->...
You can use a static class property to store a rolling list of posts that are used in previous queries. This method allows you to pass data between classes (widgets, modules, plugins, etc...), but will also work for a procedural workflow. Everything on the page that uses your intermediary class will know what posts to ...
60,838
<p>I'm trying to figure how to scale the_post_thumbnail to a specific width? Can you guys help?</p> <p>Currently I'm using </p> <pre><code>&lt;?php //Resize post thumbnail $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' ); $thumbnailHei...
[ { "answer_id": 60843, "author": "FlashingCursor", "author_id": 9276, "author_profile": "https://wordpress.stackexchange.com/users/9276", "pm_score": 3, "selected": true, "text": "<p>This should work:</p>\n\n<p>You could use:</p>\n\n<pre><code>add_image_size( 'category-thumb', 220, 9999 )...
2012/08/04
[ "https://wordpress.stackexchange.com/questions/60838", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15410/" ]
I'm trying to figure how to scale the\_post\_thumbnail to a specific width? Can you guys help? Currently I'm using ``` <?php //Resize post thumbnail $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' ); $thumbnailHeight = $thumbnail[1]; ...
This should work: You could use: ``` add_image_size( 'category-thumb', 220, 9999 ); //220 pixels wide (and unlimited height) ``` and then to display: ``` if ( has_post_thumbnail() ) { the_post_thumbnail( 'category-thumb' ); } ``` This will create a thumbnail size of 220 by "unlimited"... Set the featured image o...
60,859
<p>I'm looking to echo the number of posts per month since the blog began, and for months where there was no posts echo '0'. </p> <p>This is the output I want:</p> <p>January 1, February 3, March 8, April 3, ...</p> <p>Any help would be great. Dave</p>
[ { "answer_id": 60860, "author": "Varun Sridharan", "author_id": 18746, "author_profile": "https://wordpress.stackexchange.com/users/18746", "pm_score": 2, "selected": false, "text": "<p>So basically what you need to do is paste the following code in your theme’s sidebar.php file or any o...
2012/08/05
[ "https://wordpress.stackexchange.com/questions/60859", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5089/" ]
I'm looking to echo the number of posts per month since the blog began, and for months where there was no posts echo '0'. This is the output I want: January 1, February 3, March 8, April 3, ... Any help would be great. Dave
So basically what you need to do is paste the following code in your theme’s sidebar.php file or any other file where you want to display custom WordPress archives. ``` <?php global $wpdb; $limit = 0; $year_prev = null; $months = $wpdb->get_results("SELECT DISTINCT MONTH( post_date ) AS month,YEAR( post_date ) AS year...
60,890
<p>I wonder if there is a way to scale down uploaded media exactly to 50%.</p> <p>From what I see, with <code>add_image_size</code> you can only specify a width and a height in pixel.</p> <p>The idea is to upload high resolution images for Retina displays and then let Wordpress generate a custom image size scaled dow...
[ { "answer_id": 60860, "author": "Varun Sridharan", "author_id": 18746, "author_profile": "https://wordpress.stackexchange.com/users/18746", "pm_score": 2, "selected": false, "text": "<p>So basically what you need to do is paste the following code in your theme’s sidebar.php file or any o...
2012/08/05
[ "https://wordpress.stackexchange.com/questions/60890", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3192/" ]
I wonder if there is a way to scale down uploaded media exactly to 50%. From what I see, with `add_image_size` you can only specify a width and a height in pixel. The idea is to upload high resolution images for Retina displays and then let Wordpress generate a custom image size scaled down for standard displays. Th...
So basically what you need to do is paste the following code in your theme’s sidebar.php file or any other file where you want to display custom WordPress archives. ``` <?php global $wpdb; $limit = 0; $year_prev = null; $months = $wpdb->get_results("SELECT DISTINCT MONTH( post_date ) AS month,YEAR( post_date ) AS year...
60,918
<p>In the Jetpack plugin, the subscriptions module can be included in your blog by following these instructions:</p> <blockquote> <p>To use the Subscriptions widget, go to Appearance → Widgets. Drag the widget labeled “Blog Subscriptions (Jetpack)” into one of your sidebars and configure away.</p> </blockquote> ...
[ { "answer_id": 60925, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 2, "selected": false, "text": "<p>Right Now jetpack provides only way to embed subscriptions as sidebar widget. Registering a new sidebar would be ...
2012/08/05
[ "https://wordpress.stackexchange.com/questions/60918", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18951/" ]
In the Jetpack plugin, the subscriptions module can be included in your blog by following these instructions: > > To use the Subscriptions widget, go to Appearance → Widgets. Drag the > widget labeled “Blog Subscriptions (Jetpack)” into one of your > sidebars and configure away. > > > I am interested in includi...
Right Now jetpack provides only way to embed subscriptions as sidebar widget. Registering a new sidebar would be a better Idea to do so, and this will not take more than few seconds. ### Step 1 - Register a sidebar for jetpack Just drop in this code somewhere in your theme's `functions.php` file. ``` register_side...
60,929
<h1>Question</h1> <p>Is there a way that my registered users (if they are not the form is hidden so I don't need that) are restricted to submit the form more than 5 times per day, or 20 per month or whatever value I would use?</p> <p>And I would also need to display the number of sumbmissions they have left. If they al...
[ { "answer_id": 60939, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 1, "selected": false, "text": "<p>I don't know which forms you are using but the basic form submission loads the data into database.</p>\n\n<p>To b...
2012/08/05
[ "https://wordpress.stackexchange.com/questions/60929", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5499/" ]
Question ======== Is there a way that my registered users (if they are not the form is hidden so I don't need that) are restricted to submit the form more than 5 times per day, or 20 per month or whatever value I would use? And I would also need to display the number of sumbmissions they have left. If they already se...
As @amit wrote, the submission should have a daily counter that saves the count for that user, in the wp\_usermeta table. If you can run a cron job that runs daily, you can save the submission counter only. The daily cron can reset the counter on assigned time. But if you don't you should save the counter and the day ...
60,957
<p>This is an odd case I've run into. A site I've had for years started throwing this "error" when i try to make certain backend changes. It seems pervasive - If i try to install, update, activate or deactivate any plugin. I can still look at the list of plugins and view their settings, generally.</p> <p>Any thoug...
[ { "answer_id": 60977, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 3, "selected": false, "text": "<p>This particular message happens when a <a href=\"http://codex.wordpress.org/WordPress_Nonces\">nonce</a> ch...
2012/08/06
[ "https://wordpress.stackexchange.com/questions/60957", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4121/" ]
This is an odd case I've run into. A site I've had for years started throwing this "error" when i try to make certain backend changes. It seems pervasive - If i try to install, update, activate or deactivate any plugin. I can still look at the list of plugins and view their settings, generally. Any thoughts on where t...
This particular message happens when a [nonce](http://codex.wordpress.org/WordPress_Nonces) check fails. I'd say the likely cause is a conflict with the referer (as part of nonce security, WP checks to see if the referer was an admin page on the same domain & path). You can rule this out by defining a custom function...
60,958
<p>I am printing the description for a custom taxonomy of artists with the following code:</p> <pre><code>$terms = get_the_terms( $post-&gt;ID, 'artists'); if ( $terms ) { // loop through artists (could be multiple) foreach ( $terms as $term ) { $termid = 'artists_' . ($term-...
[ { "answer_id": 60975, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 3, "selected": false, "text": "<p>Apply <a href=\"http://codex.wordpress.org/Function_Reference/wpautop\" rel=\"noreferrer\"><code>wpautop</c...
2012/08/06
[ "https://wordpress.stackexchange.com/questions/60958", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18964/" ]
I am printing the description for a custom taxonomy of artists with the following code: ``` $terms = get_the_terms( $post->ID, 'artists'); if ( $terms ) { // loop through artists (could be multiple) foreach ( $terms as $term ) { $termid = 'artists_' . ($term->term_id); ...
Apply [`wpautop`](http://codex.wordpress.org/Function_Reference/wpautop) - it converts line breaks into `<br />` and double breaks into paragraphs. ``` echo wpautop( wptexturize( get_yoast_term_description() ) ); ```
60,978
<p>I'm completely new to <a href="http://wpmvc.org/" rel="nofollow">WPMVC</a>. Followed and finished their tutorial for creating plugins. Now I'm trying to add a search page to search <code>Venues</code> (that comes from their example!). This page should appear as a submenu page of the <code>Venues</code> menu. I creat...
[ { "answer_id": 61101, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 2, "selected": false, "text": "<p>Finally after a lot of digging into the core files, I found the way to add a <code>submenu</code> page....
2012/08/06
[ "https://wordpress.stackexchange.com/questions/60978", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4740/" ]
I'm completely new to [WPMVC](http://wpmvc.org/). Followed and finished their tutorial for creating plugins. Now I'm trying to add a search page to search `Venues` (that comes from their example!). This page should appear as a submenu page of the `Venues` menu. I created a file named `search.php` in the `app/views/admi...
Finally after a lot of digging into the core files, I found the way to add a `submenu` page. Here's the stepwise solution if anyone is stuck on it! Lets assume you want to add a submenu page called 'Sample'. 1.First, in the `app/config/bootstrap.php` file (you have to manually create it if it doesn't exist) of your p...
61,010
<p>i created a taxonomy page from archive.php , working based on thematic frame work. i tried a lot to make the sidebar working but it show nothing and even using firebug its not exist !</p> <pre><code>&lt;?php /** * Template Name: MEDIT * * … * * @package Thematic * @subpackage Templates */ // calling th...
[ { "answer_id": 61011, "author": "jhussey", "author_id": 17475, "author_profile": "https://wordpress.stackexchange.com/users/17475", "pm_score": 0, "selected": false, "text": "<p>If you have named your sidebar file sidebar.php then you should use get_sidebar() and not thematic_sidebar(). ...
2012/08/06
[ "https://wordpress.stackexchange.com/questions/61010", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16115/" ]
i created a taxonomy page from archive.php , working based on thematic frame work. i tried a lot to make the sidebar working but it show nothing and even using firebug its not exist ! ``` <?php /** * Template Name: MEDIT * * … * * @package Thematic * @subpackage Templates */ // calling the header.php ...
It working now this is the right template with the code i should use Thanks for help ``` <?php /** * Archive Template * * Displays an Archive index of post-type items. Other more specific archive templates * may override the display of this template for example the category.php. * * @package Thematic * @su...
61,016
<p>How could I make particular role access widgets administration menu (<em>wp-admin/widgets.php</em>), but <strong>not</strong> access other <a href="http://codex.wordpress.org/Roles_and_Capabilities#edit_theme_options" rel="nofollow" title="Roles and Capabilities / edit_theme_options">theme administration</a> menu el...
[ { "answer_id": 61023, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<h2>Confirming&hellip;</h2>\n\n<p>Yes, there's <em>currently</em> (WP 3.4.1) no way to modify the access arguments for...
2012/08/06
[ "https://wordpress.stackexchange.com/questions/61016", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18978/" ]
How could I make particular role access widgets administration menu (*wp-admin/widgets.php*), but **not** access other [theme administration](http://codex.wordpress.org/Roles_and_Capabilities#edit_theme_options "Roles and Capabilities / edit_theme_options") menu elements. I have got that far as to display **Appearance...
Confirming… ----------- Yes, there's *currently* (WP 3.4.1) no way to modify the access arguments for admin menu pages. The only one, that you can modify through the public wp API is the *»Comments«* menu item. All others are registered by hand. But there's help coming from [@scribu (read more at the trac ticket)](h...
61,017
<p>To integrate Zurb´s <a href="http://foundation.zurb.com/docs/orbit.php" rel="nofollow">Orbit Slider</a> in my theme, I´m trying to generate this HTML with WordPress:</p> <pre><code>&lt;div id="featured"&gt; &lt;img src="featured-image-1.jpg" alt="the-alt-tag" data-caption="#htmlCaption-1" /&gt; &lt;img src="fea...
[ { "answer_id": 61019, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 2, "selected": true, "text": "<p>I'd use the this code to print the image instead of using <code>the_post_thumbnail();</code>.</p>\n\n<p>So that th...
2012/08/06
[ "https://wordpress.stackexchange.com/questions/61017", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7584/" ]
To integrate Zurb´s [Orbit Slider](http://foundation.zurb.com/docs/orbit.php) in my theme, I´m trying to generate this HTML with WordPress: ``` <div id="featured"> <img src="featured-image-1.jpg" alt="the-alt-tag" data-caption="#htmlCaption-1" /> <img src="featured-image-2.jpg" alt="the-alt-tag" data-caption="#htm...
I'd use the this code to print the image instead of using `the_post_thumbnail();`. So that the `$slider_query->current_post` can be used to print the current iteration of post in WP\_Query loop. Eg. ``` <img src="<?php wp_get_attachment_url( get_post_thumbnail_id() ); ?>" alt="the-alt-tag" data-caption="#htmlCapt...
61,020
<p>I've been looking for a plugin that limits the tags dislayed in the tag cloud by date. Basically, I want all tags from a certain date forward. I've searched current plugins and haven't found anything that limits by date. </p> <p>Doing some research, I think I just need to modify the following line from:</p> <pre><...
[ { "answer_id": 61019, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 2, "selected": true, "text": "<p>I'd use the this code to print the image instead of using <code>the_post_thumbnail();</code>.</p>\n\n<p>So that th...
2012/08/06
[ "https://wordpress.stackexchange.com/questions/61020", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18984/" ]
I've been looking for a plugin that limits the tags dislayed in the tag cloud by date. Basically, I want all tags from a certain date forward. I've searched current plugins and haven't found anything that limits by date. Doing some research, I think I just need to modify the following line from: ``` $tags = get_term...
I'd use the this code to print the image instead of using `the_post_thumbnail();`. So that the `$slider_query->current_post` can be used to print the current iteration of post in WP\_Query loop. Eg. ``` <img src="<?php wp_get_attachment_url( get_post_thumbnail_id() ); ?>" alt="the-alt-tag" data-caption="#htmlCapt...
61,029
<p>I activated the post thumbnail by putting this in the <code>functions.php</code>:</p> <p><code>add_theme_support( 'post-thumbnails');</code></p> <p>And this in the <code>loop.php</code>:</p> <p><code>&lt;?php the_post_thumbnail('full', array ('class' =&gt; 'rollover')) ; ?&gt;</code></p> <p>And voila, the featur...
[ { "answer_id": 61031, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 1, "selected": false, "text": "<p>This is not a WordPress related, Anyway here is tip -</p>\n\n<p>You can not call a <code>&lt;?php .. ?&gt;</code>...
2012/08/06
[ "https://wordpress.stackexchange.com/questions/61029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18988/" ]
I activated the post thumbnail by putting this in the `functions.php`: `add_theme_support( 'post-thumbnails');` And this in the `loop.php`: `<?php the_post_thumbnail('full', array ('class' => 'rollover')) ; ?>` And voila, the featured image appears on the main page, hopefully with the class of "rollover." But what...
This is not a WordPress related, Anyway here is tip - You can not call a `<?php .. ?>` function into your `style.css` file. Instead set the background inline just as shown in this example, and apple styling. ``` <div style="background: url('<?php wp_get_attachment_image_src(); ?>');"> // blah blah ... </div> ```
61,041
<p>I'm needing some posts to have different title colors than others, and I figured this would be most conveniently accomplished by some sort of check box on the post creation/edit screen. How would I go about adding the check box, then retrieving the value in the template?</p> <p>Thanks</p>
[ { "answer_id": 72997, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 3, "selected": false, "text": "<p>Yes, that's right, you need a <a href=\"http://codex.wordpress.org/Function_Reference/add_meta_box\" rel=\"n...
2012/08/06
[ "https://wordpress.stackexchange.com/questions/61041", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18989/" ]
I'm needing some posts to have different title colors than others, and I figured this would be most conveniently accomplished by some sort of check box on the post creation/edit screen. How would I go about adding the check box, then retrieving the value in the template? Thanks
Yes, that's right, you need a [Custom Meta Box](http://codex.wordpress.org/Function_Reference/add_meta_box) that'll create the checkboxes in the Post Editing screen. ![post custom meta box](https://i.stack.imgur.com/baRUq.png) In this case, they are radio buttons, as we need only one value. The following is the code...
61,042
<p>I've got two custom fields for event posts: <code>event-start</code> and <code>event-end</code>. When I'm querying for current events, I'd like to show any post where the <code>event-start</code> OR the <code>event-end</code> is greater than or equal to today's date and I'd like to order them by <code>event-start</...
[ { "answer_id": 72997, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 3, "selected": false, "text": "<p>Yes, that's right, you need a <a href=\"http://codex.wordpress.org/Function_Reference/add_meta_box\" rel=\"n...
2012/08/06
[ "https://wordpress.stackexchange.com/questions/61042", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18003/" ]
I've got two custom fields for event posts: `event-start` and `event-end`. When I'm querying for current events, I'd like to show any post where the `event-start` OR the `event-end` is greater than or equal to today's date and I'd like to order them by `event-start` (not the default post\_date). I've created a query w...
Yes, that's right, you need a [Custom Meta Box](http://codex.wordpress.org/Function_Reference/add_meta_box) that'll create the checkboxes in the Post Editing screen. ![post custom meta box](https://i.stack.imgur.com/baRUq.png) In this case, they are radio buttons, as we need only one value. The following is the code...
61,072
<p>I'm using <a href="http://codex.wordpress.org/get_comments" rel="nofollow noreferrer">get_comments</a> to show lastest comments i.e.:</p> <pre><code>&lt;?php global $comments, $comment; $comments = get_comments( array( 'number' =&gt; '5', 'status' =&gt; 'approve', 'post_status' =&gt; 'publish' ) ); for...
[ { "answer_id": 61074, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 1, "selected": false, "text": "<blockquote>\n<h2>Note -</h2>\n<p>It uses the values stored in global variable - <code>wp_query</code>. Usually the ...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61072", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17048/" ]
I'm using [get\_comments](http://codex.wordpress.org/get_comments) to show lastest comments i.e.: ``` <?php global $comments, $comment; $comments = get_comments( array( 'number' => '5', 'status' => 'approve', 'post_status' => 'publish' ) ); foreach ( (array) $comments as $comment) { echo '<li>'.$comm...
Yay! We got filters! -------------------- Wrapping the result of the `$wpdb` comments query right into a filter callback (and a plugin) is the nice way of handling comments. ``` /* Plugin Name: »Kaisers« Comments without admin comments */ ! defined( 'ABSPATH' ) AND exit; add_filter( 'comments_array', 'wpse_61072_com...
61,088
<p>I have a basic understanding of <a href="http://au2.php.net/manual/en/function.serialize.php">serialize</a> (I come across it often when I'm migrating WordPress installs) and I just discovered <a href="http://au2.php.net/manual/en/function.json-encode.php">json_encode</a>.</p> <p>Given that serialize causes so much...
[ { "answer_id": 61094, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 5, "selected": true, "text": "<ul>\n<li>serialize representation can be stored in text and reversed</li>\n<li>JSON representation can be stored in tex...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61088", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4994/" ]
I have a basic understanding of [serialize](http://au2.php.net/manual/en/function.serialize.php) (I come across it often when I'm migrating WordPress installs) and I just discovered [json\_encode](http://au2.php.net/manual/en/function.json-encode.php). Given that serialize causes so much trouble with replacing strings...
* serialize representation can be stored in text and reversed * JSON representation can be stored in text but cannot always be precisely reversed Run this example: ``` $query = new WP_Query(); var_dump( $query ); var_dump( unserialize( serialize( $query ) ) ); var_dump( json_decode( json_encode( $query ) ) ); ``` *...
61,100
<p>I wonder if Wordpress is the best CMS or solution for what I wannt to do?</p> <p>I need to find some way to upload images to a post that I can loop as background images. Just like I can upload multiple images and Wordpress automatically creates a <code>gallery</code> I don't want that to happen, but use those image...
[ { "answer_id": 61107, "author": "Dalton Rooney", "author_id": 799, "author_profile": "https://wordpress.stackexchange.com/users/799", "pm_score": 0, "selected": false, "text": "<p>I think this plugin will do the trick: <a href=\"http://wordpress.org/extend/plugins/wp-supersized/\" rel=\"...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61100", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
I wonder if Wordpress is the best CMS or solution for what I wannt to do? I need to find some way to upload images to a post that I can loop as background images. Just like I can upload multiple images and Wordpress automatically creates a `gallery` I don't want that to happen, but use those images directly (without a...
You can do that within the loop using `wp_get_attachment_image`. Something like (not tested): ``` //loop starts //values for get_posts ( or wp query if you prefer) $args = array( 'post_type' => 'attachment', //gets the attachments aka your images 'numberposts' => -1, 'post_parent' => $post->ID ); // som...
61,105
<p>I am trying to set up a multi-level custom post type structure with permalinks that look like <code>authors/books/chapters</code>, with authors, books, and chapters all set up as their own custom post type. For example, a typical URL on this site might look like <code>example.com/authors/stephen-king/the-shining/cha...
[ { "answer_id": 61520, "author": "prettyboymp", "author_id": 203, "author_profile": "https://wordpress.stackexchange.com/users/203", "pm_score": 1, "selected": false, "text": "<p>The rules will get added to the extra_rules_top of WP_Rewrite in the order that the extra permastructs are add...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61105", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/799/" ]
I am trying to set up a multi-level custom post type structure with permalinks that look like `authors/books/chapters`, with authors, books, and chapters all set up as their own custom post type. For example, a typical URL on this site might look like `example.com/authors/stephen-king/the-shining/chapter-3/` Each chap...
If you want to keep 'authors' as the base slug in the permalinks, i.e. *example.com/authors/stephen-king/* for the 'authors' CPT, *example.com/authors/stephen-king/the-shining/* for the 'books' CPT and *example.com/authors/stephen-king/the-shining/chapter-3/* for the 'chapters' CPT, WordPress will think pretty much eve...
61,114
<p>I have 3 differents custom post type : &quot;Projet&quot;, &quot;Notice&quot; and &quot;Disque&quot;. I want them to appear in a specific order when they are listed in the <em>category</em> or the <em>tag</em> template page. Like that :</p> <h1>1 - Notice</h1> <h1>2 - Projet</h1> <h1>3 - Disque</h1> <p>I've tried to...
[ { "answer_id": 61121, "author": "RCNeil", "author_id": 12294, "author_profile": "https://wordpress.stackexchange.com/users/12294", "pm_score": -1, "selected": false, "text": "<pre><code>$args = array( 'post_type' =&gt; 'notices', 'posts_per_page' =&gt; 1 );\n$loop = get_posts( $args );\n...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61114", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19018/" ]
I have 3 differents custom post type : "Projet", "Notice" and "Disque". I want them to appear in a specific order when they are listed in the *category* or the *tag* template page. Like that : 1 - Notice ========== 2 - Projet ========== 3 - Disque ========== I've tried to catch te query string and use 3 different l...
someone [there](http://wordpress.org/support/topic/how-to-order-different-custom-post-type-in-category-or-tag-template-page?replies=5) help me and solved the problem. It works. Cool. Thks guys. Details : First - I remove this code from function.php ``` function namespace_add_custom_types( $query ) { if( ( is_tag() |...
61,122
<p>I have pages like <a href="http://www.101greatgoals.com/category/goals/" rel="nofollow">this</a> with a lot of social buttons. A lot means more than 50 buttons because each posts on that page has its own buttons.</p> <p>So maybe I'll make the page smaller, with less posts but this is not the main reason and not wha...
[ { "answer_id": 61121, "author": "RCNeil", "author_id": 12294, "author_profile": "https://wordpress.stackexchange.com/users/12294", "pm_score": -1, "selected": false, "text": "<pre><code>$args = array( 'post_type' =&gt; 'notices', 'posts_per_page' =&gt; 1 );\n$loop = get_posts( $args );\n...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61122", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17707/" ]
I have pages like [this](http://www.101greatgoals.com/category/goals/) with a lot of social buttons. A lot means more than 50 buttons because each posts on that page has its own buttons. So maybe I'll make the page smaller, with less posts but this is not the main reason and not what I am looking for. I want to know ...
someone [there](http://wordpress.org/support/topic/how-to-order-different-custom-post-type-in-category-or-tag-template-page?replies=5) help me and solved the problem. It works. Cool. Thks guys. Details : First - I remove this code from function.php ``` function namespace_add_custom_types( $query ) { if( ( is_tag() |...
61,136
<p>There are many scripts/hacks out there to insert ads into the middle of the post (after 'x' number of paragraphs), however I haven't found a good enough script that can do the above.</p> <p>This is the script that comes close,</p> <pre><code>&lt;?php $post_counter=0; ?&gt; &lt;?php if (have_posts()) : ?&gt; &lt;?p...
[ { "answer_id": 61141, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 5, "selected": true, "text": "<p>instead of a post counter, you could use the variable <code>$wp_query-&gt;current_post</code> - which starts with...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61136", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5411/" ]
There are many scripts/hacks out there to insert ads into the middle of the post (after 'x' number of paragraphs), however I haven't found a good enough script that can do the above. This is the script that comes close, ``` <?php $post_counter=0; ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post()...
instead of a post counter, you could use the variable `$wp_query->current_post` - which starts with 0 for the first post in the loop; for some output after the third post, use for instance this before the line with `endwhile;`: ``` <?php if( $wp_query->current_post == 2 ) { ?> DO SOMETHING <?php } ?> ```
61,142
<p>I'm actually just trying to mirror a GoDaddy site on a subdirectory of my personal 1&amp;1 hosting.</p> <p>I just strait up copy-pasted the file structure, and copied the Database, using a <a href="http://interconnectit.com/124/search-and-replace-for-wordpress-databases/" rel="nofollow noreferrer">search replace to...
[ { "answer_id": 61146, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": 1, "selected": false, "text": "<p>make sure your .htaccess file is correct.\ndid you copy that aswell?</p>\n" }, { "answer_id": 61156, ...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61142", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5846/" ]
I'm actually just trying to mirror a GoDaddy site on a subdirectory of my personal 1&1 hosting. I just strait up copy-pasted the file structure, and copied the Database, using a [search replace tool](http://interconnectit.com/124/search-and-replace-for-wordpress-databases/) to replace the base url with my new one. I t...
Ok, I'm a jerk. Somehow I overlooked the welcome.html file in the root of the wp install (for some reason this is a GoDaddy 404 page). Not sure what code is causing that to load instead of index.php, but there it is. I deleted this file, and voila! Everything works as expected. That was a waste of 6 hours haha.
61,147
<p>I have a parent category and several child categories. I also have several posts that belong to the child categories. Each post can be belong to several categories. I want to know how to query the post table so when I want to show all posts in parent category, I'll get all the post under the child categories. the re...
[ { "answer_id": 61146, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": 1, "selected": false, "text": "<p>make sure your .htaccess file is correct.\ndid you copy that aswell?</p>\n" }, { "answer_id": 61156, ...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61147", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19028/" ]
I have a parent category and several child categories. I also have several posts that belong to the child categories. Each post can be belong to several categories. I want to know how to query the post table so when I want to show all posts in parent category, I'll get all the post under the child categories. the resul...
Ok, I'm a jerk. Somehow I overlooked the welcome.html file in the root of the wp install (for some reason this is a GoDaddy 404 page). Not sure what code is causing that to load instead of index.php, but there it is. I deleted this file, and voila! Everything works as expected. That was a waste of 6 hours haha.
61,150
<p>I think I may have painted myself into a corner. I need to find a plugin, if such a thing exists, that will be a slider/text combo.</p> <p>My client loves the way the pics on this page slide up to show some text:http://p3mma.com/. The sliders here look like they are a. all images and b. just some sort of javascript...
[ { "answer_id": 61152, "author": "GhostToast", "author_id": 13676, "author_profile": "https://wordpress.stackexchange.com/users/13676", "pm_score": 1, "selected": false, "text": "<p>This is kind of a tough one, but you should be able to do this using a good base plugin and some tricky ima...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61150", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11543/" ]
I think I may have painted myself into a corner. I need to find a plugin, if such a thing exists, that will be a slider/text combo. My client loves the way the pics on this page slide up to show some text:http://p3mma.com/. The sliders here look like they are a. all images and b. just some sort of javascript and not i...
I don't know of a plugin, but you could do it yourself. Structure : * Each slide is a post. * Each post contains text and one image (uploaded throught media uploader) * To target the proper post, you could use differents techniques, the simpleiet is to use a category i.e. : "slider". Where you want to use the slid...
61,155
<p>I'd like to display a list of products for a certain category, sorted by the post_excerpt. The original code I used was this:</p> <pre><code>$args = array( 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'product_cat', 'field' =&gt; 'slug', 'terms' =&gt; array( 'my-p...
[ { "answer_id": 61152, "author": "GhostToast", "author_id": 13676, "author_profile": "https://wordpress.stackexchange.com/users/13676", "pm_score": 1, "selected": false, "text": "<p>This is kind of a tough one, but you should be able to do this using a good base plugin and some tricky ima...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61155", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17615/" ]
I'd like to display a list of products for a certain category, sorted by the post\_excerpt. The original code I used was this: ``` $args = array( 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => array( 'my-product-category' ), ...
I don't know of a plugin, but you could do it yourself. Structure : * Each slide is a post. * Each post contains text and one image (uploaded throught media uploader) * To target the proper post, you could use differents techniques, the simpleiet is to use a category i.e. : "slider". Where you want to use the slid...
61,170
<p>Hoping someone can answer this!</p> <p>I'm using this for my header and it is working:</p> <pre><code>&lt;img src="&lt;?php echo get_template_directory_uri(); ?&gt;/images/image.jpg"&gt; </code></pre> <p>But when I try to use it in a sidebar text widget it won't show the image. Any ideas?</p>
[ { "answer_id": 61173, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 3, "selected": false, "text": "<p>PHP code won't run inside of a text widget. There are plugins that will let you do that, but this type of th...
2012/08/08
[ "https://wordpress.stackexchange.com/questions/61170", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19034/" ]
Hoping someone can answer this! I'm using this for my header and it is working: ``` <img src="<?php echo get_template_directory_uri(); ?>/images/image.jpg"> ``` But when I try to use it in a sidebar text widget it won't show the image. Any ideas?
PHP code won't run inside of a text widget. There are plugins that will let you do that, but this type of thing is strongly discouraged. Add this code to your functions.php file, or better yet, make it a simple little plugin: ``` // Enable the use of shortcodes within widgets. add_filter( 'widget_text', 'do_shortcode...
61,171
<p>I use <a href="http://wordpress.org/extend/plugins/advanced-custom-fields/" rel="nofollow">Advanced Custom Fields</a> to show Vimeo videoes on a site I am creating for a client - The client pastes the vimeo ID (the last letters in the url) in a field, and the video is shown. But I would also like to show thumbnail o...
[ { "answer_id": 61172, "author": "ifdion", "author_id": 6383, "author_profile": "https://wordpress.stackexchange.com/users/6383", "pm_score": 3, "selected": true, "text": "<p>Maybe this can help</p>\n\n<pre><code>$videoID = the_field('video_link');\n$jsonurl = 'http://vimeo.com/api/v2/vid...
2012/08/07
[ "https://wordpress.stackexchange.com/questions/61171", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17400/" ]
I use [Advanced Custom Fields](http://wordpress.org/extend/plugins/advanced-custom-fields/) to show Vimeo videoes on a site I am creating for a client - The client pastes the vimeo ID (the last letters in the url) in a field, and the video is shown. But I would also like to show thumbnail of the video, I am using the f...
Maybe this can help ``` $videoID = the_field('video_link'); $jsonurl = 'http://vimeo.com/api/v2/video/'.$videoID.'.json'; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json,true); echo '<img src="'. $json_output[0]['thumbnail_large'] .'" />'; ``` It's the same call using json method
61,194
<p>I'm asked by my friend to create a widget for his multiauthor blog. He wants to list 3 authors with the most total post view from their posts. I've got the job done for the post view using post metadata. But I'm confused on querying the authors with that criteria. Any idea?</p> <p>Thanks for the help.</p> <p>[upda...
[ { "answer_id": 61206, "author": "Rajeev Vyas", "author_id": 6961, "author_profile": "https://wordpress.stackexchange.com/users/6961", "pm_score": 1, "selected": false, "text": "<p>There is no default wordpress api that will give you list of all users.. \nSo you have to manually write que...
2012/08/08
[ "https://wordpress.stackexchange.com/questions/61194", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16596/" ]
I'm asked by my friend to create a widget for his multiauthor blog. He wants to list 3 authors with the most total post view from their posts. I've got the job done for the post view using post metadata. But I'm confused on querying the authors with that criteria. Any idea? Thanks for the help. [update] I'm using thi...
> > List authors by Total Post Views - > ---------------------------------- > > > If `view` is custom field name then this functions will return all users in descending order as per their post's TOTAL view count. > > > * Just drop in this function in your theme's `functions.php` file . > * Call function `wpse_611...
61,233
<p>I am using this code to show a list of all categories in sidebar </p> <p><code>&lt;?php wp_list_cats('list=0&amp;sort_column=name&amp;optioncount=0&amp;hierarchical=0&amp;optioncount=1&amp;children=0'); ?&gt;</code></p> <p>but the problem is that is lists the child categories as well. so the final result using the...
[ { "answer_id": 61240, "author": "Roman", "author_id": 3817, "author_profile": "https://wordpress.stackexchange.com/users/3817", "pm_score": 3, "selected": true, "text": "<p><code>wp_list_cats</code> is deprecated. You should switch to the \"newer\" version <code>wp_list_categories</code>...
2012/08/08
[ "https://wordpress.stackexchange.com/questions/61233", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15061/" ]
I am using this code to show a list of all categories in sidebar `<?php wp_list_cats('list=0&sort_column=name&optioncount=0&hierarchical=0&optioncount=1&children=0'); ?>` but the problem is that is lists the child categories as well. so the final result using the above code is like : - category 1 - category 2 ...
`wp_list_cats` is deprecated. You should switch to the "newer" version `wp_list_categories` which also supports some additional options. For example the `depth` option, which is probably what you're looking for. See [the WordPress codex](http://codex.wordpress.org/Template_Tags/wp_list_categories) for more information....
61,235
<p>I created a custom post type and i want to display some text on the editor page below the title and above the text editor. How can i do this?</p> <p>I tried using add_meta_box, but i wasn't able to move it above the editor.</p>
[ { "answer_id": 61237, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 4, "selected": true, "text": "<p>The best way would be using JavaScript to inject the element.</p>\n\n<p>Here's the gist of the markup for that page:</...
2012/08/08
[ "https://wordpress.stackexchange.com/questions/61235", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8038/" ]
I created a custom post type and i want to display some text on the editor page below the title and above the text editor. How can i do this? I tried using add\_meta\_box, but i wasn't able to move it above the editor.
The best way would be using JavaScript to inject the element. Here's the gist of the markup for that page: ``` <div id="poststuff"> <div id="post-body" class="metabox-holder columns-2"> <div id="post-body-content"> <div id="titlediv"> ... other stuff ... </div> ...
61,244
<p>I am in the process of a theme, I would like to add landing pages using page-templates. I cannot find anywhere that shows how to enqueue style or js for specific page templates. Any suggestions. Ex. Landing Page 1 - landing-page-template-one.php will need very different style and js than the blog or homepage.</p>
[ { "answer_id": 61246, "author": "Edward Caissie", "author_id": 1952, "author_profile": "https://wordpress.stackexchange.com/users/1952", "pm_score": 5, "selected": false, "text": "<p>You can use the <code>is_page( 'landing-page-template-one' )</code> conditional around your page specific...
2012/08/08
[ "https://wordpress.stackexchange.com/questions/61244", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19055/" ]
I am in the process of a theme, I would like to add landing pages using page-templates. I cannot find anywhere that shows how to enqueue style or js for specific page templates. Any suggestions. Ex. Landing Page 1 - landing-page-template-one.php will need very different style and js than the blog or homepage.
You can use the `is_page( 'landing-page-template-one' )` conditional around your page specific styles / scripts as part of your over-all enqueue statements. ``` function my_enqueue_stuff() { if ( is_page( 'landing-page-template-one' ) ) { /** Call landing-page-template-one enqueue */ } else { /** Call regu...
61,272
<p><strong>My problem:</strong></p> <p>I'm trying to create a filter that will add the featured image of a post to the_content, so that I can have the first paragraph of the_content displayed before this image.</p> <p><strong>What I basicly want to achieve:</strong></p> <pre><code>&lt;p&gt;First Paragraph of the_con...
[ { "answer_id": 61274, "author": "bgallagh3r", "author_id": 18905, "author_profile": "https://wordpress.stackexchange.com/users/18905", "pm_score": 1, "selected": false, "text": "<p>Technically the quickest solution would be to use a shortcode in your content. Otherwise you'll need a goo...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61272", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4395/" ]
**My problem:** I'm trying to create a filter that will add the featured image of a post to the\_content, so that I can have the first paragraph of the\_content displayed before this image. **What I basicly want to achieve:** ``` <p>First Paragraph of the_content</p> <img>The Post's Featured Image</img> <p>The rest ...
You can do this using the 'the\_content' filter: ```php add_filter( 'the_content', 'insert_featured_image', 20 ); function insert_featured_image( $content ) { $content = preg_replace( "/<\/p>/", "</p>" . get_the_post_thumbnail($post->ID, 'post-single'), $content, 1 ); return $content; } ``` Of course, you ...
61,300
<p>I have a dilemma in how the data in this scenario should be organised, as well as queried.</p> <p>The main elements in the scenario are the following:</p> <ul> <li>Competition</li> <li>Team</li> <li>Player</li> </ul> <p>Each player plays for one particular team.</p> <p>Each team participates in one or more compe...
[ { "answer_id": 61274, "author": "bgallagh3r", "author_id": 18905, "author_profile": "https://wordpress.stackexchange.com/users/18905", "pm_score": 1, "selected": false, "text": "<p>Technically the quickest solution would be to use a shortcode in your content. Otherwise you'll need a goo...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61300", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
I have a dilemma in how the data in this scenario should be organised, as well as queried. The main elements in the scenario are the following: * Competition * Team * Player Each player plays for one particular team. Each team participates in one or more competitions. First I'd like to know how this data should be...
You can do this using the 'the\_content' filter: ```php add_filter( 'the_content', 'insert_featured_image', 20 ); function insert_featured_image( $content ) { $content = preg_replace( "/<\/p>/", "</p>" . get_the_post_thumbnail($post->ID, 'post-single'), $content, 1 ); return $content; } ``` Of course, you ...
61,313
<p>I've got a special "position" meta field for posts which can be between 0 and 37. 0 Is ignored, and everything else can have obviously any number between and including 1 and 37. But this of course means that multiple posts can have the same number.</p> <p>Now I'm trying to select only the latest entry from these du...
[ { "answer_id": 61274, "author": "bgallagh3r", "author_id": 18905, "author_profile": "https://wordpress.stackexchange.com/users/18905", "pm_score": 1, "selected": false, "text": "<p>Technically the quickest solution would be to use a shortcode in your content. Otherwise you'll need a goo...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61313", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12817/" ]
I've got a special "position" meta field for posts which can be between 0 and 37. 0 Is ignored, and everything else can have obviously any number between and including 1 and 37. But this of course means that multiple posts can have the same number. Now I'm trying to select only the latest entry from these duplicates, ...
You can do this using the 'the\_content' filter: ```php add_filter( 'the_content', 'insert_featured_image', 20 ); function insert_featured_image( $content ) { $content = preg_replace( "/<\/p>/", "</p>" . get_the_post_thumbnail($post->ID, 'post-single'), $content, 1 ); return $content; } ``` Of course, you ...
61,316
<p>I added a new menu item for my plugin like this:</p> <pre><code>add_menu_page( 'Control Panel', 'My Plugin', 'manage_options', 'control-panel', array($this, 'control_panel_page'), plugins_url('/images/menu_icon.png', __FILE__) ); public function control_panel_page() { // My HTML goes here } </code></...
[ { "answer_id": 61391, "author": "Miljenko Barbir", "author_id": 1376, "author_profile": "https://wordpress.stackexchange.com/users/1376", "pm_score": 2, "selected": false, "text": "<p>You can use the <code>file_get_contents()</code> function to load a file into a string and write it's co...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61316", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19075/" ]
I added a new menu item for my plugin like this: ``` add_menu_page( 'Control Panel', 'My Plugin', 'manage_options', 'control-panel', array($this, 'control_panel_page'), plugins_url('/images/menu_icon.png', __FILE__) ); public function control_panel_page() { // My HTML goes here } ``` However, I feel u...
From the [codex page](http://codex.wordpress.org/Function_Reference/add_menu_page): > > $menu\_slug > (string) (required) The slug name to refer to this menu by (should be unique for this menu). Prior to Version 3.0 this was called the file (or handle) parameter. **If the function parameter is omitted, the menu\_slu...
61,321
<p>If I add more than 5 Settings to a single section, the order of the settings gets weird.</p> <p>For example:</p> <pre><code>// Link color $wp_customize-&gt;add_setting( 'tonal_'.$themeslug.'_settings[link_color1]', array( 'default'           =&gt; $themeOptions['link_color1'], 'type'              =&gt; 'op...
[ { "answer_id": 61327, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<h2>CleanUp</h2>\n\n<p>Iterating is much easier for debugging, as you'll see step by step information: </p>\n\n<blockq...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61321", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18247/" ]
If I add more than 5 Settings to a single section, the order of the settings gets weird. For example: ``` // Link color $wp_customize->add_setting( 'tonal_'.$themeslug.'_settings[link_color1]', array( 'default'           => $themeOptions['link_color1'], 'type'              => 'option', 'sanitize_callback'...
If you need them in a specific order, then give a priority value to the controls. Otherwise, their order is not defined and cannot be guaranteed. If you don't define a priority, then the control gets the default priority of "10". When two controls have the same priority, then the resulting order is undefined, becaus...
61,335
<p>We have a setup where bloggers can and will have their theme changed. Is it possible to migrate the existing header image to the new theme ? I know how to override the header image with the add_filter, also know how to get the current header image. The issue here is to keep the header image when changing the theme. ...
[ { "answer_id": 61336, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 1, "selected": false, "text": "<p>Here comes the plugins to rescue, move that code into a plugin and activate. That'll not change header image upon...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61335", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19082/" ]
We have a setup where bloggers can and will have their theme changed. Is it possible to migrate the existing header image to the new theme ? I know how to override the header image with the add\_filter, also know how to get the current header image. The issue here is to keep the header image when changing the theme. Is...
We did a small mu-plugin that solved our issue. Here is the code ``` add_action('pre_update_option_stylesheet', 'phi_pre_update_option_stylesheet'); add_action('switch_theme', 'phi_switch_theme'); function phi_pre_update_option_stylesheet($stylesheet) { update_option('previous_header_image_saved', get_theme_mod(...
61,353
<p>I'm writing a plugin that creates an API endpoint that validates username/password pairs.</p> <p>I'm currently using <a href="http://codex.wordpress.org/Function_Reference/wp_signon" rel="noreferrer"><code>wp_signon()</code></a> to check whether the username/password combo works. This works fine when the credential...
[ { "answer_id": 61358, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>Use,</p>\n<ul>\n<li><a href=\"http://codex.wordpress.org/Function_Reference/get_user_by\" rel=\"nofollow noreferr...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61353", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11363/" ]
I'm writing a plugin that creates an API endpoint that validates username/password pairs. I'm currently using [`wp_signon()`](http://codex.wordpress.org/Function_Reference/wp_signon) to check whether the username/password combo works. This works fine when the credentials fail because it returns an error object. But wh...
There is a function in the [`user.php`](http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/user.php#L71) of the core files called [`wp_authenticate_username_password`](http://queryposts.com/function/wp_authenticate_username_password/) that seems like what you're looking for. If you want to avoid throwing in...
61,367
<p>I am trying to display current post author link above the loop (before loop starts) with this tag <code>the_author_posts_link()</code> but it's not displaying the author post link. Anyone please help me.</p> <p>Edited question:</p> <p>So I want author post links like this</p> <p>September 17th, 2008 by (here will...
[ { "answer_id": 61368, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>You have to use the function in the loop. </p>\n</blockquote>\n\n<p>Else it won't output anything.<...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61367", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9821/" ]
I am trying to display current post author link above the loop (before loop starts) with this tag `the_author_posts_link()` but it's not displaying the author post link. Anyone please help me. Edited question: So I want author post links like this September 17th, 2008 by (here will be author name with post link) Li...
It make use of global variable `$post` to get author id of current post. Using that this function returns the author url. > > ### Note - > > > Make sure you put this in condition ( `is_single()` ) so it only print author url on `single.php`. > > > ``` <?php echo get_author_posts_url( $post->post_author ); ?> ...
61,376
<p>Im developing a theme for article directory and i would like to link some way taxonomies to taxonomies. I had a custom post type called "<strong>company</strong>" with 2 taxnomies</p> <pre><code>Taxonomy #1 is category with terms(shops,workshops,churchs,shoppings,etc) Taxonomy #2 is location with terms(New York, N...
[ { "answer_id": 61381, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<h2>Basics</h2>\n\n<p>Just use <code>get_terms()</code> in combination with <a href=\"http://queryposts.com/function/g...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61376", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4130/" ]
Im developing a theme for article directory and i would like to link some way taxonomies to taxonomies. I had a custom post type called "**company**" with 2 taxnomies ``` Taxonomy #1 is category with terms(shops,workshops,churchs,shoppings,etc) Taxonomy #2 is location with terms(New York, New jersey,Miami, etc) ``` ...
With reservations, sure, you can do what you want with this code: ``` add_action('init', 'wpse_61376_rewrites'); function wpse_61376_rewrites() { add_rewrite_rule('^([^/]*)/([^/]*)/?$','index.php?category=$matches[1]&location=$matches[2]','top'); } ``` Then go to Settings → Permalinks in wp-admin and click "Save...
61,378
<p>I have written a plugin that will convert posts to excel format and then email the .xls to an email id. I can make it work with when function is declared in functions.php but does not work with function defined in plugin file. </p> <pre><code>if ( ! wp_next_scheduled( 'xls_func_hook1' ) ) { wp_schedule_event( tim...
[ { "answer_id": 61382, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 2, "selected": false, "text": "<p>The cron event needs to be registered on the plugin activation hook like so:</p>\n\n<pre><code>register_activation...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61378", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12673/" ]
I have written a plugin that will convert posts to excel format and then email the .xls to an email id. I can make it work with when function is declared in functions.php but does not work with function defined in plugin file. ``` if ( ! wp_next_scheduled( 'xls_func_hook1' ) ) { wp_schedule_event( time(), 'hourly',...
The cron event needs to be registered on the plugin activation hook like so: ``` register_activation_hook( __FILE__, 'activate_cron' ); function activate_cron() { wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'the_function_to_run' ); } ``` The `the_function_to_run` defined in the wp\_schedule\_event ...
61,398
<p>I'm setting up a WooCommerce site to sell shirts. I have the front page (and the "Store" page" set up to show a grid of thumbnails of the shirt designs. Each item has the price and the title of the design under it by default. I want to "turn off" showing the title and the price in the store view. I <em>DO</em> w...
[ { "answer_id": 61401, "author": "Damien", "author_id": 17132, "author_profile": "https://wordpress.stackexchange.com/users/17132", "pm_score": 0, "selected": false, "text": "<p>From the notes on <a href=\"http://www.woothemes.com/support-forum/?viewtopic=84203\" rel=\"nofollow\">WooComme...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61398", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19097/" ]
I'm setting up a WooCommerce site to sell shirts. I have the front page (and the "Store" page" set up to show a grid of thumbnails of the shirt designs. Each item has the price and the title of the design under it by default. I want to "turn off" showing the title and the price in the store view. I *DO* want them to ap...
There are a couple solutions. The solution I would recommend is to remove the actions that prints the price & title in the first place. The main reason I suggest programmatically removing the actions is because it is theme independent. These modifications should work for any theme and you don't have to worry about CSS ...
61,405
<p>Created a class in an external script which is dependent on the Wordpress environment. Since it's a class I intend to use on various projects, I decided to dynamically create a path to wp-blog-header.php and here's what I came up with. It currently works for me, but I need to ensure that its foolproof.</p> <pre><co...
[ { "answer_id": 61406, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>As per the Codex,</p>\n<p><a href=\"http://codex.wordpress.org/Integrating_WordPress_with_Your_Website\" rel=\"no...
2012/08/09
[ "https://wordpress.stackexchange.com/questions/61405", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13176/" ]
Created a class in an external script which is dependent on the Wordpress environment. Since it's a class I intend to use on various projects, I decided to dynamically create a path to wp-blog-header.php and here's what I came up with. It currently works for me, but I need to ensure that its foolproof. ``` $docRoot = ...
In the generic case, there is no performant solution other than to check every file and folder that is publicly accessible, and then all the parent folders. Since this is not a feasible or excusable operation to perform on every page load or request, you're left with two other options: * Define the location manually,...
61,437
<p>Currently i am using the following generic flow for adding the shortcode for a plugin.</p> <pre><code>class MyPlugin { private $myvar; function baztag_func() { print $this-&gt;myvar; } } add_shortcode( 'baztag', array('MyPlugin', 'baztag_func') ); </code></pre> <p>Now when this c...
[ { "answer_id": 61440, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 6, "selected": true, "text": "<p>As the error says you need an instance of the class to use <code>$this</code>. There are at least three possibilities:<...
2012/08/10
[ "https://wordpress.stackexchange.com/questions/61437", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12621/" ]
Currently i am using the following generic flow for adding the shortcode for a plugin. ``` class MyPlugin { private $myvar; function baztag_func() { print $this->myvar; } } add_shortcode( 'baztag', array('MyPlugin', 'baztag_func') ); ``` Now when this class and it's method are call...
As the error says you need an instance of the class to use `$this`. There are at least three possibilities: ### Make everything static ``` class My_Plugin { private static $var = 'foo'; static function foo() { return self::$var; // never echo or print in a shortcode! } } add_shortcode( 'bazta...
61,465
<p>Trying to make a system whereby a function is called upon an admin changing the taxonomy category (term - if i understand correcrtly) of a custom post type.</p> <p>I thought the action tag "edit_category" would do this, but doesnt seem to work:</p> <pre><code>add_action('edit_category_form', 'myFunction'); </code>...
[ { "answer_id": 61440, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 6, "selected": true, "text": "<p>As the error says you need an instance of the class to use <code>$this</code>. There are at least three possibilities:<...
2012/08/10
[ "https://wordpress.stackexchange.com/questions/61465", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10645/" ]
Trying to make a system whereby a function is called upon an admin changing the taxonomy category (term - if i understand correcrtly) of a custom post type. I thought the action tag "edit\_category" would do this, but doesnt seem to work: ``` add_action('edit_category_form', 'myFunction'); ``` Any ideas? Thanks!
As the error says you need an instance of the class to use `$this`. There are at least three possibilities: ### Make everything static ``` class My_Plugin { private static $var = 'foo'; static function foo() { return self::$var; // never echo or print in a shortcode! } } add_shortcode( 'bazta...
61,480
<p>I have got a Wordpress website and I would like to create a new one with exactly the same functions, themes/templates (apart from the color), plugins, etc. An exact clone of the current one, but with different content and name of sections.</p> <p>Is there any plugin I can use or should I just copy the website, dele...
[ { "answer_id": 61481, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<h2>Built in!</h2>\n\n<p>WordPress comes with feature for this: <strong>»MU«</strong> or Multisite or Network.</p>\n\n<...
2012/08/10
[ "https://wordpress.stackexchange.com/questions/61480", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18809/" ]
I have got a Wordpress website and I would like to create a new one with exactly the same functions, themes/templates (apart from the color), plugins, etc. An exact clone of the current one, but with different content and name of sections. Is there any plugin I can use or should I just copy the website, delete content...
Built in! --------- WordPress comes with feature for this: **»MU«** or Multisite or Network. You can [read more about it in Codex](http://codex.wordpress.org/Create_A_Network). Summed up --------- The most important part is a single line in your `wp-config.php` file: ``` define( 'WP_ALLOW_MULTISITE', true ); ``` ...
61,489
<p>I have a non plugin script that has it's own database and I want to use it with Wordpress. How can I add custom php code that connects to this separate database in my wordpress pages? It needs to go at the top of each page above <code>&lt;html&gt;</code></p> <p>I am using Genesis Framework.</p> <h1>Any help is app...
[ { "answer_id": 61497, "author": "mjsa", "author_id": 14566, "author_profile": "https://wordpress.stackexchange.com/users/14566", "pm_score": 0, "selected": false, "text": "<p>I'd say the wp-load.php file would be a safe place to put it, as it's included on all pages that use the WP funct...
2012/08/10
[ "https://wordpress.stackexchange.com/questions/61489", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19127/" ]
I have a non plugin script that has it's own database and I want to use it with Wordpress. How can I add custom php code that connects to this separate database in my wordpress pages? It needs to go at the top of each page above `<html>` I am using Genesis Framework. Any help is appreciated. ======================== ...
You could use a WordPress action hook. For example, you could add the following code to your themes functions.php file: ``` add_action( 'init', 'your_script_function' ); function your_script_function() { // your script here } ``` The first line makes WordPress execute the 'your\_script\_function' function on in...
61,530
<p>When run a query with WP_Query method, I got an object. I understand that I can then do the loop to display stuffs. But, my goal is not to display anything, instead, I want to get some post data by doing something like "foreach...". How can I get an array of post data that I can loop through and get data?</p>
[ { "answer_id": 61537, "author": "Roman", "author_id": 3817, "author_profile": "https://wordpress.stackexchange.com/users/3817", "pm_score": 8, "selected": true, "text": "<p>You should read the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"noreferrer\">function ref...
2012/08/11
[ "https://wordpress.stackexchange.com/questions/61530", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5210/" ]
When run a query with WP\_Query method, I got an object. I understand that I can then do the loop to display stuffs. But, my goal is not to display anything, instead, I want to get some post data by doing something like "foreach...". How can I get an array of post data that I can loop through and get data?
You should read the [function reference for WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query) on the WordPress codex. There you have a lot of examples to look at. If you don't want to loop over the result set using a `while`, you could get all posts returned by the query with the `WP_Query` in the propert...
61,535
<p>By default, wordpress remove accents and weird characters to generate <code>post_name</code> in wp_posts table. This post_name is used when we change the permalink structure to <code>/%postname%/</code> or some similar structures. In my language, i don't want to remove and replace many characters as it distorts the ...
[ { "answer_id": 61538, "author": "Roman", "author_id": 3817, "author_profile": "https://wordpress.stackexchange.com/users/3817", "pm_score": 1, "selected": true, "text": "<p>Why did you want to alter the URI here? SEO optimization?</p>\n\n<p>An URI has a limited number of allowed chars, d...
2012/08/11
[ "https://wordpress.stackexchange.com/questions/61535", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17226/" ]
By default, wordpress remove accents and weird characters to generate `post_name` in wp\_posts table. This post\_name is used when we change the permalink structure to `/%postname%/` or some similar structures. In my language, i don't want to remove and replace many characters as it distorts the meaning. I have change...
Why did you want to alter the URI here? SEO optimization? An URI has a limited number of allowed chars, defined in an RFC. That's the reason WordPress uses `utf8_uri_encode` to generate a permalink based on the posttitle. You can find more information in this stackoverflow question: [Which characters make a URL inval...
61,539
<p>do you have any idea how to achieve such effect with wordpress? <a href="http://www.papajastudio.pl/" rel="nofollow">http://www.papajastudio.pl/</a> http://soulwire.co.uk/</p> <p>I mean the navigation. i want to have simple cms to edit website content + such sliding effect. An ideas?</p>
[ { "answer_id": 61547, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 0, "selected": false, "text": "<p><strong><em>Note - Sliding effects has nothing to do with Wordpress.</strong> (or any CMS)</em></p>\n\n<p>Wordpre...
2012/08/11
[ "https://wordpress.stackexchange.com/questions/61539", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19140/" ]
do you have any idea how to achieve such effect with wordpress? <http://www.papajastudio.pl/> http://soulwire.co.uk/ I mean the navigation. i want to have simple cms to edit website content + such sliding effect. An ideas?
This is what came to mind though there could be some easy implementations as well: `jQuery(document).ready(function(){` ``` jQuery(document).scroll(function(){ if(jQuery(document).scrollTop()>0){ jQuery('#first-header').hide(); jQuery('#second-header').show(); } else{ jQuery('#seco...
61,567
<p>I'm using a few plugins that have shortcodes ... however, instead of creating a public page for the content, I've created some new pages within the admin using <code>add_menu_page</code> and I need to know how to utilize <code>do_shortcode()</code> within this context.</p> <p>As it stands, all the function does it ...
[ { "answer_id": 61574, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p>It seems the shortcode API <em>is</em> available in the admin, but its output will depend on the shortcode ...
2012/08/11
[ "https://wordpress.stackexchange.com/questions/61567", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9295/" ]
I'm using a few plugins that have shortcodes ... however, instead of creating a public page for the content, I've created some new pages within the admin using `add_menu_page` and I need to know how to utilize `do_shortcode()` within this context. As it stands, all the function does it spit out the string. I'm assumin...
Instead of calling `do_shortcode()` just call the function associated with the shortcode. ### Example There is a shortcode named `[example]` and a function registered as shortcode handler: ``` function example_shortcode( $atts = array(), $content = '' ) { extract( shortcode_atts( array ...
61,571
<p>I'm not sure what's happening here, since this has worked in another plugin I've created. I'm simply trying to store data in the options table. Here is the code I'm using:</p> <pre><code>function on_myplugin_start () { register_setting('first_tab_options', 'first_tab_items'); } add_action('admin_init','o...
[ { "answer_id": 61572, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 5, "selected": true, "text": "<p>...because your input (POST) name needs to match the one in your <code>register_setting</code> call:</p>\n\n...
2012/08/11
[ "https://wordpress.stackexchange.com/questions/61571", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18778/" ]
I'm not sure what's happening here, since this has worked in another plugin I've created. I'm simply trying to store data in the options table. Here is the code I'm using: ``` function on_myplugin_start () { register_setting('first_tab_options', 'first_tab_items'); } add_action('admin_init','on_myplugin_star...
...because your input (POST) name needs to match the one in your `register_setting` call: ``` register_setting( 'first_tab_options', 'first_tab_items' ); .... <input type="text" name="first_tab_items"... ``` Otherwise how the hell does WP know that `some_name` in POST holds your option data? ;)
61,595
<p>I'm a combination Drupal and WordPress developer and have recently started playing with Drupal's <a href="http://www.drupal.org/project/panels" rel="nofollow">Panels</a> module -- which allows you to create flexible layouts and drop content blocks (The Drupal equivalent of widgets) in place on either a per-layout or...
[ { "answer_id": 61572, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 5, "selected": true, "text": "<p>...because your input (POST) name needs to match the one in your <code>register_setting</code> call:</p>\n\n...
2012/08/12
[ "https://wordpress.stackexchange.com/questions/61595", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1682/" ]
I'm a combination Drupal and WordPress developer and have recently started playing with Drupal's [Panels](http://www.drupal.org/project/panels) module -- which allows you to create flexible layouts and drop content blocks (The Drupal equivalent of widgets) in place on either a per-layout or per-content item basis. I'm...
...because your input (POST) name needs to match the one in your `register_setting` call: ``` register_setting( 'first_tab_options', 'first_tab_items' ); .... <input type="text" name="first_tab_items"... ``` Otherwise how the hell does WP know that `some_name` in POST holds your option data? ;)
61,605
<p>OK so I've searched a lot and couldn't find a straight forward answer to my question. I am simply trying to use one category loop that will display posts in a category page in a wordpress site. lets say 6 posts for this purpose.</p> <p>it's pretty simple to accomplish it by using a simple query loop like so:</p> <...
[ { "answer_id": 61607, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": false, "text": "<p>check which post you're currently outputting via <code>$wp_query-&gt;current_post</code>:</p>\n\n<pre><code>&lt;?ph...
2012/08/12
[ "https://wordpress.stackexchange.com/questions/61605", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7730/" ]
OK so I've searched a lot and couldn't find a straight forward answer to my question. I am simply trying to use one category loop that will display posts in a category page in a wordpress site. lets say 6 posts for this purpose. it's pretty simple to accomplish it by using a simple query loop like so: ``` <?php query...
Just create 2 queries using the "offset" parameter and separate them by: ``` <?php wp_reset_query(); ?> ``` Display posts from the 4th one (offset is starting from 0): ``` <?php $query = new WP_Query( 'offset=3' ) ); ?> ``` EDIT: Here's some sample code: ``` <?php query_posts('offset=0&showposts=2&order=ASC'); ?...
61,626
<p>I have a wordpress blog at</p> <p><a href="http://www.1000irritatingthings.com" rel="nofollow noreferrer">http://www.1000irritatingthings.com</a></p> <p>I had the sociable plugin working for a while, but now when I try to configure it, I get the following error in the admin panel when I select Sociable classic:</p> ...
[ { "answer_id": 61627, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 0, "selected": false, "text": "<p>How long is \"a while\" and what other plugins have you installed since Sociable stopped working?</p>\n\n<p>I...
2012/08/12
[ "https://wordpress.stackexchange.com/questions/61626", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13029/" ]
I have a wordpress blog at <http://www.1000irritatingthings.com> I had the sociable plugin working for a while, but now when I try to configure it, I get the following error in the admin panel when I select Sociable classic: > > **Fatal error:** Call to undefined function curl\_init() in > > > `D:\(WEBSITES)\1000...
Is it your host? ---------------- Test if `cURL` is installed. If not: Go and **talk to** your host. Here you got a small plugin. Drop it in your MU-Plugins folder and reload *any* page, or drop it into your plugins folder, activate it and then reload the page. ``` /* Plugin Name: _CHECK IF cURL INSTALLED */ functio...
61,635
<p>I have a theme name is mytheme in <code>themes/mythem/functions.php</code> I using code:</p> <pre><code>function remove_scripts() { remove_action('wp_head','mytheme_head_scripts'); } add_action('init', 'remove_scripts'); </code></pre> <p>=>but result can't remove all javascript, how to fix it ?</p>
[ { "answer_id": 61639, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 0, "selected": false, "text": "<p>If the function <code>mytheme_head_scripts</code> used priority while hooking into <code>wp_head</code> then you ...
2012/08/13
[ "https://wordpress.stackexchange.com/questions/61635", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19179/" ]
I have a theme name is mytheme in `themes/mythem/functions.php` I using code: ``` function remove_scripts() { remove_action('wp_head','mytheme_head_scripts'); } add_action('init', 'remove_scripts'); ``` =>but result can't remove all javascript, how to fix it ?
You either use the `admin_*/wp_print_scripts` hook or the `admin_*/wp_print_styles` hook. The styles hook comes before the print scripts hook, so maybe it fits better than just using a priority of `0` for the `*_print_scripts` hook (there might be function with a name that's hooked in earlier on priority `0`). ``` fun...
61,636
<p>Is there a way to bring, automaticaly, an old edited/modified post in the front of page?</p> <p>More clear, I want that every time when i edit a post to display it in front of my page, like sticky posts or something.</p> <p>Is that possible?</p> <p><strong>Edit</strong></p> <p>First, thanks for your promptly ans...
[ { "answer_id": 61637, "author": "Evan Yeung", "author_id": 1878, "author_profile": "https://wordpress.stackexchange.com/users/1878", "pm_score": 2, "selected": false, "text": "<p>From what I understand you want to order posts by their modified date. </p>\n\n<p>If so, then this should b...
2012/08/13
[ "https://wordpress.stackexchange.com/questions/61636", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19181/" ]
Is there a way to bring, automaticaly, an old edited/modified post in the front of page? More clear, I want that every time when i edit a post to display it in front of my page, like sticky posts or something. Is that possible? **Edit** First, thanks for your promptly answer! Yes, in part this is it, but it's not ...
From what I understand you want to order posts by their modified date. If so, then this should be a solution: [How to order posts by modified date without using 'query\_posts'?](https://wordpress.stackexchange.com/questions/49940/how-to-order-posts-by-modified-date-without-using-query-posts/49947#49947)
61,653
<p>I wanted to use Wordpress built in WP Cron to update currency rates daily.</p> <p>I use this function currently,</p> <pre><code>require_once(WP_PLUGIN_DIR . '/autocurupdate/currencyexchange_class.php'); $cx=new currencyExchange(); $cx-&gt;getData(); $currency_sql = "select last_updated from " . $wpdb-&gt;prefix."c...
[ { "answer_id": 61703, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<h2>First things first: Say hello! to <code>$wpdb</code></h2>\n\n<p>The <a href=\"http://codex.wordpress.org/Class_Ref...
2012/08/13
[ "https://wordpress.stackexchange.com/questions/61653", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7749/" ]
I wanted to use Wordpress built in WP Cron to update currency rates daily. I use this function currently, ``` require_once(WP_PLUGIN_DIR . '/autocurupdate/currencyexchange_class.php'); $cx=new currencyExchange(); $cx->getData(); $currency_sql = "select last_updated from " . $wpdb->prefix."currencies where code = 'PHP...
First things first: Say hello! to `$wpdb` ----------------------------------------- The [wpdb Class](http://codex.wordpress.org/Class_Reference/wpdb) is what you take to interact with the database on it's most basic level. Forget all those `mysql_*` functions, when it comes to WordPress. The core has a nice wrapper, t...
61,659
<p>Why uninstalling the following (empty) plugin results in error?</p> <p>Here is <code>my-plugin/my-plugin.php</code>:</p> <pre><code>&lt;?php /* Plugin Name: My Plugin */ </code></pre> <p>and <code>my-plugin/uninstall.php</code>:</p> <pre><code>&lt;?php </code></pre> <p>When I click 'Delete' and then confirm, I ...
[ { "answer_id": 233901, "author": "Annapurna", "author_id": 98322, "author_profile": "https://wordpress.stackexchange.com/users/98322", "pm_score": 2, "selected": false, "text": "<p>I also had the same problem. It was due to the permission issue in wordpress directory. Navigate to the Dir...
2012/08/13
[ "https://wordpress.stackexchange.com/questions/61659", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19075/" ]
Why uninstalling the following (empty) plugin results in error? Here is `my-plugin/my-plugin.php`: ``` <?php /* Plugin Name: My Plugin */ ``` and `my-plugin/uninstall.php`: ``` <?php ``` When I click 'Delete' and then confirm, I get the following error: > > Plugin could not be deleted due to an error: Could n...
I also had the same problem. It was due to the permission issue in wordpress directory. Navigate to the Directory where you have installed WordPress and…. run the following in your terminal: ``` sudo chown www-data:www-data * -R sudo usermod -a -G www-data username ``` Replace username with the username you are usi...
61,668
<p>I am using <a href="http://codex.wordpress.org/Function_Reference/get_bookmarks" rel="nofollow"><code>get_bookmarks()</code></a> to get bookmark links. I can get links posted in cat A <strong><em>or</em></strong> cat B, but I only want links in both A <strong><em>and</em></strong> B.</p> <p><strong>Example what I n...
[ { "answer_id": 61685, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>It should be as simple as that: Just get the terms from the <code>link_category</code> and use the <code>get_terms(...
2012/08/13
[ "https://wordpress.stackexchange.com/questions/61668", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3094/" ]
I am using [`get_bookmarks()`](http://codex.wordpress.org/Function_Reference/get_bookmarks) to get bookmark links. I can get links posted in cat A ***or*** cat B, but I only want links in both A ***and*** B. **Example what I need:** I have three link categories `cat#1`, `cat#2`, `cat#3`. I need to get links in both ...
It should be as simple as that: Just get the terms from the `link_category` and use the `get_terms()` argument instead, which should work like you need it. ``` get_terms( 'link_category' ,array( 'include' => array( 1, 2, 3 ) ,'orderby' => 'name' ,'order' => 'ASC' ...
61,678
<p>Ive been looking into actions and hooks etc... from wordpress, but cant seem to do a very simple thing. I just want to execute a function whenever a post is updated, and within the function I want the names of the terms that have been changed on that save. So maybe some sort of before and after comparison of terms??...
[ { "answer_id": 61685, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>It should be as simple as that: Just get the terms from the <code>link_category</code> and use the <code>get_terms(...
2012/08/13
[ "https://wordpress.stackexchange.com/questions/61678", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10645/" ]
Ive been looking into actions and hooks etc... from wordpress, but cant seem to do a very simple thing. I just want to execute a function whenever a post is updated, and within the function I want the names of the terms that have been changed on that save. So maybe some sort of before and after comparison of terms?? C...
It should be as simple as that: Just get the terms from the `link_category` and use the `get_terms()` argument instead, which should work like you need it. ``` get_terms( 'link_category' ,array( 'include' => array( 1, 2, 3 ) ,'orderby' => 'name' ,'order' => 'ASC' ...
61,684
<p>This script list users with their last post. How to exclude some authors from guery ?</p> <pre><code>&lt;?php //List of users sorted descending by date of lastest post written by user $uc=array(); $blogusers = get_users_of_blog(); if ($blogusers) { foreach ($blogusers as $bloguser) ...
[ { "answer_id": 61685, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>It should be as simple as that: Just get the terms from the <code>link_category</code> and use the <code>get_terms(...
2012/08/13
[ "https://wordpress.stackexchange.com/questions/61684", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18025/" ]
This script list users with their last post. How to exclude some authors from guery ? ``` <?php //List of users sorted descending by date of lastest post written by user $uc=array(); $blogusers = get_users_of_blog(); if ($blogusers) { foreach ($blogusers as $bloguser) { ...
It should be as simple as that: Just get the terms from the `link_category` and use the `get_terms()` argument instead, which should work like you need it. ``` get_terms( 'link_category' ,array( 'include' => array( 1, 2, 3 ) ,'orderby' => 'name' ,'order' => 'ASC' ...
61,734
<p>I've created a custom post type (minerals) with a custom taxonomy (location) which supports hierarchies. What I am trying to do is create a return according to the parent location of the mineral post type. </p> <blockquote> <p>For example, someone clicks on Europe, and the results show all minerals from all liste...
[ { "answer_id": 61746, "author": "Brent", "author_id": 10972, "author_profile": "https://wordpress.stackexchange.com/users/10972", "pm_score": 0, "selected": false, "text": "<p>Ok, well I think I've figured out my own question. The link posted above in the comment to my question did prove...
2012/08/13
[ "https://wordpress.stackexchange.com/questions/61734", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10972/" ]
I've created a custom post type (minerals) with a custom taxonomy (location) which supports hierarchies. What I am trying to do is create a return according to the parent location of the mineral post type. > > For example, someone clicks on Europe, and the results show all minerals from all listed countries in Europ...
I think you're way overcomplicating this. Use [`get_terms`](http://codex.wordpress.org/Function_Reference/get_terms) to get all taxonomy terms that are a child of a particular term via the `child_of` argument, then use that array with a [`WP_Query` tax query](http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy...
61,737
<p>At the moment I'm using a custom post type called 'locations' I would like to be able to put input fields into the custom post type that would store the information such as ( address, type, phone number, etc.. ) in a separate table called 'markers' So when a new post is made it will create a new entry in the table m...
[ { "answer_id": 61739, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 0, "selected": false, "text": "<p>You have 3 options.</p>\n\n<ol>\n<li><p>Just use the native custom fields in WordPress, unless you have a\ngood rea...
2012/08/13
[ "https://wordpress.stackexchange.com/questions/61737", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16946/" ]
At the moment I'm using a custom post type called 'locations' I would like to be able to put input fields into the custom post type that would store the information such as ( address, type, phone number, etc.. ) in a separate table called 'markers' So when a new post is made it will create a new entry in the table mark...
You should avoid creating more tables. Just do it if you really have a good reason to. Note that `wp_postmeta` can store practically any kind of data, and simply using the [`get_post_meta`](http://codex.wordpress.org/Function_Reference/get_post_meta) function can do all the job in most cases. But if you *must* use ano...
61,749
<p>I have publications and I want to simply add year and month to the permalink. Currently the year and month of publication is added to the post as a meta value. I've set up publications as a custom post type and created taxonomy for the specific title of the publication. I would like the permalink to be:</p> <p>publ...
[ { "answer_id": 61959, "author": "user1255062", "author_id": 15931, "author_profile": "https://wordpress.stackexchange.com/users/15931", "pm_score": 2, "selected": false, "text": "<p>Was able to get this working. Thought I would write down what we did in the hopes that it will help someon...
2012/08/13
[ "https://wordpress.stackexchange.com/questions/61749", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15931/" ]
I have publications and I want to simply add year and month to the permalink. Currently the year and month of publication is added to the post as a meta value. I've set up publications as a custom post type and created taxonomy for the specific title of the publication. I would like the permalink to be: publications/p...
Was able to get this working. Thought I would write down what we did in the hopes that it will help someone in the future (or someone can give me feedback on how to better improve it!) 1. Registered Custom Rewrite Rules ``` add_action('init', 'pub_rewrite_rules'); function pub_rewrite_rules() { global $wp_rewrit...
61,770
<p>There are a lot of people discussing how to increase the php max upload file size...</p> <p>In my case though I want to shrink it from 8MB to 4MB... In my cpanel configuration, if I change the setting, it will eventually change it for all the websites hosted... which is something I don't want (on some other wordpre...
[ { "answer_id": 61774, "author": "Damien", "author_id": 17132, "author_profile": "https://wordpress.stackexchange.com/users/17132", "pm_score": 0, "selected": false, "text": "<p>If you are running Wordpress multisite then go to <code>wp-admin/network/settings.php</code> and scroll down to...
2012/08/14
[ "https://wordpress.stackexchange.com/questions/61770", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8421/" ]
There are a lot of people discussing how to increase the php max upload file size... In my case though I want to shrink it from 8MB to 4MB... In my cpanel configuration, if I change the setting, it will eventually change it for all the websites hosted... which is something I don't want (on some other wordpress install...
At the top of your wp-config.php file: `ini_set('upload_max_filesize','4M');`
61,775
<p>I'm planning a custom WordPress theme where the Custom Post Type (CPT) will have latitude and longitude coordinate as it's meta value. The latitude and longitude will be displayed as a Marker in a Google Map.</p> <p>So far I don't have any problem in showing the Google Map and the CPT as it's Marker. That is if I q...
[ { "answer_id": 61782, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": 4, "selected": true, "text": "<p>This is a simple mathimatical problem.\nYou will indeed need access to both your longitude and latitude, so save ...
2012/08/14
[ "https://wordpress.stackexchange.com/questions/61775", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6383/" ]
I'm planning a custom WordPress theme where the Custom Post Type (CPT) will have latitude and longitude coordinate as it's meta value. The latitude and longitude will be displayed as a Marker in a Google Map. So far I don't have any problem in showing the Google Map and the CPT as it's Marker. That is if I query the C...
This is a simple mathimatical problem. You will indeed need access to both your longitude and latitude, so save it in a metafield. than you will have to query your posts like this as a sql query. Haven't got a chance to test it. and or pour it into wordpress. Don't have access to my test env now. But I guess you cou...