question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
Well, this should be pretty simple, however I couldn't find answer anywhere on the web. all answers I found were close but no exactly what I needed. what I need is to display just the current term of a custom post type I am in. not all the terms just one! (the relevant one) this is what I'm using but it displays ALL th...
Ok, so I finally found what I needed here: stackexchange-url ("How to get current term in my custom taxonomy in WordPress?") the last update at the bottom courtesy of @user3208: <code> &lt;?php // Get terms for post $terms = get_the_terms( $post-&gt;ID , 'oil' ); // Loop over each item since it's an array if ( $terms !...
Display current taxonomy term when inside custom post type
wordpress
When you add an image with "Add media" to the WYSIWYG editor the link around the image automatically gets a rel="attachment wp-att-XX". I would like to remove this with a script - Can anyone help me? :)
You can remove it right before post is printed to the screen by stripping it out from content. But remember it still will meddle in Editor. <code> &lt;?php function my_remove_rel_attr($content) { return preg_replace('/\s+rel="attachment wp-att-[0-9]+"/i', '', $content); } add_filter('the_content', 'my_remove_rel_attr')...
Remove rel="attachment wp-att-XX"
wordpress
I am using the following code to display child page content on it's parent page. The code is working great, but it currently only shows the latest two child page posts, is there any way to display all of them and then add pagination to navigate through them? <code> &lt;?php $pages = get_pages('child_of='.$post-&gt;ID.'...
After some searching I was able to find this post: http://wordpress.org/support/topic/add-pagination-to-list-of-child-pages My final code looks like this: <code> &lt;?php $ids = array(); $pages = get_pages("child_of=".$post-&gt;ID); if ($pages) { foreach ($pages as $page) { $ids[] = $page-&gt;ID; } } $paged = (get_quer...
Paginate Child Pages Content on Parent Page
wordpress
I'm getting a really cryptic error and I'm not sure where to begin. The site ( http://www.petcercise.com/ ) works fine, but when I attempt to go to /wp-admin/ I get the following error: Fatal error: Exception thrown without a stack frame in Unknown on line 0 I've googled it and searched the Worpress support site. This ...
About the Error Exception thrown without a stack frame Means that someone's code threw and exception in a place where it wasn't allowed to throw an exception. For instance, one cannot throw an exception in an object's destructor. There's a fairly good example of how this might happen in the php docs . In short, if you ...
Fatal error: Exception thrown without a stack frame in Unknown on line 0
wordpress
Is there a code in functions.php that I can add to disable or hide "collapse menu" button? The one that is on the left side of the admin menu in the dashboard. I'd need it for both admin, authors, contributors.
Here is a simple css display: none function, it just adds some css in the html, if there are more stuff that you want to hide i recommend you to add a new css-file with the function admin_enqueue_scripts <code> function wpse_remove_collapse() { echo '&lt;style type="text/css"&gt;#collapse-menu { display: none; visibili...
How to disable or hide "collapse menu"
wordpress
I ran into a strange Problem today developing a new Plugin. I set it up as usual, creating the <code> f711-roomprice </code> folder in the Plugindirectory, and creating the <code> f711-roomprice.php </code> as well as an <code> inc </code> directory in there. Everything worked fine with the activation hook and the incl...
Browsing through my old questions, I reopened this one and tested some things out in my plugin. The solution was quite simple, although I am not sure if it had something to do with a new version of WordPress as well. I refactored the plugin and noticed different encodings than last time I tested this. I don't know how ...
Placement of Code in Plugin for hooking `save_post`
wordpress
I have put together this loop to display all children posts of the desired cat, but i am not getting any of the posts from one of the children cats.. Not sure if i am using the best method to accomplish what I am trying to do.. <code> &lt;?php $posts = array(); $categories = get_categories('child_of=5'); foreach($categ...
Your foreach is way wrong. Try combining the category ids in an array, then running one query only to get the posts you want. Edit: read your comments. Try use using an array function like array_merge instead of the + to combine the resulting post arrays. See if that helps.
Child_of not displaying all children posts.. via get_posts
wordpress
I am having problems with <code> add_theme_support('custom-header'); </code> I can change the Header Text color but I can't hide my Header Text when I leave unchecked "Show header text with your image" inside admin panel (obviously it should hide header text if unchecked). I have no idea should I add some specific CSS ...
I have added this code to my header.php and it worked nicely: <code> #header a{ &lt;?php if(get_header_textcolor()=='blank') { echo 'visibility: hidden;'; } else { ?&gt; color:#&lt;?php echo get_header_textcolor(); } ?&gt; } </code>
Add theme support custom header will not hide text?
wordpress
Much like how the Plugins or Comments menu items have these number notifications in a bubble for updates and unmoderated comments respectively, I'd like to use that bubble to display the number of CPTs which have a "Pending review" status. How to go about doing that? I have found stackexchange-url ("this thread"), but ...
I made this work iterating through a post types list, and pinpointing the correct <code> $menu </code> key for the post type using a secondary function (instead of manually iterating through the <code> $menu </code> object). Function reference: <code> get_post_types </code> and <code> wp_count_posts </code> . <code> ad...
Put update-like notification bubble on multiple CPTs menus for pending items
wordpress
Is there some REST API that Wordpress supports, out of the box or through any plugin that exposes the same information exposed through the normal pages? (I.e. latest posts, filtering by categories etc.) There seems to be a JSON API plugin but it seems to be very old and not maintained. There also seems to be some plugi...
The REST API can be used for straight-up retrieval on any blog that has enabled it. Self-hosteds require an active choice to turn the JSON interface on in Jetpack but once it's up it's wide open. This is not necessarily appreciated by everyone , and that's somewhat understandable. I picked a blog ID at random here for ...
Wordpress REST endpoint with JSON for Mobile App integration
wordpress
I am wondering what's the best way to give a user the option to feature a custom post type on the home page. I have a Case Study custom post type and some of them need to be feautured on the home page. Ideally when creating the case study there would be like a checkbox labeled "Feature on home page". Once that is selec...
First, you'll want a quick way to toggle whether a post is featured or not. I wrote a plugin that does this: http://wordpress.org/extend/plugins/featured-item-metabox/ but I feel like a total dork because I just discovered that this plugin was already doing that! http://wordpress.org/extend/plugins/featured-post Ugh. A...
Option to feature custom post type on home page
wordpress
I'm searching for an action hook which I can use to control access to certain parts of my Wordpress site. I want to write some custom PHP which will check certain user attributes and decide if they can view a particular part of the site (ie only users with certain attributes can view pages which fall under particular u...
Put this at the very top of your <code> page.php </code> file, before the <code> get_header() </code> call: <code> &lt;?php // redirect if user isn't logged in if( ! is_user_logged_in() ) { wp_safe_redirect( home_url( '/signup/' ) ); exit; } // supply IDs of both parent pages $keys = array( '21', '23' ); // check if us...
Action hook to control access to certain parts of my site
wordpress
I would really like my images to display in the same way I've ordered them in the media browser. What am I doing wrong? <code> $images =&amp; get_children( array('post_parent' =&gt; $post-&gt;ID, 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'orderby' =&gt; 'menu_order', 'order' =&gt; 'asc' )); </code...
a) If you have reordered the images under the uploaded to this post in the media browser then they should have <code> menu_order&gt;0 </code> and you can get that order with <code> 'orderby' =&gt; 'menu_order', 'order' =&gt; 'asc' </code> b) If you haven't, then <code> menu_order=0 </code> for all these images and you ...
Make Images appear in the same order as in media browser using get children?
wordpress
I have the following loop used to display posts by category &amp; I would like to to re-order them based on a dropdown selector <code> if (!isset($qry)) $qry = new WP_Query(array('category_name'=&gt;$GLOBALS['city'],'order'=&gt;$orderby)); if ($qry-&gt;have_posts($orderby)) { $do_the_post = null; if (is_single($orderby...
I guess the problem is <code> $qry = new WP_Query(array('category_name'=&gt;$GLOBALS['city'],'order'=&gt;$orderby)); </code> Let's just say $orderby is orderby=title&amp;order=ASC Then the order argument of WP_Query will be like this: <code> 'order'=&gt;'orderby=title&amp;order=ASC' </code> However, order argument only...
reorder a WP_Query, using a dropdown
wordpress
I am using the commenting system to all users to add a private note that only they can see to posts and I am using the wordpress comments system to do it. I wrote a function to call the logged in user comments in a shortcode to display on their profile page. I can get this to work without passing it through a variable ...
Could be because you are using the concatenating assignment operator incorrectly: <code> $note_content. = </code> should be <code> $note_content .= </code> http://php.net/manual/en/language.operators.string.php
Using multiple line variable inside a function?
wordpress
I try to create an array of years, which is avaible in my template-files and in at least one other function in the functions.php. <code> function get_the_years() { global $year_arr = range(2001, date('Y')); return $year_arr; } </code> Then I want to use it in a function, which creates a term for every year in the custo...
In order to access a variable defined in the <code> global </code> scope you must reference it with the <code> global </code> keyword wherever you want to call it again. In your case, the function <code> create_year_terms() </code> must call the <code> global $year_arr </code> within its scope. Also, you can always get...
Defining a global array in functions.php?
wordpress
I have made a custom post type (sidebar_element) which are shown on sidebar. On each sidebar element admin can choose where in sidebar should that element be shown, ie. 'top', 'middle' or 'bottom', and that the value is saved in meta field. Meta values for those alignments are 30, 20 and 10. Now, if there are multiple ...
Found an answer to this. Somehow WordPress' own <code> orderby </code> isn't fully functional when trying to order by multiple values. I solved this by changing <code> WP_Query </code> to <code> SQL Query </code> , and including second <code> DESC </code> after <code> _postmeta.meta_value+0 </code> <code> SELECT XXX_po...
WP_Query orderby not working with meta_value_num and menu_order
wordpress
The answer given stackexchange-url ("to a previous and identical question") is unfortunately not working on my WP install. I'm using a version of the function recommended stackexchange-url ("there"). <code> function nim_hide_editor() { $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; $template = get_post_...
The following works for me, testing with TwentyTwelve. Using <code> load-{$pagenow} </code> instead of <code> admin_init </code> avoids the checking for the global <code> $pagenow </code> . See comments for further info: <code> // Run only when editing a page // For new pages load-page-new.php should be used // See: ht...
Hide page visual editor if template is selected - redux
wordpress
I'm using Yoast's Wordpress SEO plugin to generate breadcrumbs for my site. The problem is that when it comes to BuddyPress pages, the breadcrumbs can't see a member's profile page. Right now it shows <code> "Home &gt; Members" </code> on the profile page when it should <code> "Home &gt; Members &gt; Whatever the membe...
This is possible using the filter <code> wpseo_breadcrumb_links </code> . In this example, I'm using the functions <code> bp_get_user_meta </code> and <code> bp_loggedin_user_id </code> , adjust as needed. To check if the page is child of the Members page (in this example, <code> ID == 2 </code> ), I'm using the functi...
Wordpress SEO plugin (by Yoast) and BuddyPress
wordpress
I have the following code for adding a dropdown box with a new taxonomy currently the default when I create a new post is None . Is there a way I can define a default, for example News . <code> function create_theme_taxonomy() { if (!taxonomy_exists('type')) { register_taxonomy( 'type', 'post', array( 'hierarchical' =&...
This is the following new updated article_type function to make it work: I have removed selected attribute from none option and added selected attribute to that terms having news slug. <code> // This function gets called in edit-form-advanced.php function article_type($post) { echo '&lt;input type="hidden" name="taxono...
Select default taxonomy on dropdown
wordpress
I have created a widget that has quite a few settings, and so I am trying to create a tabbed menu (using jQuery UI) inside the widget settings of the admin page. The problem is basically that tabs don't happen (i.e. the a tags just appear on the top and the related divs underneath them). This is a shortened version of ...
Ok, so, for some reason I can't comprehend, the answer is that the div element containing the tabs should have a class and not an id for jQuery UI to work properly, as such: <code> &lt;div class="mytabs"&gt; </code> and <code> jQuery(document).ready(function($) { $(".mytabs").tabs(); }); </code> Just for the record, th...
jQuery UI inside widget on admin page
wordpress
Background Problem The site I'm working right now uses custom front-end forms for content, terms and user editing and creation. Access to wp-admin is blocked for non administrator. All of them uses basic wp_ajax functionality. On the user editing form, the function updates the user data using <code> wp_update_user() </...
That's likely because you are using <code> $current_user-&gt;ID </code> , which always refers to the currently logged in user, or when "empty" object if not logged in ( <code> ID == 0 </code> ). If you would like to update user meta on any other user you would have to supply the user ID of that user in the <code> $_POS...
update_user_meta updates to a wrong ID
wordpress
If I have WordPress installation in English, then I can define my theme translation file in the wp-config.php file with following: <code> define('WPLANG', 'sv_SE'); </code> But if I have WordPress installed in the local language then there is already WordPress translation file defined there, then how can I define my th...
It all depends a bit if your current theme already supports localization. Does your theme's function file contain something like this? <code> load_theme_textdomain( 'twentytwelve', get_template_directory() . '/languages' ); </code> If not, add it in there. And change <code> twentytwelve </code> to your <code> theme-dir...
How to define theme translation file?
wordpress
I'm using wp_insert_post in a loop to insert 500 posts in a new WP install. It works quickly, and memory usage is from 25M to 28M. The next run of a second batch of 500 posts, takes the memory from 25M to 178M. So the memory usage seems to be based on how many posts are already in the table. A third run of 500 posts ex...
Did some profiling, it was the 5k+ queries being stored in the $wpdb-> queries array.
wp_insert_post memory consumption
wordpress
I have a couple of pluins which I use every time I create a new WP-page. Is there a way to implement these plugins as part of my theme? I have searched for a soloution for a couple of hours now, without any luck - hope someone can help :)
First, I would recommend against it. I have a package of plugins that I use on almost all of our websites (both public and internal plugins)... and plugins should really remain plugins. Deploying a package of plugins is not hard or time consuming and only needs to be done once per project. By integrating them into a th...
Implement plugins as part of a theme
wordpress
I'm new to wordpress and PHP Im trying to build a site that the user can select a destination so I did this by creating categories (country) subcategories (state) sub sub category (city) and I want to split them into 3 dynamic drop down menus when you select country the state automatically populates according to the pa...
I found a solution for this in case someone else has this issue, there is a plugin that can help achieve this it is called Category Ajax Chain Selects http://wordpress.org/extend/plugins/category-ajax-chain-selects/
Separate categories parents, childs and grandchilds in dropdowns
wordpress
Currently using CF Post Formats ( http://alexking.org/blog/2011/10/25/wordpress-post-formats-admin-ui ) and using the following code to automatically embed a URL that has been input into the 'Audio' or 'Video' custom field: <code> &lt;?php echo wp_oembed_get( get_post_meta($post-&gt;ID, '_format_audio_embed', true) ); ...
<code> &lt;?php if (strstr($audio, '&lt;iframe')) { echo $audio; } else { echo wp_oembed_get( get_post_meta($post-&gt;ID, '_format_audio_embed', true) ); } ?&gt; </code> Of course, this would require that you get the custom field with the audio embed code or url into $audio :) Edit - try: <code> &lt;?php $audio = get_p...
Displaying cf post formats with oembed
wordpress
I have a working wordpress installation at mydomain.com/wordpress/index.php (not a real domain). I want to migrate it to mydomain.com/index.php. How can I do that? I tried just unzipping a new copy of wordpress in the main domain space and copying over the config file, but I don't think I got it working, since it's not...
You have to change Settings -> General -> WordPress Address (URL) and Site Address (URL) in the old installation. WP looks in the DB at these settings and creates dynamic links, etc, from there, so you need to change it in the DB (either through these settings or by editing the db manually.) Another option (and, actual...
Migrating from foo.com/wordpress/ to foo.com/ -- how can I do it?
wordpress
I have a self-hosted blog at <code> www.MyPersonalSite.com/blog </code> that runs on the Wordpress.org platform. My buddy has a blog at <code> www.HisName.wordpress.com </code> . He seems to get a lot more traffic to his blog. My inclination is that when he makes a post, it submits it to some central Wordpress blogroll...
The only potentially WordPress specific (in the context of this site) part of this question seems to me to be about adding an update service to the list used by WordPress. If you are correct that <code> wordpress.com </code> sites submit to a particular blogroll, and if <code> wordpress.com </code> allows outside sites...
List Wordpress.org Blog on Wordpress.com
wordpress
I've (I think) an interesting problem here. What I want to do is create a global archive page, with everything on it. Dates, authors, categories etc all on one page. I have a child theme, with TwentyTwelve as the parent. Inside TwentyTwelve there exists archive.php, category.php, tag.php, author.php etc., basically all...
This is minimally tested-- nearly untested really-- but: <code> function force_archive_php_wpse_88824() { if (is_main_query() &amp;&amp; is_archive()) { include (get_stylesheet_directory().'/archive.php'); exit; } } add_action('template_redirect','force_archive_php_wpse_88824'); </code> You are interrupting the templat...
Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy
wordpress
I'm developing my own theme. I'm trying to remove the default WordPress image sizes medium, large and full. I also want my own image size, <code> vividflow-full-width </code> . I'm using this Sumtips tutorial . At the <code> after_setup_theme </code> , this is runt: <code> add_image_size( 'vividflow-full-width', 682, 9...
Your custom size will only show up as an option if the selected image exists at those dimensions. So, have you uploaded any images since adding the new image size to functions.php? If not, then you won't see the vividflow option. You could always run regenerate thumbnails so bring your older images up to date.
Custom image size doesn't work
wordpress
On the WordPress Optimization/Performance page it suggests hardcoding static variables rather than referencing them through WordPress functions. I think I get the rationale behind that. But what about doing something like the following: <code> function foobar() { global $post; $post_ID = $post-&gt;ID; $site_url = site_...
This is a PHP question not related at all to WP, but since it was upvoted.... TL;Dr version - Compilres do this kind of micro optimizations much better then you, no point in even trying. lets look at what compilers will do with your question code <code> // is this less efficient $meta = get_post_meta($post-&gt;ID,'meta...
Hardcoding and WordPress Performance
wordpress
I have WP Query and I am simply comparing by the meta value by = My value contains town names, and seems to work great for the majority of names. However some names contain apostrophes... Madonna dell'olmo And the meta values with apostrophes fail to work. This is my query... <code> $dealerResults = new WP_Query(array(...
WordPress adds slashes to the REQUEST/GET/POST superglobals, if I'm not mistaken. Try this change: <code> $ajaxCounty = stripslashes( $_POST['varCounty'] ); $ajaxTown = stripslashes( $_POST['varTown'] ); </code> Related Trac ticket.
meta_query fails to compare on values containing apostrophes
wordpress
I have a custom taxonomy, "Country". I am using WP User Frontend to let users post to the site. Most data is saved as custom fields, so I have a custom field "cf_country". I want to be able to set that custom field to the taxonomy for existing and all future posts. I found a converter plugin, but its a one time thing. ...
Without knowing exactly how your input form looks, I can only give you the following as a suggestion. Basically you verify that you want/have permission to save the data and then take the meta's input and set it as a term in your taxonomy via <code> wp_set_object_terms() </code> . You'll want to fire this every time a ...
Custom Field as Custom Taxonomy?
wordpress
I'm trying to disable the "author" hyperlink when making a post, but having no success. How can I do it?
Look for <code> single.php </code> in your theme directory. There you should find <code> the_author() </code> , you can remove that to remove a reference to the author. You will be able to find all your answers in the codex , by the way.
How do I disable the "by author" hyperlink on posts?
wordpress
I have a custom meta box added to the Page edit screen. I also have categories turned on for Pages. I'm using <code> get_categories($post-&gt;ID); </code> to retrieve a list of categories, as you would in a page template, but it returns a list of all categories instead of just the ones selected. Is it possible to only ...
Figured it out, I was using the wrong function. Correct function was <code> get_the_category_by_ID($cat); </code>
Return selected categories only in custom page meta box?
wordpress
I've registered a new taxonomy for my custom post type, and now I'm trying to edit the taxonomy table. I've successfully removed the description column but I can't figure it out how to edit column width for the column that shows the number of custom post types found in that particular taxonomy. The column's CSS class s...
This should do the trick: <code> add_action( 'admin_print_styles', 'cor_admin_print_styles', 200 ); function cor_admin_print_styles() { $screen = get_current_screen(); if ( 'edit-tags' === $screen-&gt;base &amp;&amp; 'department' === $screen-&gt;taxonomy ) { echo &lt;&lt;&lt;EOF &lt;style&gt; .fixed .column-posts { wid...
Customize my custom taxonomy table in Admin panel
wordpress
I registered a custom post type (foo) with <code> register_post_type </code> , setting <code> 'hierarchical' =&gt; true, </code> so now when I want to use it I have <code> post_type=foo </code> . How can I query child of foo? any ideas? thanks!
You can display child pages of particular parent foo page using following code ( using parent page ID ): <code> $the_query = new WP_Query( 'post_type=foo&amp;post_parent=93' ); // The Loop while ( $the_query-&gt;have_posts() ) : $the_query-&gt;the_post(); echo '&lt;li&gt;' . get_the_title() . '&lt;/li&gt;'; endwhile; <...
child of post type (custom)
wordpress
I am working with a blog page that uses the following query: <code> &lt;?php $paged = (get_query_var("paged")) ? get_query_var("paged") : 1; query_posts("category_name=blog&amp;posts_per_page=2&amp;paged=".$paged); ?&gt; </code> and my pagination looks like: <code> &lt;?php $next = get_next_posts_link("Next &gt;&gt;");...
Ok, Now this is particularly very odd...I found this forum post: http://wordpress.org/support/topic/error-404-on-pagination-when-changing-posts_per_page-on-query_posts Which basically says that if you are restricting the number of posts to a number less than 10 (which is the WordPress default), sometimes it can break p...
Wordpress with broken paging page 3
wordpress
I was goofing with the settings (first problem) in the "General" tab of my wp-admin panel on my self-hosted blog. There are two settings: Wordpress.com URL and Blog URL (or something). They were both originally set to my self-hosted <code> www.domain.com/blog </code> . I thought if I changed the Wordpress.com URL to an...
This is sort of two questions in one, but to solve your first problem and get your blog working again you need to edit your MySQL database. If you have access to PhpMyAdmin open that up and find the <code> wp_options </code> table. Inside the table there are two values to change <code> siteurl </code> and <code> home <...
Self-hosted blog Admin Panel Forwarding to WP.com
wordpress
I have featured images shown for different posts of same category in a page in a specific div. I need to show the whole post related to this image in the same page in another div. I know i must use JavaScript in this. But i need some reference which i can use for this. Can anyone help me with this? I am using the follo...
Replace your above code with this following code : <code> &lt;?php /* Template Name: Meet The Team Template */ ?&gt; &lt;?php get_header(); ?&gt; &lt;div id="meet_posts" class="narrowcolumn"&gt; &lt;?php $recent = new WP_Query("cat=6&amp;orderby=title&amp;order=ASC"); while($recent-&gt;have_posts()):$recent-&gt;the_pos...
Javascript in wordpress
wordpress
I added infinite scroll support of the Jetpack plugin to my own theme using this tutorial: <code> add_theme_support( 'infinite-scroll', array( 'container' =&gt; 'content', 'footer' =&gt; false, 'render' =&gt; 'vividflow_infscroll_render', 'wrapper' =&gt; 'post_summaries', 'posts_per_page' =&gt; 12, 'type' =&gt; 'scroll...
Grabbing the values Normally you just access the <code> $wp_query </code> object or, in case you did do a custom query like <code> $my_query = new WP_Query(); </code> , the <code> $my_query </code> object. From there you can get the <code> $wp_query-&gt;numberposts </code> (or better, as non-deprecated: <code> $wp_quer...
Get 'page' number with infinite scroll
wordpress
Is there a way to add a class to a div, when the current site url is equal to the permalink of a post? I need a class "current" to my custom made menu. I put the posts links in a list item with a loop, and for every link i want to check if the permalink is equal to the current page url. If the permalink matches the cur...
I would do something simplier using ID : <code> &lt;?php $current_id = $post-&gt;ID; ?&gt; &lt;?php query_posts('orderby=name'); ?&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;li&gt; &lt;?php $current_class = ( $current_id == $post-&gt;ID ) ? 'class="current"' : ''; ?&gt; &lt;a &lt;?php if ( $current_class...
If permalink is equal to current site url
wordpress
(WP 3.5.1) My blog has a header picture showing its name. But for some reason exactly one post shows a picture in the header which is actually used within the post itself. http://www.joyofdata.de/blog/frequency-of-character-combinations/ I don't even know how I would acomplish such feat if I wanted - given that the hea...
in Twenty Eleven, any featured image in a post or static page, with image dimensions larger than the size of the header image - 1000px width in the unedited theme - will automatically get used for the header image.
One post out of more than twenty shows odd picture (from post) in the header
wordpress
I am generating the following notice in my options.php when testing my theme in wp_debug mode. I can see where the problem is but do not know how to fix this issue? It seems the non object is being called from the taxonomy array in options.php as the array cannot find the term_id because a post and or category has not ...
You can use isset() or property_exists() to check if the property exists. <code> foreach ( $taxonomies_password_terms_obj as $taxonomy) { if( isset( $taxonomy-&gt;term_id ) ){ $options_password_taxonomies[$taxonomy-&gt;term_id] = $taxonomy-&gt;name; } } </code>
Notice: Trying to get property of non-object in options.php
wordpress
I have a number of external SQL tables that have data in exactly the way I want and I would like to use them to populate various wordpress posts with shortcodes. The problem is that I don't understand how wordpress 'filters' text in get_content() so that the proper and are added. IOW: I have a proper WP Post and I disp...
You can run the <code> the_content </code> filters on your data. <code> foreach ($results as $r) { echo apply_filters('the_content',$r); } </code> That should get you the same formatting as in your posts. http://codex.wordpress.org/Function_Reference/apply_filters
Add Default Wordpress Formatting To Data From External SQL Tables?
wordpress
Tom J Nowell posted this code to help me retrieve the YouTube video time. Functions <code> // function to parse the code from the URL function parse_youtube_video_id_from_url( $video_url ) { $splited_data = explode( '=', $video_url ); $video_unique_code = substr( $splited_data[1], 0, -strlen( strrchr( $splited_data[1],...
The following are the functions that I use to extract data from a YouTube response to <code> wp_remote_get </code> . It's just the basic stuff, you'll have to adjust, complement and integrate into your code. <code> add_action( 'save_post', 'brsfl_save_postdata' ); function brsfl_save_postdata( $post_id ) { // IMPORTANT...
How can i create a function to get youtube video time
wordpress
On the Codex on Post Thumbnails, I see: Post Thumbnails is a theme feature introduced with Version 2.9. It was quickly changed to Featured Images with Version 3.0. Post Thumbnail, now Featured Image, is an image that is chosen as the representative image for Posts, Pages or Custom Post Types. On the changelog for Versi...
This is explained in the core ticket #12554. Change label in UI for Post Thumbnail and Page Image to "Featured Image" for both We should change the UI label for the post thumbnail box on post and page editor screens. It's post thumbnail for posts, and page image for pages, but it's not always a thumbnail and the labeli...
What's the difference between post thumbnails and featured images (if any)?
wordpress
Maybe I'm not getting the whole concept, but is there a way to modify a Custom Post Type so that it includes other 'fields' like a 'real' db table. I don't mean a Custom Field (get_meta)... I mean inside the table that can be manipulated with rules. I want to make a post type with several -mandatory- fields. eg. <code>...
There is no built in way to do so. You could possibly do it via MySQL directly via ALTER TABLE but you'd have to write custom code to take advantage of this yourself. Another option is to create a new table where each set of data references a certain post. Yet again, you'd have to manage everything yourself. My suggest...
Is There A Way To Add Another Field To Custom Post Type (Not Custom Field/Meta)?
wordpress
At the bottom of each post, I want to display posts that have the same tag. Based on numerous examples of function doing something similar, I created the function below. I call it from with in the loop from the custom post php that I created. It's called succesfully, but I don't get the list of titles that I expect to ...
<code> foreach( $posts_array as $post ) { echo the_title(); } </code> I think the problem is you call the_title() without setup_postdata first If I were you, I'll simply use $post-> post_title . <code> foreach( $posts_array as $post ) { echo $post-&gt;post_title; } </code> This is because you are "get_posts"ing within ...
How to create an overview of posts with the same tag?
wordpress
i want to add this part to wordpress page but every time i add it wordpress add extra stuff that stop it from working properly this is my code <code> &lt;li data-hovercolor="#e859c5"&gt; &lt;a href="/digitalways/?page_id=308"&gt; &lt;h2 data-type="mText" class="sti-item"&gt;server&lt;/h2&gt; &lt;h3 data-type="sText" cl...
Add this to your functions.php, this should give the result you're looking for: <code> remove_filter('the_content', 'wpautop'); </code>
page wordpress add extra unwanted stuff
wordpress
I don't know how to check this but it seems to do the redirection when I change the permalink structure.
Yes it does. For a long time I could not find the answer too which made worry about changing. One day I just did it and checked. The Firefox AddOn Live-Headers shows it very clearly.
Does WordPress automatically do 301 redirect if I change permalink
wordpress
I can't seem to find this in the docs or through google. So basically I'm just looking for the Javascript event that fires when an item is added to the cart. For some reason my default added to cart notification isn't working. EDIT: So I'm thinking because I'm including the woocommerce.php file in my themes default fol...
Read the source. From woocommerce-ajax.php (in the plugin's root folder) Javascript/Ajax add to cart <code> /** * AJAX add to cart * * @access public * @return void */ function woocommerce_ajax_add_to_cart() { global $woocommerce; check_ajax_referer( 'add-to-cart', 'security' ); $product_id = (int) apply_filters('wooco...
What is the Javascript event for an item being added to the cart in Woocommerce?
wordpress
I have a meta key called 'prijs' in each post. The value of this meta key consist of numbers in the follow structure: 2,100.00 I want to remove the comma in the meta value to get this output: 2100.00 So, i created a function but it doesn't work: <code> add_action('wp_insert_post', 'deleteCommaDB'); function deleteComma...
You'll only need to run it once, but this should get all your posts, and then loop through them and update the meta. <code> add_action('admin_init', 'deleteCommaDB'); function deleteCommaDB(){ // The Query $args = array ( 'posts_per_page' =&gt; -1 ); $the_query = new WP_Query( $args ); // The Loop while ( $the_query-&g...
Function to change meta value in database for each post
wordpress
When I create a page with the content as <code> [contact-form-7 id="199" title="Untitled"] </code> , it displays the form, but when I use it as <code> &lt;div class="first"&gt;&lt;?php $recentProjects = get_post('275'); echo $recentProjects-&gt;post_content; ?&gt; &lt;/div&gt; </code> it is not working. It is displayin...
This is correct behaviour. A simple <code> echo </code> will just return the field from the DB, unmodified. if you want to render the shortcode try <code> &lt;div class="first"&gt;&lt;?php $recentProjects = get_post('275'); echo do_shortcode($recentProjects-&gt;post_content); ?&gt; &lt;/div&gt; </code>
wordpress not displaying my form
wordpress
I have been reading around and cannot seem to figure this out. Everything is working fine except that pagination seems to not work, I am adding a second rewrite rule, shouldn't this fix that? I can get to the first page fine, but any page beyond throws a 404. Here is my code: <code> // Rewrite the Sermon URL function s...
Figured it out. I had everything right, it just was not being called in the proper order. I should have been matching paged url's first before the post. This is my working code: <code> // Rewrite the Sermon URL function sermon_rewrite() { $cpt = 'sermon'; $tax = 'series'; add_rewrite_rule( '^'.$cpt.'/([^/]+)/page/([0-9...
URL rewrite breaking pagination
wordpress
I am trying to build a Wordpress theme with boostrap, but the nav menu is giving me some trouble. I would like the dropdown to work like boostraps dropdown, but I do not know how to do this. This is my menu: <code> &lt;ul class="nav"&gt; &lt;?php wp_nav_menu( array( 'items_wrap' =&gt; '%3$s' ) ); ?&gt; &lt;/ul&gt; </co...
You will need to write a custom walker extending <code> Walker_Nav_Menu </code> , more or less like so: <code> class My_Custom_Nav_Walker extends Walker_Nav_Menu { function start_lvl(&amp;$output, $depth = 0, $args = array()) { $output .= "\n&lt;ul class=\"dropdown-menu\"&gt;\n"; } function start_el(&amp;$output, $item...
Bootstrap drop down menu with wp_nav_menu
wordpress
I have a snippet of code I've written in the functions.php file which is simply to remove menu pages if the user cannot activate plugins. It works as intended; however it is showing a PHP error in the admin area only if the logged in user is an administrator. Here's the code snippet: <code> &lt;?php /************ Remov...
Put the <code> add_action </code> line inside the <code> if (!current_user_can('activate_plugins') ) { </code> : <code> &lt;?php /************ Remove admin menu items from anyone who isn't an admin ************/ if (!current_user_can('activate_plugins') ) { function my_remove_menu_pages() { remove_menu_page('link-manag...
Remove Menu Page Giving Error
wordpress
So, I asked this question differently in another thread but it was more of an advice type question so it really didn't render any useful responses. I believe I can word it better and should help some of you decipher what I am trying to accomplish and possibly help someone else once we collaborate on a solution. I have ...
I've dabbled in this as well. For a meta box I recommend the Meta Box plugin (which I regularly contribute code to). A good tutorial on how to use it is here . For custom columns, do a search in WPSE but stackexchange-url ("this") should get you started. Saving the post title involves using the <code> save_post </code>...
How To Set Custom Post Type Title Without Supports
wordpress
I have a form on my site, created using Contact Form 7 with Captcha. Contents of the form when POSTed are being sent to a PHP script, the "action" attribute of the form is set to <code> themes/&lt;themename&gt;/&lt;filename&gt;.php </code> We have been receiving a lot of spam, it seems that someone can handcraft the fo...
You must hook the form using <code> wpcf7_before_send_mail </code> and add your PHP code to functions.php (since the script is already in your theme folder)? You won't lose any of CF7's abilities. <code> function wpse_process_form( &amp;WPCF7Object ){ #process your form here } add_action('wpcf7_before_send_mail', 'wpse...
How to stop direct HTTP POST to a PHP script?
wordpress
If i have a set of years, retrieved by the loop, for every years can be more post ID. Like: <code> 2008 =&gt; 3,7,8 2009 =&gt; 4,5,6 2010 =&gt; 9 </code> the code is: <code> query_posts('post_type=portfolio&amp;posts_per_page=-1'); if (have_posts()) : while (have_posts()) : the_post(); $tmp_date = //get the year; </cod...
Use <code> ksort </code> <code> ($projectsByYear) </code> Of course every time you add something to the array it will need to be resorted.
Multidimensional array sort?
wordpress
I've a problem. I've tried a lot of things but I could not find a solution. I use query_vars parameters in this page and there isn't any problem. But i don't use different parameters or the same parameters in different custom page (../videolar). Parameter value is always empty. Parameters used once ? Function.php : <co...
The problem is solved. Re-save your permalink settings after you add the parameter. Or change the file permissions of .htaccess to 777.
problem in query_vars parameters
wordpress
I work with websites which require using Post Meta for Post Objects within a particular Post Type. I often add a Meta Box to a particular Post Type, to provide additional settings for the new Post Object being created. You can imagine by now, I have created a few classes which make Post Meta management easier for my ev...
If you need to search by your <code> meta_key </code> / <code> meta_value </code> then do not store them in a single key. If you store as a single key then you are going to have to store your data as <code> serialize </code> d string, or something similar. The only way you can search that would be via an inefficient <c...
Better post meta efficiency?
wordpress
When you hover over my drop-down menu using IE8 or IE9, the menu div will display behind the YouTube embedment. It works fine on all other browsers. Upon research, I found out that many others have the same problem and the solution is to set the <code> wmode </code> attribute to <code> transparent </code> . So for inst...
You can filter the HTML output for oEmbed with <code> oembed_result </code> . Now test the HTTP host of the URL for <code> www.youtube.com </code> and add the parameter. The oEmbed result is cached in a post meta field to avoid too many requests. To update old posts I have added an activation helper that clears those c...
Set wmode attribute to transparent for the embed shortcode to make drop-down menu hover over YouTube embed in Internet Explorer
wordpress
I use the tag cloud widget on my site. I have some tags which consist of more than one word, like 'free will'. In the tag cloud, there sometimes comes a line break in those tags, between the words: How can I make that this doesn't happen? I thought of adding <code> display:inline-block; </code> to the style of the tags...
Try this in your CSS (untested, but should work in theory) <code> .tagcloud a { white-space: nowrap; } </code>
No line breaks in tags in tag cloud
wordpress
Can i reduce the queries by compresing this ?, cand i reduce queries, if i can , how can i do? Note : The images are in diferent size http://oi55.tinypic.com/rwp3ex.jpg <code> &lt;div class="art-Block"&gt; &lt;div class="art-Block-tl"&gt;&lt;/div&gt; &lt;div class="art-Block-tr"&gt;&lt;/div&gt; &lt;div class="art-Block...
Because this is very similar to stackexchange-url ("How to reduce the database query-es") I will then give you an outline of a possible solution: You have four similar loops with <code> 1) 1 post &amp;&amp; offset=0 2) 4 posts &amp;&amp; offset=1 3) 5 posts &amp;&amp; offset=1 4) 6 posts &amp;&amp; offset=1 </code> so ...
Reduce Database Queries in Code
wordpress
I am generating the following notice in the options-framework.php. Notice: Undefined index: in options-framework.php I believe it is something to do with sanitization, but do not know how to resolve this issue. I have the following arrays defined in options.php <code> // Pull all the custom taxonomies into an array $op...
Most likely you have an undefined array index. You can check if the array index exists with <code> isset() </code> like this: <code> if(isset($some_array[$some_index])){ } </code> So check all your arrays in the <code> options-framework.php </code> file. You can try for example: <code> if ( isset($option['type']) &amp;...
Notice: Undefined index: in options-framework.php
wordpress
everyone, is there way to order categories in add/edit post in admin dashboard. The problem is my order must be custom, not by Name or ID. For example: Rumors (id 5) News (id 1) Features (id 7) etc. The ideal solution will be to order categories by description. That way in category description field I will put number o...
Use the <code> get_terms_args </code> hook and modify the <code> orderby </code> argument, like so: <code> add_filter( 'get_terms_args', 'my_sort_terms', 10, 2 ); function my_sort_terms( $args, $taxonomies ) { $args['orderby'] = 'description'; return $args; } </code> Possible values for this argument are listed in the ...
Custom order categories in admin dashboard
wordpress
I want to redirect non logged in users to page id = 2 which have registration form. <code> function checkLogged() { $pg = get_permalink(); if (!is_user_logged_in() &amp;&amp; !is_front_page() &amp;&amp; $pg != home_url('/?page_id=2')) { wp_redirect(home_url('/?page_id=2')); exit; } } add_action('wp_head', 'checkLogged'...
Use following code instead of above code : <code> function checkLogged() { if (!is_user_logged_in() &amp;&amp; !is_front_page() &amp;&amp; 2 != get_queried_object_id()) { wp_redirect(home_url('/?page_id=2')); exit; } } add_action('wp_head', 'checkLogged'); </code>
This webpage has a redirect loop issue
wordpress
I'm working on a WordPress site and have installed a slider plugin that registers a slider on the backend (or multiple sliders) and then displays it on the front end with a couple of simple php snippets. I'm trying to modify the plugin so I can do the same thing with a shortcode. I want the shortcode to be able to regi...
To be able to use a variable that is essentially being created within the shortcode function, you'll need to store it somewhere and then retrieve the value. Wordpress does use global variables internally to store and carry across values, but I wouldn't advise you do the same though. Read about the options API here . Pr...
How to use shortcode attribute in separate function
wordpress
I'm able to list users by a single role only. When I try and add an array to the code below I just get a list of all authors. I'm sure that it is something straight forward that I'm missing. Thanks Josh <code> &lt;?php $roles = array('guest-teacher', 'president', 'core-faculty'); $args = array( 'meta_key' =&gt; 'last_n...
Unfortunately, you cannot pass an <code> Array </code> of User Roles to <code> WP_User_Query </code> . The <code> role </code> argument only accepts a String, which is then cleared by a <code> trim </code> command. See user.php on Line 495 , where <code> prepare </code> handles the Query for the Constructor after parsi...
List users of an array of roles
wordpress
WordPress has a framework in place for handling AJAX which is well documented here: http://codex.wordpress.org/AJAX_in_Plugins My concern with this is that every time you execute an AJAX query, (even if you want to return a single field from a table) this framework instantiates the whole WordPress stack, including any ...
The crude alternative most people resort to is the one where you add a file and include several levels up. This is arguably worse for performance if not just as bad. But there is a variant that works better, if we create our own AJAX entrypoint URL, and specify: <code> define( 'SHORTINIT',true); </code> Then include th...
What's the best way to implement AJAX in WordPress?
wordpress
I am creating a custom website by modifying the twenty-eleven theme. I want to create custom text in the header area that is unique to each page. Is there a way to add a 'description' to each page and then use php to call on that description? Currently it displays the "site title" here is the url to the site so you can...
For something like this, you can use WordPress's built-in "Custom Fields" feature. Step 1 On your edit page, create a new Custom Field (if you don't see the Custom Fields box on your edit screen, click on the grey"Screen Options" tab at the top-right of the page, and make sure the "Custom Fields" box is checked). The n...
custom header text
wordpress
is it possible to set one URL prefix to include one PHP page every time? Only Wordpress header and this PHP page. I need to include some custom application but HAVE TO include wordpress powered web-design. For example - http://my.web.com/customapp/ is a prefix and <code> http://my.web.com/customapp/ http://my.web.com/c...
Try <code> get_template_part() </code> . For example, in your <code> index.php </code> template file: <code> /** * Index template file */ /** * Include header */ get_header(); /** * Include arbitrary file */ get_template_part( 'foobar' ); </code> This will include a template-part file, <code> foobar.php </code> , locat...
URL prefix to include one PHP page
wordpress
I am hiring a content writer for my WordPress blog. I will be the sole blog admin. I need to define a role for this writer. I was wondering if there was a WordPress user role that will allow him to publish posts and pages (even without admin approval), but not be able to Edit or Delete them once published (or only do t...
I would create a new user role, and then assign that role to the user when you create their account. In your <code> functions.php </code> : <code> add_role('content_writer', 'Content Writer', array( 'read' =&gt; true, 'publish_posts' =&gt; true, 'edit_posts' =&gt; false, 'delete_posts' =&gt; false, )); </code> You can ...
Allow Content Author to Publish, But Not Edit or Delete
wordpress
Is there any solution for using jQuery tabs within the native WordPress scripts? If you know of a way to get any method of jQuery tabs working on the frontend and the backend please share your solution. I have tried implementing jQuery Tabs (example source available at link) Dependencies: UI Core Widget Factory Effects...
jQuery UI Tabs are actually shipped with WordPress core, so implementing them is quite easy. It sounds like you're only trying to utilize the tabs on the admin side, so a very basic setup would look something like: In functions.php: <code> function my_enqueue_scripts($hook) { // Only load the scripts on the pages where...
Good solution for adding jQuery tabs anywhere within WordPress?
wordpress
I have a standard page setup at <code> http://mysite.com/mypage/ </code> I'd like to setup a rewrite rule in my theme functions that takes any URLs such as: <code> http://mysite.com/mypage/helloworld/ </code> &lt;-- Currently shows "Not Found" And translates it into: <code> http://mysite.com/mypage/?var=helloworld </co...
As the question was modified, I modify my answer. This task is relatively easy, doable just with a single rewrite rule, which converts everything after /mypage/ string into a variable - I call it var. As this is added to query_vars via hook, is reachable via <code> global $wp_query; echo $wp_query-&gt;var; </code> . <c...
Wordpress Rewrite Rule
wordpress
I am well aware of the use of child themes for this. I know about get_header($name). I already understand the use of conditional tags. I want my plugin to remove the function: <code> function get_header( $name = null ) { do_action( 'get_header', $name ); $templates = array(); if ( isset($name) ) templates[] = "header-{...
I am not sure what you want to do is doable (seems impossible to me but everything seems impossible until someone does it). I thought of a very ugly workaround. <code> add_filter( 'template_include', function( $template ) { $temp = get_temp_dir() . basename( $template ); file_put_contents( $temp, str_replace( 'get_head...
I would like to use create a function in my custom plugin to tell WP to use a different header
wordpress
In a custom post type, I first got all the revisions using <code> wp_get_post_revisions() </code> . I looped through, and compared metadata and postdata to see the differences between the two. However, it seems that when I employ the same strategy on <code> get_the_terms() </code> , I'm getting the proper taxonomies fo...
WordPress only supports revisions for post content, not terms. To create a system that monitors changes in post-term relationships over time, you would have to write a plugin that explicitly handles that. If you're interested in going down that route, you would probably need to use the save_post hook to save term data ...
Saving Taxonomies to Post Revisions
wordpress
I am in the process of writing a plugin that allows end-users to submit a form that includes customer information. Upon submission, I am notified that a new customer has submitted the request form. If I approve the account, I am going to create a WordPress user account. I am at the beginning stages of this plugin and w...
I don't know if we are allowed to link to other answers but there is another question very similar to yours and the accepted answerer stated these things: You should be skeptical of anyone who says that there is a single "right" way. The right way depends on the situation. Using the CPT infrastructure has a number of n...
Custom Post Type or Custom Tables
wordpress
I have a custom walker menu.( See the code below) I would like to have my nav menu like this <code> ---------------------------------- Home | link1 | link2 | link3 (5) ---------------------------------- </code> Where <code> 5 </code> is the children count of link3. Can someone help me to implement this? Here is my curr...
<code> function start_el(&amp;$output, $item, $depth = 0, $args = array(), $id = 0) { $item_html = ''; parent::start_el($item_html, $item, $depth, $args); $locations = get_nav_menu_locations(); $menu = wp_get_nav_menu_object( $locations['primary_navigation'] ); $menu_items = wp_get_nav_menu_items($menu-&gt;term_id); $c...
Custom Nav Walker menu - Display children count
wordpress
I am working on a website that I installed WP on a few months back but haven't worked on beyond the install of WP and a theme. I went back to it today and needed to update WP and install a few plugins. When I went to do that it started asking me for FTP info, which was new to me. After research I added said FTP info in...
Wordpress is only asking for FTP credentials if your chmod permissions are misconfigured. You should start by checking them. It means all files and directories inside wordpress dir and not only wp-content.
Wordpress update and plugin install not working
wordpress
I am making a theme where I have built in my own custom threading and such using twitter bootstrap. I have it now so that, as per default, when you click reply you are shot down to the WordPress comment forum. Is there a way to make the comment forum come to you? to display right under the comment you are replying too?
Enqueue the <code> 'comment-reply' </code> script . <code> function wpse88530_enqueue_comment_reply() { // Enqueue the comment-reply script on //single blog post pages with comments // open and threaded comments if ( // Returns the value for the specified option. // 'thread_comments' is a Boolean option where // commen...
Comment forum to display under the comment you're replying too
wordpress
Newbie in wordpress coding. please tell how to create theme option pages. <code> function my_plugin_menu() { add_theme_page('Theme Options', 'Theme Options', 'edit_theme_options', 'theme-option-slug' , 'settings_page'); } function settings_page() { echo "aa"; } </code>
You created the callback function and the function for adding the Theme page, but you also have to tell WordPress when to call your function <code> my_plugin_menu </code> . You can do this by hooking into <code> admin_menu </code> . <code> add_action('admin_menu', 'my_plugin_menu'); </code> This way WordPress knows tha...
add_theme_page is not working
wordpress
Supposing I have this function which I hooked into my_get_users function: <code> function define_users($group) { //Query database for users belonging to a group global $wpdb; $users= $wpdb-&gt;get_results("SELECT user_id from $wpdb-&gt;usermeta WHERE meta_key='groupname' AND meta_value=$group",ARRAY_N); return $users; ...
try this $users = apply_filters('my_get_users',$group);
Why this filter hook is not working when passing parameters?
wordpress
After following this tutorial -- stackexchange-url ("Showing all the posts in one page?") -- I was able to show all post links in one tag page. Example: http://blogote.com/tag/facebook/ Now I have several H1/H2 headers in those tag pages -- more than 100s. How can I convert these H1 titles into normal titles? Here's th...
I'd change this: <code> class="' . esc_attr( $post-&gt;post_type ) . '-title entry-title" </code> and make a special class for this usage. For example, make it: <code> class="fb-list" </code> and then style it however you like in your style.css file: <code> .fb-list { font-size: 16px; font-weight: bold; } </code> I'd a...
Changing H1 to Normal Links
wordpress
I'm having trouble using the "Dynamic-Image-Resize" plugin by "Kaiser Franz Josef". In my template I'm adding following code: <code> $imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id( $post-&gt;ID ), "Full"); $image_path = $imgsrc[0]; dynamic_image_resize( array( 'src' =&gt; $image_path ,'width' =&gt; 60 ,'h...
Ask the right guy Which you just did, so... here's your answer from the developer. :) What does the right output tell us? First of all, the public <code> dynamic_image_resize() </code> API function is just a wrapper for the singleton itself. When you take a closer look at the class, you'll notice a <code> __toString() ...
Dynamic-Image-Resize Plugin does not output anything
wordpress
I have created a custom post type "events" to display event information. All links to the events work well when I am logged in. However, if I am not log in, all the links for events that set in the future are broken - having a page not found message; but these pages will display as soon as I log in. -- all links for ev...
I would recommend downloading the excellent Advanced Custom Fields plugin and using that. It will let you easily create a field to accept a date and it uses a date picker to ensure you are getting the proper format stored. Then, in your code, all you have to do is this: <code> echo get_field('event_date'); </code> ... ...
Why the custom post type links don't work if not login?
wordpress
I want to auto-login visitors to WP through email links. I use a "userid" parameter with their email and a "redirect_to" one to know where to point them. There are some protected areas in the site, just for registered visitors, and they can't see them if they don't log in first (that's the reason of the auto-login). My...
The <code> init </code> hook is too early, so the <code> is_user_logged_in() </code> check is failing. Try using the <code> wp_head </code> hook instead (with a -1 priority). The exit/die function will still prevent the page from loading, but will give you more access to key globals you may need to evaluate. Example: <...
Autologin only working the second time
wordpress
In the default category widget, when you check the "show posts count" checkbox, the number of posts appear surrounded by parentheses, how to remove them.
Add this code to your functions.php file and it will remove the parentheses and surround the post count with a span with a class to easily style it. <code> function categories_postcount_filter ($variable) { $variable = str_replace('(', '&lt;span class="post_count"&gt; ', $variable); $variable = str_replace(')', ' &lt;/...
How to remove the parentheses from the category widget
wordpress
<code> &lt;?php/* Template Name: Contact */?&gt; &lt;?php get_header(); ?&gt; &lt;?php wp_enqueue_script( 'jquery.validate.min', get_bloginfo('template_directory') . '/js/jquery.validate.min.js', array('jquery') , 3.1, true ); wp_enqueue_script( 'jquery.form', get_bloginfo('template_directory') . '/js/jquery.form.js');...
From your code: <code> $(function() { // Validate the contact form $('#contactform').validate({ </code> WordPress loads jQuery in "no conflict" mode, meaning that the "$" symbol is not defined. Change the "$" to the proper full "jQuery" or use a no conflict wrapper .
Contact form with Jquery and PHP don't work
wordpress
I have a custom post type "pakket", in which I've put all kinds of data in the taxonomy terms. This custom post type has about 50 items, each with their own values for taxonomy terms. For example: Pakket Hakhoutsingel (waardedaling)=0.6 (opbrengstderving)=YES (aanlegkosten)='string' Bossingel (waardedaling)=6 and so on...
At first, you'll have to make a dropdown filled with your values from the database: <code> &lt;select id="pakket"&gt; &lt;?php foreach ($allPakkets as $pakket) { echo '&lt;option value="'.$pakket['id'].'"&gt;'.$pakket['name'].'&lt;/option&gt;'; } ?&gt; &lt;/select&gt; </code> And a div to put results in: <code> &lt;div...
best way to communicate between php and jquery/javascript
wordpress
I want to customise the output of Yoast SEO breadcrumbs, I have this so far which works great: <code> add_filter( 'wpseo_breadcrumb_single_link', 'ss_breadcrumb_single_link', 10, 2 ); function ss_breadcrumb_single_link( $link_output, $link ) { $element = 'li'; $element = esc_attr( apply_filters( 'wpseo_breadcrumb_singl...
They are all null. You haven't set any of those variables. Here is your function. <code> function ss_breadcrumb_output() { return apply_filters( 'ss_breadcrumb_output', '&lt;' . $wrapper . $id . $class . ' xmlns:v="http://rdf.data-vocabulary.org/#"&gt;' . $output . '&lt;/' . $wrapper . '&gt;' ); } </code> All of the va...
Edit Yoast SEO breadcrumbs output
wordpress
I have made a custom template to show the posts in "Products" category in a single page.I have some custom fields.I need to show the values of the custom fields in the page. I have used the get_post_custom_values as the following but i get an error as <code> Warning: Invalid argument supplied for foreach() in C:\wamp\w...
It most probably means that no custom post values have been retrieved for the key <code> Description </code> that you used. According to the Codex , <code> Returns nothing if no such key exists, or none is entered. </code> Try adding <code> print_r($key_values); </code> on the line just after <code> get_post_custom_val...
get_post_custom_values not working
wordpress
After hours of unfruitful Googling, I am asking for your help on this issue. My objective is to display only 1 category with get_the_category if the category ID matches the ID or slug set in the get_the_category function. Basically I'm asking for something like this: let's say there's a category titled "important". I w...
I think you could do something like this: <code> $categories = get_the_category(); $displayed_category_id = 1; // set this to the category ID you want to show $output = ''; if($categories){ foreach($categories as $category) { if ( $displayed_category_id == $category-&gt;term_id) { $output .= '&lt;a href="'.get_category...
Display 1 category only with get_the_category (by ID or slug)
wordpress
I'm trying to figure out if it's possible to get an excerpt from each post, grabbing the first paragraph from each one. I'm currently using the ACF plugin and have custom post types and custom fields. Here's my code: <code> function custom_field_excerpt() { global $post; $text = get_field('news'); if ( '' != $text ) { ...
Assuming your paragraphs are marked with <code> &lt;p&gt; </code> tags, which can be set in the ACF field options, the following should work: <code> function custom_field_excerpt() { global $post; $text = get_field('news'); if ( '' != $text ) { $start = strpos($text, '&lt;p&gt;'); // Locate the first paragraph tag $end...
Excerpt length: get first paragraph
wordpress
I'm trying to implement the Co-Authors Plus Plugin. It says that you will need to change some PHP in the theme. The documentation outlines the changes . I believe I have found where I would need to change it in my theme. In the <code> post-author-info.php </code> file: <code> &lt;?php /** * Post Author Info * * @packag...
I think you're looking for something like this article . It's rather comprehensive, but I'll just cover the multiple BIOs and avatars. You'll want to change your HTML code to this instead: <code> &lt;?php $i = new CoAuthorsIterator(); ?&gt; &lt;?php while( $i-&gt;iterate() ) : ?&gt; &lt;div id="authorinfo" class="colum...
Editing Theme to apply Co-Authors Plus
wordpress
Hy, i make a slide for news, the question is how can i reduce the dathabase queries...ore how can i compress this code... http://s16.postimage.org/bswe0vrph/queries.jpg <code> &lt;div id="featured" &gt; &lt;ul class="ui-tabs-nav"&gt; &lt;li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1"&gt; &lt;?php $rec...
You can try this version with <code> WP_Query() </code> called only once: <code> &lt;?php $args=array( 'post_type' =&gt; 'stiri', 'posts_per_page' =&gt; 5, 'taxonomy' =&gt; 'stire', 'stire' =&gt; 'articole-speciale' ); $recentPosts = new WP_Query($args); ?&gt; &lt;div id="featured" &gt; &lt;ul class="ui-tabs-nav"&gt; &...
How to reduce the database query-es
wordpress
<code> foreach((get_the_category()) as $category) { echo $category-&gt;cat_name . ', '; } </code> So I'm echoing it like this because I don't want the categories to appear as hyperlinks, I just want the cat names. The problem is I can't get rid of the last separator so it ends up like : category, category, category, I ...
There are two ways to solve this issue. You need a clean array of category names for both, so let’s start with that: <code> $cat_names = wp_list_pluck( get_the_category(), 'cat_name'); </code> <code> $cat_names </code> is now an array with just the names: <code> Array ( [0] =&gt; aciform [1] =&gt; Cat A [2] =&gt; Cat B...
strip last comma from get_the_category
wordpress
I'm having trouble with some images not showing up. These were fine and then suddenly stopped working for no apparent reason. A couple of examples: http://coachmi.com.au/blog/2012/11/how-to-build-a-strong-organisational-culture/ http://coachmi.com.au/blog/2012/11/the-path-creating-your-mission-statement-for-work-and-li...
I had a look at your links, looks like you are using Jetpack which puts all your images on the WordPress CDN. For some reason it is not working correctly. Turn it off and it shall work properly. Most likely you must have changed the image after publishing the post
Some images suddenly not appearing
wordpress