question stringlengths 0 34.8k | answer stringlengths 0 28.3k | title stringlengths 7 150 | forum_tag stringclasses 12
values |
|---|---|---|---|
I am using custom post_type and inside the loop I echo get_delete_post_link but there is nothing echoing. <code> <?php $wpquery = new WP_Query('post_type=myposts'); if( $wpquery->have_posts() ) { while ($wpquery->have_posts()) : $wpquery->the_post(); $id = get_the_ID(); //just a test to see can I get post I... | Is the user logged in and is allowed to delete posts of this post type? There are three checks inside the <code> get_delete_post_link </code> function before anything starts happening: <code> if ( !$post = get_post( $id ) ) return; $post_type_object = get_post_type_object( $post->post_type ); if ( !$post_type_object... | Can't echo get_delete_post_link | wordpress |
I'm new with unit testing in Wordpress. I managed to setup the unit testing environment using PHP Unit and Wordpress tests but I am having trouble accessing the plugin options that I've set in the plugin. <code> class nrw_pg{ private $twitter_id; public function __construct(){ $options = get_option('nrw_pg_options'); $... | As the testing database is (usually, and should be) a separate database, you will need to set the appropriate option value in the setUp routine (using add_option or update_option). I would also recommend deleting or reseting the option in the teardown method as well, but I have had issues when trying to drop tables (se... | Unit testing wordpress plugins with plugin options | wordpress |
I am trying to pull up posts from only category ID 18 with this query for a plugin I am working on but it will not work. I can not use <code> query_posts </code> or <code> WP_Query </code> in the place I am using this. <code> global $wpdb; $posts = $wpdb->get_results( "SELECT ID, post_title, post_content, post_date ... | This is a SQL problem. Your query is wrong. You forgot to include the term_relationships table in the query, yet reference it during the JOIN. By including the term_relationships table, that would solve the problem with the query. <code> SELECT ID, post_title, post_content, post_date FROM {$wpdb->posts} AS p JOIN {$... | WPDB Query Question with Category Only | wordpress |
I have been pouring through the code trying to find out how the navigation menu is actually built. In my header I see: <code> < nav id="site-navigation" class="main-navigation" role="navigation"> < h3 class="menu-toggle">Menu< /h3> < a class="assistive-text" href="" title="Skip to content">Skip ... | The code in question is in header.php, line 45. <code> <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?> </code> This is the Codex reference to this function: wp_nav_menu . From my experience, and some googling, stackexchange-url ("this previous answer") has the ans... | How does the Twenty Twelve Navigation Bar work? | wordpress |
Is this possible? I've never seen it used, but I need it... I want to show for each author (if they are logged in) on their own profile page, the amount of comments they have posted today. If the day passes by, than the counter has to be 0 and the comment counter has to start again. | You can try this query that counts user comments by using the <code> user_id </code> field in the comments table as a filter: <code> function count_user_comments_today( $uid ){ global $wpdb; $today = date('Y-m-d'); $tomorrow = date('Y-m-d', time() + 86400); $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*)... | Show comment number per author per day | wordpress |
I've got these custom post types (CPT) and meta boxes: Movies (CPT) Genre (Meta box) Genres (CPT) If one movie is called Die hard then I want the permalink to be: /genres/action/die-hard This is easily fixed by setting the movie-CPT to 'rewrite' => false and use this code instead: <code> add_action('init', 'rb_add_rewr... | It sounds like you're very close here and your only remaining issue is that your permalinks for genres and movies collide. <code> 'movies' CPT permalink /genres/%custom field meta box value%/%movie%/ 'genres' CPT permalink /genres/%genre%/ </code> The issue here is using the <code> add_permastruct </code> . When it cre... | Rewrite custom post type url's adding meta box values | wordpress |
I using post meta like.. <code> $meta = get_post_meta(99,'_mymeta',true); $value = $meta['somekey']; echo $value; </code> But how to update <code> $meta['somekey'] </code> to some another value ? How to use update_post_meta to update sub meta key ?(Idk, How ppl call) <code> update_post_meta(99, '_mymeta["somekey"]', 'm... | To update post meta that are an array: you have to fetch the original values, change the value you need and update it again. For example <code> $list_of_values = get_post_meta($post_id, '_list_values', true); if(!empty($list_of_values)) { $list_of_values["some_prop"] = "new value"; } update_post_meta($post_id, '_list_v... | How to update/delete array in post meta value? | wordpress |
I am redoing some of my older blogs and I noticed with the new themes most of them take advantage of featured images which is fine. The problem is a lot of my older posts that was never set either because I did not use it or because it didn't exist. Now I know of the featured thumbnail plugin the regenerates your posts... | You need to first download those external images then you can attach and set them as the post thumbnail. To download and attach you can use the <code> media_handle_sideload() </code> function. I wrote a plugin that will search through all your posts and pages and download and attach any external image into the media li... | Create post thumbnails from images stored outside of uploads directory | wordpress |
I have a question about the comment numbers in a post... For now, I can output the total number of a comment inside a post outside the loop. That's cool enough, but I want to get show the comment number/amount of a post PER DAY . So let's say I have a post and people are commenting 10 times today... Than, I want to sho... | There is no argument to restrict a comment query directly to a given date. You have to filter the query later: <code> /** * Get the number of comments for a post today. * * @param int $post_id * @return int */ function t5_count_comments_today( $post_id = NULL ) { if ( NULL === $post_id ) $post_id = get_the_ID(); add_fi... | How to output comments number of a post per day? | wordpress |
Is it possible to set woocommerce to not charge the customer until the product actually ships? | This is not so much a WooCommerce issue as a payment gateway issue. Paypal distinguishes, for example, between 'authorization' and 'capture', Worldpay has similar terms (and a different API). E.g. for Paypal see https://cms.paypal.com/es/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_authcapture . I... | Dont' charge customer until product ships - woocommerce | wordpress |
As you see in the snapshot, just the main site appear in My Sites menu, Although it appears correctly in the "Network Admin". I used the subdomain installation when I configured the Wordpress MU. And this is the Wordpress MU part in wp-config.php <code> define('WP_ALLOW_MULTISITE', true); define('MULTISITE', true); def... | I found the solution , it's dead simple, I should add myself to the child site as a user, I guess this should be done by default. | Child Site doesn't appear in the Network menu | wordpress |
I'm working some API. Core is WordPress. Okay, let me paste a sample: <code> <?php include_once('../wp-blog-header.php'); $roll= esc_attr($_GET['roll']); if ( $roll != "" ) { $args = array( 'meta_key' => 'std_roll', 'meta_value' => $roll, ); $blogusers = get_users($args); foreach ($blogusers as $user) { echo '... | I was solved using <code> <?php include_once('../wp-load.php'); </code> | WordPress & External Page: 404 error in IE and some others | wordpress |
How can I call the usernames of people that have edited a post? I know I can use <code> get_the_modified_time </code> to display the time the post was last modified, is the same possible with the list of users that edited it? | The WordPress function <code> get_the_modified_author() </code> will give you the author who last edited the current post. But if you want to list all the users that have edit the current post, you could try: <code> function get_the_modified_authors_wpse_99226(){ global $wpdb; $authors = array(); $results = $wpdb->g... | Get names of authors who have edited a post | wordpress |
I have the following code I'm trying to automatically add a menu to a theme via overriding a function. So I won't have to edit the theme file However the menu is being outputted at the top of the page and on every page instead of only in its given location. <code> /******************************* MENUS SUPPORT ********... | I think your current call to <code> wp_nav_menu() </code> may be echoing the menu when the code is seen and not returning it in the function. Try this call: <code> wp_nav_menu( array( 'theme_location' => 'legal_footer_navigation', 'echo' => false, ) ); </code> If that works, you can also probably remove the echo ... | How Can I add a menu to the theme from withen the function.php file | wordpress |
I have set up the following to create 'pretty' post type and category permalinks: <code> function kdev_add_category_rules() { $post_types = array( 'kdev_photos', 'kdev_videos', 'kdev_articles' ); foreach($post_types as $post_type) { $pt_obj = get_post_type_object($post_type); $pt_rewrite = $pt_obj->rewrite; $pt_slug... | I would say you need to add the following rewrite rule in your foreach loop: <code> add_rewrite_rule('^'.$pt_slug.'/category/(.+?)/page/?([0-9]{1,})/?','index.php?post_type='.$post_type.'&category_name=$matches[1]&paged=$matches[2]','top'); </code> | Adding paged query to custom URL rewrite | wordpress |
I'm trying to activate a plugin I made on a network site. I'm getting an error: <code> Plugin could not be activated because it triggered a fatal error. </code> I have the debug mode on and it outputs all errors into a debug.log, however nothing is given for this error. Is there another way to see what the error may be... | I eventually muscled my way through it. The first thing I did was stackexchange-url ("manually activated the plugin via the database"). Next I went back to the subsite to verify that the plugin was activated. It was not. So I tried activating again. Now I was getting an error in relation to memory being exhausted. This... | Plugin fatal error | wordpress |
I have a custom tabbed menu which has some input fields that works properly. I followed this tutorial: http://wp.tutsplus.com/tutorials/the-complete-guide-to-the-wordpress-settings-api-part-8-validation-sanitisation-and-input-ii/ But, I need to replace the textarea input for the rich text element. I tried to use the fu... | This is was I use to convert textarea with wp_editor() <code> wp_editor($value, "editor-name", array( 'tinymce' => array( 'theme_advanced_buttons1' => 'bold,italic,underline', 'theme_advanced_buttons2' => '', 'theme_advanced_buttons3' => '' ) )); </code> | Convert textarea with wp_editor | wordpress |
I would like to offer my visitors the option to download the entire photo gallery (displayed on dedicated [gallery] pages) as a ZIP file displayed at the bottom of each gallery page. - The full-sized image will have to be included. David Walsh has given some code in his post here to zip up files but I'm having troubles... | First you have to get the images. How to get all images of a gallery is described stackexchange-url ("here"). WordPress uses two classes for unzipping files. The PHP bilt in <code> ZipArchive() </code> (usage see David Walsh). And PclZip, you can found this class in <code> wp-admin/includes/class-pclzip.php </code> . I... | ZIP up all images displayed in a [gallery] and offer as download link | wordpress |
I am trying to use the below code snippet to display an image and then wrap it in a link to a specific term archive page. In this case, I have a custom taxonomy (Series) with a few different terms. The variable $series outputs the Term Object, therefore I want to use the get_term_link function to get the URL to the ter... | That field can return multiple term objects depending on how you've got it configured, so I'll guess that <code> $series </code> in this case is an array containing a single element, which contains your term object. Try inspecting the contents of series: <code> print_r( $series ); </code> You'll probably see something ... | get_term_link not working | wordpress |
It's a strange issue and I've seen it happen with plugins, however I don't know how to fix it. Maybe just a PHP issue? Anyhow, I have a settings/options page with several text areas. Upon saving, a "\" appears before each apostrophe. Each time it's saved, an additional back-slash appears. I'm not sure what code would b... | It's a PHP issue. The character <code> ' </code> is being escaped so that it can be safely in various places, not least of which is the database. That's why your <code> ' </code> look like <code> ' </code> . You can use PHP's <code> stripslashes() </code> function to clean it up, or (if it's an array you need to clean ... | Character \ appearing before ' after saving a settings page | wordpress |
I am trying to create custom welcome panel in dashboard for WP and can't see where I went wrong. It's not allowing me to add html. | Your <code> update_option </code> should be inside a hook callback and should check to see if <code> $_POST['custom_welcome_panel'] </code> is set before trying to update the option. Otherwise that could be overwriting your option every time the page loads. And, honestly, as written I could shove anything I wanted into... | Customize Plugin | wordpress |
I'm trying to display the 5 best rated posts of the last week (7 days) on my website, however I can't seem to figure out how to display them. Here's what I've achieved so far but it doesn't seem to work: <code> <?php $slider_query = new WP_Query('posts_per_page=5&cat=3&orderby=highest_rated&order=desc');... | I think this must have been solved many times here on WordPress Answers. You could also check out the examples in the Time parameters part in Codex for <code> WP_Query </code> . Here are two of them (slightly modified to your needs) Example 1: <code> // Create a new filtering function that will add our where clause to ... | Display posts of the last 7 days | wordpress |
How can I show the amount of a comment per post outside the loop? I tried this in a function already: <code> ' . get_comments_number . ' </code> , but that outputted the text "array" on the screen... What do I have to do for getting it to work? On my <code> single.php </code> I used this to output some list items (post... | To print just the total number of comments for a given post ID, use the <code> count </code> argument: <code> echo get_comments( array ( // post ID 'post_id' => 149, // return just the total number 'count' => TRUE ) ); </code> To get the total number of all comments of all posts on the current page, you can use t... | Can't show comments count per post outside loop | wordpress |
I would like to know the best way to debug email issues in woocommerce when the mails are not being sent for any account/Order related processes. Thanks | This sounds like your site is unable to send emails from the web server or your emails are being blocked by spam filters. Try setting up a free account at one of the two services I've linked to below and install their WordPress plugin and see if this fixes your email issues. Sendgrid Mandrill | Woocommerce Emails not being sent | wordpress |
I’m creating a custom registration form for my website. Every tutorial has this call in the form <code> require_once(ABSPATH . WPINC . '/registration.php'); </code> I’ve read that <code> registration.php </code> has been depreciated quite a long time ago. Which file must be called upon, what is the proper way? | If you look at the source of the file you can see that it doesn't do anything even if you were to include it except add a warning that "This file no longer needs to be included". So those tutorials are out of date. You don't need to include it. The file you actually need to <code> include </code> , if any file at all, ... | Include "registration.php" for custom registration form? | wordpress |
i registered my sidebars as follows: <code> $sidebars = array ( 'sidebar-10' => 'Hoof Sidebar', 'sidebar-11' => 'Tuisbladsy area een', 'sidebar-12' => 'Tuisbladsy area twee', 'sidebar-13' => 'Tuisbladsy area drie', 'sidebar-14' => 'Tuisbladsy area vier', 'sidebar-15' => 'Voet area een', 'sidebar-16' =... | You just need to use the alternate syntax for foreach. From the php manual : The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable. There are two sy... | register sidebars | wordpress |
I am using themefuse WP theme and facing this problem. http://themefuse.com/forum/thepractice-wp/twiiter-newsline-is-blank Can someone please suggest if I need to use some other attribute. I am not finding any help on ThemeFuse site. Thanks | It is very likely because you are using the old Twitter API, for example: <code> <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/USERNAME.json?callback=twitterCallback2&amp;count=4"> </code> You will need to update your code to the new API: <code> http://api.twitter.com/1/statuse... | Twitter feed is showing blank in WP site | wordpress |
I'm trying to connect some user_meta data from registration form to some categories set up in admin to filter the presentation on the page. This one is tripping me up because the question has multiple answers ... Here is what I have set up so far ... <code> $user_id = $current_user->ID; $user_values = get_user_meta(... | Are you looking for this? <code> function convertInterestCategory() { $interest_categories = array( 'interest_disaster', 'interest_animals', 'interest_women', 'interest_seniors', 'interest_hunger_health', 'interest_education', 'interest_environment', 'interest_arts_culture', 'interest_children_youth', 'interest_other',... | Matching usermeta at registration to categories of content | wordpress |
This code retrive me the movies that are comming in cinema, i want to be able to list movies that apear this day, next day ... 7 day week Ex: Today is 13.05.2013, i want to list the movies that apear this day ( - the code down list me all the movies that are comming)... and if the day pass to 14.05 i want the box post ... | What you want to do in this case is to use a meta_query in WP_Query like the following. You can reference the following Codex for more information https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters . Once you have the posts. Loop over them and add their date as data attribute, and filter the i... | Display movies that apear this day next | wordpress |
I have a custom post type with its meta in an array. What I need to do is query based on the value of a key in that meta array. <code> $args = array( 'post_type' => 'my-cpt', 'posts_per_page' => -1, 'orderby' => 'meta_value', // Sort by this value 'meta_key' => 'my_meta_array', // Sort by this meta key 'met... | You can't do that. When you save postmeta (or any other meta, for that matter), WordPress runs it through <code> maybe_serialize </code> which turns objects and arrays into serialized data . When it gets pulled back out, it is run through <code> maybe_unserialize </code> . Serialized data looks something like this: <co... | WP_Query meta_query by array key | wordpress |
I am currently starting a plugin development project and ideally I'd like the plugin to run using its own custom theme as if it was it's own separate thing. Is it possible to include a theme within the plugin that has its own custom page layout etc and would only use that template when the related pages are accessed? T... | I don't quite know what you mean by "include a theme" and you are talking about a potentially large and complicated project but I think you should be able to control the display of your plugin content with the <code> template_redirect </code> hook. <code> function template_redir_wpse_99209($content) { // code or file i... | Wordpress plugin with its own "site"/theme | wordpress |
I created a Custom Post Type (call it "my-post-type"). I created an <code> archive-my-post-type.php </code> page for displaying all the Custom Post Types. Looking at the "Recent Posts" section of the Sidebar, I noticed none of custom post types are showing up . I'd like the Custom Post Types to show in Recent Posts as ... | Well, you SHOULDN'T use <code> pre_get_posts </code> , as it will alter ALL the queries in the site. Also, the query made by the recent posts plugin is not the main query. The main query is made for displaying the current page, after parsing the query variables from URL, and it is responsible, among other things for th... | How to get my Custom Post Type to display in Recent Posts using "pre_get_posts" | wordpress |
So I have a CPT of references (like a dictionary kind of format for music). In it there are two taxonomies: <code> medium_reference </code> and <code> reference_letter </code> . The <code> reference_letter </code> lists letters A-Z, while <code> medium_reference </code> lists through the type of reference type it is (p... | In case anyone runs into trouble like I did, I figured it out! <code> $taxonomy_1 = get_terms( 'taxonomy_1', $args_1 ); $taxonomy_2 = get_terms( 'taxonomy_2', $args_2 ); foreach( $taxonomy_1 as $tax_1 ) { foreach( $taxonomy_2 as $tax_2 ) { $posts = get_posts( array( 'posts_per_page' => -1, 'post_type' => 'ENTER-Y... | Looping taxonomy in taxonomy? | wordpress |
I'm trying to figure out the best way to solve this problem. I have a couple of archive type pages that display content from multiple post types at once. For example, I've overridden the default search behavior of WordPress with my own search functionality. Since the core WordPress search isn't used, the global <code> ... | I don't really see anything wrong with what you're doing; globalizing <code> $post </code> and using <code> setup_postdata() </code> are very standard, well-established techniques for dealing with posts that don't come straight out of the standard loop; they're not usually considered hacks. | Advise on Templates for Custom Queries | wordpress |
I'm trying to add a "Publish" link by the quick actions: but I'm not exactly sure of how implement it. Here's what I've got so far: <code> add_filter('post_row_actions', function ( $actions ) { global $post; // If the post hasn't been published yet if ( get_post_status($post) != 'publish' ) { $nonce = wp_create_nonce('... | Without doing Ajax (like in Quick Edit), the <code> admin_url </code> should be the very <code> edit.php </code> page. Note that: the filter <code> post_row_actions </code> takes two arguments, the second one being <code> $post </code> , so the global is not necessary. instead of using <code> id </code> as query argume... | How to add a "publish" link to the quick actions | wordpress |
Is it possible to make a comment out of a post that already exists (with the same name). For example, if the post 'Hello World' exists and a users posts another 'Hello World' post, it should make the second post a comment beneath the first post... How can I do this? | You can use get_page_by_title http://codex.wordpress.org/Function_Reference/get_page_by_title to check if another page/post is using the same title. If so, get the content of that post and insert it using wp_insert_comment, and delete the original post with wp_delete_post. Finally, glue all these together inside the sa... | If post exists, make it a comment in existing post with same name? | wordpress |
I keep having an intermittent issue where the admin bar disappears from a wordpress site I often use, when using my main browser (Google Chrome). I can access /wp-admin/ no problem, and another problem is that post previews will not work, instead showing me the 404 page. Safari, however, works just fine. What can I do ... | I still don't know what the exact cause was, but deleting cookies for the specific site fixed the problem. | Why do previews work in one browser, but not another? | wordpress |
I added open graph meta data to all the posts on a site, however, when I attempt to paste a post link on Facebook, the graph meta information isn't loaded. Then, when I insert the URL into the debugger / linter , it works, both within the debugger and when posting normally on Facebook (which didn't work moments prior).... | First, this isn't a WordPress specific question, it's a Facebook question. Secondly, Facebook caches pages, they don't crawl them on every submission. If you have a URL that has already been submitted to Facebook before, then they will have already crawled it for the OG data once before, and saved it to their cache. If... | Open graph metadata isn't pulled on Facebook until after I run that specific link through the debugger | wordpress |
I Created a custom taxonomy for my <code> projects </code> custom post type. <code> function projects_taxonomy() { $labels = array( 'name' => __('projects Categories'), 'singular_name' => __('project Category'), 'search_items' => __('Search project Categories'), 'all_items' => __('All project Categories'), ... | You have the <code> rewrite </code> argument defined inside the <code> $labels </code> array, move it out to the <code> $args </code> array: <code> $args = array( 'labels' => $labels, 'hierarchical' => true, 'rewrite' => array('slug' => 'projects', 'with_front' => true) ); </code> | Custom taxonomy rewrite using tax name instead of rewrite slug | wordpress |
What I am trying to achieve is to load a .js file on an edit.php page, however the code is not working specifically for this page. I've applied the same code type of code to other CPT pages, but for some reason this CPT page is not registering the script. Here is the code I am using: <code> add_action( 'admin_menu', 'c... | I think you're using the wrong approach. Rather than removing the submenu item, alter how the post type was registered, and change the <code> show_in_menu </code> argument. Hook into init way late and change the argument. <code> <?php add_action('init', 'wpse99123_post_type_switcher', 999); function wpse99123_post_t... | Trying to add script to specific admin page is not working | wordpress |
I'm wondering if there is a way to display current WP Query filters. I wrote a function that is supported to delete all posts and it does but when I'm using WPML and it filters posts by language then it does not remove non-English posts. I thought that using <code> 'suppress_filters' => true </code> will help but wi... | There's a global variable called <code> $wp_filter </code> (you can see examples of it all through the source of <code> /wp-includes/plugin.php </code> . This probably isn't the WordPress Way to do it, but you could try something like this: <code> global $wp_filter; var_dump( $wp_filter ); </code> ...but note the cavea... | How to display WP Query filters? | wordpress |
using function <code> is_archive() </code> we can know whether it is archive page or not. But if it is archive page how can i find whether it is author archive page or category archive or date archive. I have found this code in wp-includes/query.php <code> if ( $this->is_post_type_archive || $this->is_date || $th... | Use just the functions, not the object properties: <code> if ( is_post_type_archive() or is_date() ) </code> There are stackexchange-url ("many conditional functions") (returning <code> TRUE </code> or <code> FALSE </code> ) for exactly these cases. | How to get type of archive whether it is post or date or category archive? | wordpress |
I have a custom post type, which has email and names stored. I would like to take these email addresses and concatenate (join them) together into a single string. This string will be stored in a variable, and I will then assign this variable to the <code> $email_to </code> in wp_mail. Using a cron, the latest 3 posts w... | There are many ways you can do this. For my examples, I'm going to assume you've stored the emails in the <code> post_title </code> field. <code> wp_mail </code> takes a string or array in the to field, so you can do something like this... <code> <?php $emails = get_posts(array( 'post_type' => 'your_email_storing... | Take stored email addresses from custom post type & turn into one string | wordpress |
I'm developing my first plugin for WordPress and I'm getting a grasp of the whole hook system. I'm now stuck on a (probably) small issue, that I could possibly circumvent, but I'm afraid of coming out with a "hack", more than a real solution. What I'm trying to do is putting two submit buttons on my Options page: Save ... | The settings API is crap. I need a long time and need try many until I got this working. My problem was that the values from my inputs never was passed to the validate callback. I end up in using the array method: <code> <input type="text" name="foo[bar]" value="baz" /> </code> If the formular will be send, in th... | How do I handle multiple Submit buttons in plugin's option page? | wordpress |
If someone puts a post on my site, they usually do that with some tags. If someone posts a post with the tag "hello", I want it to output that tag after my content and let it link to the archive page where it queries to see if there is another post with the same tag --> this already works! What I now want is this: say ... | You can use the get_page_by_title function as described by the codex here http://codex.wordpress.org/Function_Reference/get_page_by_title . Here is an example of getting the title of a post. By default, it's looking for a post type of 'page': <code> $current_post = get_page_by_title("certain title", OBJECT, "post"); ec... | Output posts with same name as tags? | wordpress |
I need help on this, the case is I want to get TOP X tags from user post. For example user A wrote 50 post, i want to show TOP 5 tags from that user post, It 's for displaying user interest. second important thing is i m already have the post ID's selected. $pids = array(123,345,323,456,789); Thank you. i found interes... | With an array containing the post IDs its easy <code> $post_ids = array( 167, 774, 787, 358 ); $tag_all = array(); foreach ( $post_ids as $post_id ) { $tags = wp_get_post_tags( $post_id, array() ); foreach ( $tags as $tag ) array_push( $tag_all, $tag->name ); } $result = array_count_values($tag_all); arsort( $result... | Get TOP x Tags from selected posts | wordpress |
Im trying to understand how to get the custom field incr_number into admin columns. However im failing to understand and im googling but not finding a direct answer. It cant be that hard surly? <code> <?php /*-----------------------------------------------------------------------------------*/ /* WooThemes supportpr... | Try replacing everything from the comment downwards with this. Basically you seemed to have a function in there that wasn't getting called, and you need to add the <code> case "incr_number" </code> test to the <code> woo_supportpress_ticket_custom_columns </code> function: <code> /*-------------------------------------... | custom field in admin columns | wordpress |
I've been experimenting with creating a Custom Post Type as a plugin (because I've seen this recommended in various places). But I have a question not about the how , but rather the why of building CPT's as a plugin. Yes... Adding the CPT as a plugin does keep my functions.php nice and tidy. But... Assuming I've enable... | toscho's answer is correct as to the technical reasons to define your CPT in a plugin, but it seems to me that much of you question stems from a misunderstanding of the template hierarchy. Almost, but not quite, every template file that you've seen is optional. With the exception of the basic index.php template file, T... | Creating a Custom Post Type as a Plugin? Why? | wordpress |
I haven't been able to find what I'm looking for and not sure how to approach it. I'm using <code> wp_list_categories </code> to obviously list terms of a taxonomy. I'd like to add some text to the end of each item. Example being: taxonomy_term some_new_text instead of taxonomy_term Here's the basic <code> wp_list_cate... | Use <code> get_categories() </code> (which returns an array of category objects rather than directly displaying them) instead of <code> wp_list_categories </code> , and loop through the results, outputting whatever you want. | Add text to the end of each list item in wp_list_categories | wordpress |
I am trying to build a content submission form on the front end of my site, and I am using <code> wp_editor </code> to render visual text editors for my users, so they can make bold text and lists and stuff like that. The issue is that I can't figure out how to make the wp_editor a required field in my form. I know I c... | You can add a filter to the editor html <code> add_filter( 'the_editor', 'add_required_attribute_to_wp_editor', 10, 1 ); function add_required_attribute_to_wp_editor( $editor ) { $editor = str_replace( '<textarea', '<textarea required="required"', $editor ); return $editor; } </code> | Make editor required for post from frontend | wordpress |
I have a plugin like this: <code> <?php /* Plugin Name: MyPlugin */ class MyPlugin { public function __construct() { add_action('wp_enqueue_scripts', array($this, 'enqueueAssets')); } public function enqueueAssets() { wp_register_script('myplugin', plugins_url('myplugin.js', __FILE__), array('jquery')); wp_enqueue_s... | By the time your widget (or sidebar if this is hard-coded) loads you have already missed the <code> wp_enqueue_scripts </code> hook, which runs in the header and that means that you have missed the window for registering the script in the <code> <head> </code> at all, which you are trying to do-- there is no fift... | Enqueue scripts inside a class in a plugin | wordpress |
I want to show some simple things on homepage with ajax. The problem is I want to load everything when is_home() is true. Php, js, everything. In funtions.php: <code> add_action('init', 'pint_functions_separation_test'); function pint_functions_separation_test(){ if ( is_home() ) { require_once('functions_hometest.php'... | Use: <code> if ( is_home() or ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) </code> <code> is_home() </code> returns <code> TRUE </code> on the front-end only, <code> admin-ajax.php </code> on the other hand is an admin page. So you need to check both conditions. | Load ajax if is_home() | wordpress |
Using the below code to chnage the author page url to use the "nickname". Works ok but when the nickname is more than one word it doesnt make it url friendly. Any way to do this? <code> add_filter( 'request', 'wpse5742_request' ); function wpse5742_request( $query_vars ) { if ( array_key_exists( 'author_name', $query_v... | You've already used <code> sanitize_title </code> once in you code. You need to use that in again, inside the <code> wpse5742_author_link </code> function. <code> $link = str_replace( $author_nicename, sanitize_title($author_nickname), $link ); </code> That should take care of the spaces. Another other option is to use... | Author Nickname URL Friendly | wordpress |
I want to add screen options to my plugin settings page, like the ones that are available in the Dashboard. I tried using the <code> add_option </code> method of the <code> WP_Screen </code> object and found that it supports only two options. <code> per_page </code> and <code> layout_columns </code> . Does anyone know ... | You don’t need to invent a new screen option row. Just use proper metaboxes. Currently, you are drawing pseudo-metaboxes: <code> <!-- Post status start--> <div class = "postbox"> <div class = "handlediv"> <br> </div> <h3 class = "hndle"><span><?php _e("By Post Status", 'bulk... | Add screen options to custom admin pages | wordpress |
As a student software developer who is about to graduate, I find it is time to start my own blog. I've been told it is important to make a name for yourself, to stand out from the rest. Therefore I decided to make a Wordpress website. Since I live in Belgium, I would like a <code> .be </code> domain. But, I'm new to Wo... | Its simple.. Export Just check this page to export your blog data.. http://en.support.wordpress.com/export/ Import Install a fresh wordpress.. Then import it.. http://en.support.wordpress.com/import/ Please note: wordpress.com uses the same software downloaded from wordpress.org.. They just using it as multisite.. http... | Is a *.wordpress.com blog easy to migrate? | wordpress |
I added a filter for option_active_plugins to keep most plugins from loading on an admin page. Confirmed to be on the right page and to be returning a properly altered array, but it's having no effect on which plugins are being included on the page. Tried high numbers for filter priority. No effect. Any ideas? | OK, duh: I needed to have my plugin in the /mu-plugins dir to make its filter available early enough for <code> function wp_get_active_and_valid_plugins() </code> . | option_active_plugins filter not working | wordpress |
I just consolidated a couple standalone WordPress installs into one Multi-site install. After importing posts into each site accordingly, I am unable to edit a post or page, and select a different user. There are four users on the site, and I'm only able to select two of the four users as the post author. Any idea why ... | I found the issue, thanks to @Toscho </code> giving me the spark of an idea. We are using custom user roles and capabilities. It had something to do with the User Role Editor plugin. Deleted the custom role, and created a new one, reassigning all capabilities. Then updating all users to the newly created user role. Pro... | Cannot select certain authors for posts after import | wordpress |
I am working on a theme with custom post type. the issue currently is that i am saving the layout files in a folder called templates.. and in front-page.php i am using an options check to see which type of layout did the user selected from theme panel.. and include that file.. Right now in the custom post type template... | It is hard to say with 100% certainty but I think the problem is your use of <code> query_posts </code> . Here is what I believe is happening: The Main query runs with the default parameters and loads your page You clobber the main query with <code> query_posts </code> You generate pagination based on the clobbered mai... | Pagination problem in custom post type used as front page | wordpress |
I have implemented Full Calendar via json with my Wordpress custom post types. All is fine except I want to add the taxonomy term of the event / post to the 'className' of the event object but cant seem to get it working, can someone please take a gander at my implementation see where I am going wrong? I cant seem to g... | You are using <code> get_single_term </code> in a way that would require it to return a value... <code> $term = get_single_term($post->ID, 'course_locations'); </code> ... but you have written it in such a way that it <code> echo </code> s a value. You should have... <code> function get_single_term($post_id, $taxono... | Post Terms As Class Name For Full Calendar Events | wordpress |
Here is my loop code for index.php . I do not have an archive or category.php right now. This is very basic. <code> $temp = $wp_query; global $wp_query; $wp_query = new WP_Query(); $wp_query->query('posts_per_page=20'.'&paged='.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); </code> I hav... | You are overwriting the query that loads with the page (which you saved to $temp) - why not just use the one that loads with the page: <code> while(have_posts()) : the_post(); // put the post here endwhile; </code> | Category archive is displaying all posts rather than the specific category | wordpress |
I'm trying to make a little blog network that functions like wordpress.com, where I can create and admin multiple blogs with a single user (or share blogs between users). I've tried to do that by simply following this guide , but when I tried to create a new site, it created another user with it. How can I enable the m... | If you create the new blog using your email address, it will be owned by your user. Because you are acting as the super admin, it assumes you are creating for a new user. Not entirely sure what you mean about my blogs, but if you follow the steps above then the new blog will appear in the drop down admin bar when you a... | Enable "My blogs" in a custom installation | wordpress |
I want to remove all the links from my network login page ("Register","Lost your password" and "Back to site") how can i do that? | I am not sure there is a way to suppress all these links, but you can hide them with CSS: <code> add_action( 'login_head', 'hide_login_nav' ); function hide_login_nav() { ?><style>#nav,#backtoblog{display:none}</style><?php } </code> Result: | Remove Links from Login page | wordpress |
I have been beating my brains on this one for days now and my Google-fu is failing me. I have created a custom meta box with a dropdown menu that lists all of the terms from a custom taxonomy. What I cannot figure out is how to save the selected option from the drop down menu when the post is saved. I'm a bit of a newb... | <code> $myterms = get_terms($taxonomies, $args); </code> returns an array of term objects. Use <code> $term->term_id </code> as <code> option </code> value … <code> "<option value='$term->term_id'>". esc_html( $term_name ) . "</option>" </code> … and store that ID, not the name. Names can change, the ... | Save selected item from dropdown menu in a meta box as a metadata value for a custom post type | wordpress |
The <code> paginate_links </code> Codex function reference has some sample code that's being reposted all over the net. It has a section that uses a variable called <code> $big = 999999999; // need an unlikely integer </code> : <code> echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagen... | Note the <code> get_pagenum_link( $big ) </code> : This will create an URL ( not a link) based on the number provided in the first parameter. That function is used to get the basic pattern for the URL, and the high integer is used here, because: You must provide an integer as argument. The resulting URL is filtered wit... | Why do you need an unlikely integer in paginating? | wordpress |
I'm trying to pull multiple sites posts. For example, I can pull out a single site posts by a category and total posts 10. But I'm trying to pull out both posts from two separate Multisite blogs 1 & 2. But only blog 1 works. Also, I want to pull out another category from blog 1 and blog 2 by another category. How c... | The WordPress function <code> switch_to_blog() </code> expects an integer as an input parameter. You can read more about it in the Codex: http://codex.wordpress.org/Function_Reference/switch_to_blog Please try this kind of structure instead: <code> <?php $original_blog_id = get_current_blog_id(); // get current blog... | Get posts from sites in Multisite? | wordpress |
There is a function called apply_filter where you can use it like this: <code> echo apply_filter('the_content', $my_content); </code> It add formatting tags and clean up the content. Trac or docs I looked in the trac and docs but could not find what functions are used in the apply_filter function. I found wpautop The o... | You can use the global <code> $wp_filter </code> array to check for callbacks on each filter. Here is for example a code snippet that prints out all the callbacks on the <code> the_content </code> filter in the footer part of your theme: <code> add_action('wp_footer',function(){ global $wp_filter; printf('<pre>%s... | What functions are included in apply_filter('the_content') | wordpress |
I have a problem here, I registered a custom post type and I named it 'recipe' then I created a custom taxonomy under the post type, I named it 'recipe category'. Now I want to display the of categories under that custom taxonomy, but unfortunately I have no luck. I tried this code <code> <?php $taxonomy = 'recipeca... | The problem can only be one of the following: Your taxonomy "recipecategory" does not exist. Your taxonomy has no terms. None of your recipecategory terms have any posts. In this case, make the following change: <code> $tax_terms = get_terms($taxonomy, array('hide_empty' => false)); </code> This should work as it wi... | List the categories under custom taxonomy | wordpress |
Ive installed "lightbox plus colorbox" plugin and im trying to call the latest post from the CPT notices. the notices have post expiration so essentially im looking to display the latest alert on the homepage. What ive'e learned from google so far: <code> <?php $hotfoodpresent = get_posts( array('post_type' => 's... | Your code cannot work. At first, your <code> endwhile; </code> and <code> endif </code> statements are inside the string. They will be printed and not executed. The correct formatted code should look like this <code> $hotfoodpresent = get_posts( array('post_type' => 'st_notice', 'posts_per_page' =>-1) ); if ( $ho... | post in a lightbox? | wordpress |
I need to use it as a background image but this is killing me because: <code> show_media_header() </code> would print <code> <a href="#">http://url/of/the/header</a> </code> How can I just retrieve the value? So I can print it just like I need it? | Try this Dynamic Header plugin function: <code> get_media_header_url() </code> instead of this one: <code> show_media_header() </code> It is defined as <code> function get_media_header_url() { global $post; $post_id = $post->ID; //Declare the wpdb var and table name and run the query to see if there is a media objec... | How to get ONLY the URL of the image that show_media_header returns? | wordpress |
Limiting post search to titles only is a breeze, but WooCommerce's post types don't abide by this rule. I have tried modifying the code below to be specific to products but am not having any luck. <code> function search_by_title_only( $search, &$wp_query ) { global $wpdb; if ( empty( $search ) ) return $search; // ... | It turns out the free Relevanssi plugin does this rather well. I was afraid it would only search posts and not custom post types, but it does it all... and rather well! It only requires a simple filter added to your theme's <code> functions.php </code> file to get it to omit the body content: <code> // search titles on... | Search Woocommerce product titles only | wordpress |
Hello Im using a custom filter that hooks to <code> pre_comment_approved </code> to look for bad words in a custom way. Now when the comment gets flagged it returns <code> spam </code> . How could I post back an error to the comments page so the user is aware that his/her email was sent to spam because of the use of a ... | This is how I've handled passing messages back to the user before: within your current function, set a transient with your message: <code> set_transient( 'admin_notice', 'Please put down your weapon. You have 20 seconds to comply.' ); </code> Then add a new hooked function: <code> function admin_notices() { $notice = g... | Returning error upon comment being flagged as spam | wordpress |
I have got a shortcode that displays a custom post type, via a <code> foreach </code> . The shortcode has been used in the standard post type. I have used <code> the_title(); </code> in the shortcode. <code> the_title(); </code> outputs the post_title of the standard post type (which the shortcode is in), rather than <... | You need to add <code> setup_postdata($post); </code> inside your loop: <code> foreach ( $attachments as $post ) { setup_postdata($post); the_title(); the_content(); } </code> | Shortcode is displaying the wrong post_title | wordpress |
I'm trying to make a photo gallery where the individual photos can be shared on Facebook and Twitter, and when you click the link, the photo that was shared will open in a lightbox automatically. Most lightbox plugins provide a deep-linking feature that provides this in the form of a #! after the URL. Unfortunately, bo... | one way you could do this with an internal WordPress rewrite, which would then set a query var you could check when enqueueing your javascript, and pass that data via localize script . so first, rewrite rule to intercept requests to <code> gallery/ </code> with something appended, load the page named <code> gallery </c... | Redirect URL to an existing page with query string or #! added on | wordpress |
Im using a loop to make a slider. My code is <code> <?php query_posts( array( 'post_type' => 'my_gallery', 'author'=>$author->ID ) ); while( have_posts() ) : the_post(); $imagethum = eh_postImage(115, 70); ?> <a data-slide-index="0" href=""><?php echo $imagethum; ?></a> <?php endwhil... | try yo use the build-in loop counter: <code> <a data-slide-index="<?php echo $wp_query->current_post; ?>" href=""><?php echo $imagethum; ?></a> </code> | For Each +1 Wordpress Loop | wordpress |
Does anyone know how to create multiple admin widget pages with calling specific sidebars? In Detail, I have a custom post type called Groups and I am creating new admin pages in the back end. I added a submenu to Groups called Widgets. I created a sidebar for Groups and I want to add this sidebar to the Groups widget ... | Your code deletes keys from widgets. One of those keys is named 'class'. When WordPress looks for the 'class' key it is missing and PHP reports that. I think you want this: <code> $groups_sidebars = array(); foreach ( retrieve_widgets() as $widget ) { if ( array_key_exists( 'groups-sidebar', $widget ) ) $groups_sidebar... | Creating Multiple Admin Widget Page with Calling One Sidebar | wordpress |
Here is my loop <code> <?php if ( have_posts() ) : ?> <?php /* Start the Loop */ ?> <?php $i = 0; while ( have_posts() ) : the_post(); ?> <?php if ($i++ == 0) : ?> <div class="entry-content-main"> <?php get_template_part( 'content', get_post_format() ); ?> </div> <?php else:... | you could rewrite the full code and use the build-in loop counter <code> $wp_query->current_post </code> to fix the css classses and add a class for the first post per row to clear the float to prevent the 'wacky sticking'; example: <code> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_po... | First post full width, rest in two columns | wordpress |
I am writing a set of classes to easily create options pages accessible via submenus of the standard WordPress menus and a way to easily create options for said menus. The way I am wiring it is via a settings class which you pass settings to and I intend to have it work along with a submenu class to create the menu, se... | You have the name parameters set to "$id" which means that they'll be things like "show_header_2" and such. You actually want them to be "second_section[show_header_2]" and similar instead, so that the array of settings is what you get back from the form. | Why is the Settings API is not saving my array of options | wordpress |
This code works well to display child pages of the parent page while viewing both the parent page and child page. It doesn't apply the <code> current_page_item </code> CSS class to the parent while viewing it (and only it, not interested in it being applied while on the children) - any suggestions? <code> <ul class=... | If I understand what you want, it is trickier than it should be to get it working. <code> $ancestors = array(); $ancestors = get_ancestors($post->ID,'page'); $parent = (!empty($ancestors)) ? array_pop($ancestors) : $post->ID; if (!empty($parent)) { $pages = get_pages(array('child_of'=>$parent)); if (!empty($pa... | Add Parent to List of Subpages | wordpress |
I was just adding a custom role by using the add_role() function. Here is the code below: <code> add_role('user', 'User', array('read')); </code> I figured this would give the same level of access as the subscribers role. Technically I want them to be the same but I don't want to use the subscribers as a role for certa... | You have to give the capability a true or false, like this: <code> add_role('user', 'User', array( 'read' => true )); </code> To fix it, first remove the role and than re-add it again. <code> remove_role('user'); add_role('user', 'User', array('read' => true)); </code> http://codex.wordpress.org/Function_Referenc... | Custom Role does not have access to dashboard | wordpress |
I am an admin of a multi-author blog. I am implementing a monitoring system which will require me to downgrade a user from an 'author' (this role allows them to make a custom post) back to the 'reader' role if I think it is a spam account, or if they are breaking website rules. After changing their role using the admin... | You can add actions to the <code> set_user_role </code> hook: <code> add_action( 'set_user_role', 'wpse98904_remove_demoted_user_posts', 10, 2 ); function wpse98904_remove_demoted_user_posts( $demoted_author_id, $role ) { if( 'subscriber' == $role ) { // In here you'd search for all the posts by the user $args = array(... | Downgrade user from role that allows post creation | wordpress |
I'm working on a widget that embeds videos using oEmbed and I'm testing it out using the default providers in WordPress. So far, they are all working fine, except Viddler. The video is displayed, but not with the width and height I specified. To get the oembeds to work properly in the widget, I'm using the wp_oembed_ge... | Yes, seems that viddler changed their oembed endpoint, and the redirection from the old one is stripping the maxwidth. I made a core ticket about the issue: http://core.trac.wordpress.org/ticket/24296 | Viddler oEmbed not working with specified width | wordpress |
I'm using the following widget to retrieve a list of the custom post type jobs : <code> class FeaturedJobsWidget extends WP_Widget { function FeaturedJobsWidget() { $widget_ops = array('classname' => 'FeaturedJobsWidget', 'description' => 'Displays a random post with thumbnail' ); $this->WP_Widget('FeaturedJob... | Use wp_reset_postdata () function after while loop to reset custom wp_query as shown in following code so that it will not break other wordpress loop. <code> <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=jobs&posts_per_page=8'); while ($custom_posts->ha... | Retrieving list of a custom post type in a widget without using WP_Query? | wordpress |
I am trying to <code> WP_Query </code> a custom post type. I would like to display the <code> post_title </code> s in a list. Here is my code, it doesn't seem to work: <code> <?php add_action( 'init', 'custom_faq_type_mp' ); function custom_faq_type_mp() { register_post_type( 'faq_type_mp', array( 'labels' => arr... | Write code for human beings to read it. If you indent your code, add white space and use good variable names it will be more readable to human beings. The human being you are writing for is usually yourself in 4 to 6 months. For example, your first function could look like this: <code> add_action( 'init', 'custom_faq_t... | WP_Query of a custom post type isn't working | wordpress |
I've been trying for quite a few hours to get something to print out in loop: post has 2 categories, one of them is <code> prace </code> (slug) and I need the other one printed. If it isn't too much to ask. Tried just about everything with categories I could but can't get any further due my lack of knowledge of working... | If I understand your requirements correctly: <code> $terms = wp_get_post_terms( $post->ID, 'category' ); echo $terms[1]->name; </code> You can see what other values are returned by <code> var_dump </code> ing <code> $terms </code> . The above assumes that you are using the category taxonomy. | Print out one of 2 post category | wordpress |
Let's say I want to create a custom template for my taxonomy <code> customtax </code> . This is pretty simple, I just create a <code> taxonomy-customtax.php </code> in my theme directory. Now, I'ld like to query a built-in category with one term of my custom taxonomy, like so: <code> www.example.com/?customtax=x&ca... | You can tell WordPress what template file to use with the <code> template_redirect </code> hook. <code> add_action( 'template_redirect', 'wpse98738_taxonomy_redirect' ); function wpse98738_taxonomy_redirect() { if( 'x' == $customtax && 'y' == $category_name ) { include( get_template_directory() . '/taxonomy-cus... | How to define the template priority between built-in categories and custom taxonomies? | wordpress |
I have a custom taxonomy (location) that is being populated automatically by an advanced custom field on user save. The issue is that it saves the term_id in the postmeta meta_value field. When I echo that field in my archive or taxonomy template it obviously shows me the term_id and not the actual term name (ex. I get... | You can use <code> get_term_by </code> to retrieve a term by its ID: <code> $term_id = 123; $term = get_term_by( 'id', $term_id, 'location' ); if( $term ){ echo $term->name; } </code> | How can I get the name of term post meta value which equals term id | wordpress |
I would like to create a modal 'pop-up' window in WooCommerce to appear when the "Add to cart" button has been clicked. This has to occur after the WC actions that actually add the product to the cart but before/instead of any redirects. I have found several likely/possible hooks, actions and filters which may be usefu... | The following works for me for product archive pages (these include both the main shop page as well as archive pages for product categories, for example). It will show the current cart contents in a thickbox. I chose to show this for this example just because that's the data that one gets back through Ajax after clicki... | Lightbox popup on WooCommerce add_to_cart action | wordpress |
I have been developing plugins for WordPress, most plugins I have developed use two or three classes, hence not as huge as Buddypress or WooCommerce. I am planning to develop two open source plugins to deliver some sort of complex system (can't share details at the moment but later during development) where other devel... | The API you offer in a plugin or a theme depends on the logic of that specific code. There is probably no guide that applies to all situations. I am a contributor for multiple plugins with APIs, and what I have learned so far is: Do not offer an API until you really know how people use your code. Release the first two ... | How to create an API for my plugin? | wordpress |
I have created custom Wordpress loop using WP_Query, loop is working fine and I can customize it nicely, however i have a problem using "Blog pages show at most" settings, for example inside my loop if i have added following argument <code> 'post_per_page' =>-1 </code> my loop is showing all posts but now i can't in... | I'm not sure why your blank variable method should work, but it seems dodgy to me. I would explicitly set the posts_per_page to the number defined in settings: <code> 'posts_per_page' => get_option( 'posts_per_page' ) </code> | "Right Way" to make custom Loop respect reading settings inside admin panel? | wordpress |
I want to set up my site so that when I go to any post then it should show full width page. This theme already has a full width page but I wanted it to show in the default width page. How can I accomplish this? My website link is - http://techjagot.com The code in single.php is :- <code> <?php get_header(); ?> &l... | You have to edit your <code> single.php </code> for a full width design in your post view, is the <code> single.php </code> is responsible showing your post details. Suppose, if your <code> single.php </code> looks like this: +---------------------+ | | +--------------+------+ | | | | | | | | | | | | | | | +-----------... | How can I set full width page layout in a default post page? | wordpress |
The first plugin is somehow breaking the second one (the content of the second one doesn't show up at all): plugins/featured-images.php: <code> <?php /* Plugin Name: Featured Jobs Plugin URI: [Enter your website URL] Description: [Enter brief description of plugin] Version: [Enter version number of plugin (probably ... | Your code fails because of a PHP syntax error. Things to note: Your problem is a result of your failure to indent your code correctly, resulting in things being missed. Your editor should be able to reindent code, and it should auto-indent as you type. There are no excuses for this, and it's a 100% avoidable situation ... | Why is my custom widget breaking another one? | wordpress |
I'd like to add something to <code> wp_head() </code> but I'm aiming precise location (like after style.css but before rtl.css and before my other custom script). I'm wondering if it's possible to list everything that is attached to <code> wp_head() </code> in execution/display order anyhow? I know that I can pass prio... | While you can practically control order of hooked things by priority, it's not always the right tool for the job. In case of styles you should be using appropriate <code> wp_enqueue_style() </code> function which allows you to easily set up elaborate dependencies which will be automagically processed by WP to produce d... | wp_head() - list hooked actions with priorities? | wordpress |
I've seen two ways to remove meta boxes: remove_meta_box() and unset(). <code> function TEST_remove_dashboard_widgets(){ remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); } add_action('wp_dashboard_setup', 'bmc_remove_dashboard_widgets'); </code> vs. <code> function TEST_remove_dashboard_widgets() ... | When in doubt use the API. Let’s say the structure of <code> $wp_meta_boxes </code> will change or go away one day. <code> remove_meta_box() </code> will still work, because the API is a contract between core and developers. Unsetting some keys in a global variable might break. <code> unset() </code> is easier to write... | Removing meta boxes: remove-meta_box() or unset()? | wordpress |
I've hit the issue described in '11: "stackexchange-url ("Enable comments for post with comments meta box removed")" and I'd like to ask for your help to adapt the mentioned there code to the current wordpress version. I have a custom post type that must have comments enabled and contributors must not be able to disabl... | Filter the <code> 'comments_open' </code> check. It happens inside of the function with the same name, and that function is called in a theme usually like this: <code> comments_open() and comment_form( array ( 'comment_notes_after' => '' ) ); </code> This is how the filter works: <code> add_filter( 'comments_open', ... | Enable comments for post when comments meta box removed | wordpress |
I am trying to have a section under a single post where it displays completely random posts. I got everything working, but every once in a while one of the random posts that get displayed is the actual post that it is on (the single). Here is my code: <code> <?php $args = array( 'numberposts' => 3, 'orderby' =>... | Check to see if you have a post ID (which you should on a single post page but I am not sure if this is in <code> single.php </code> or some other template like <code> index.php </code> ) and add that to the <code> $args </code> if you do. <code> $args = array( 'numberposts' => 3, 'orderby' => 'rand' ); if (is_si... | Display random posts, but omit the post it is on? | wordpress |
I have an array with the categories and sub-categories I want to import to the "campsite-district-county" taxonomy. My sub-categories are not being inserted with the correct parent. They're being inserted on the root level. After some investigation I come across the information that I needed to clear the taxonomy cache... | You have error in your PHP. This <code> array('parent', $id_parent) </code> will produce numeric array with two values - string <code> parent </code> and value of <code> $id_parent </code> . What you actually need is <code> array( 'parent' => $id_parent ) </code> which will produce correct associative array with one... | Problem importing categories and sub-categories | wordpress |
I have the following: <code> //Jobs register_post_type( 'jobs', array( 'labels' => array( 'name' => __( 'Jobs' ), 'singular_name' => __( 'Job' ) ), 'public' => true, 'show_ui' => true, 'has_archive' => false, 'hierarchical' => true, 'query_var' => true, 'supports' => array( 'title', 'editor',... | If you are wanting to use a specialized archive template for your custom type, you need an additional archive file. This is named in the form of: <code> archive-[custom post type name].php </code> Since your code listing has <code> jobs </code> as the type name, the archive file would be named: <code> archive-jobs.php ... | How to prevent a custom post type from using the archive.php template? | wordpress |
I have three Javascript script that I need to load - <code> imagesLoaded.js </code> <code> lazyload-1.8.4.js </code> and <code> cd.js </code> <code> cd.js </code> contains my functions that use <code> imagesLoaded.js </code> and <code> lazyload-1.8.4.js </code> . Do load them altogether or separately? <code> function a... | I formatted that code as best I could, and once formatted it is obviously very broken. <code> wp_enqueue_script </code> takes 5 parameters. You have 9. And several of the first five are wrong. I expect that you would see errors if you had debugging enabled . You seem to be trying to enqueue all of your scripts in the s... | Load multiple Javascript scripts | wordpress |
If we set wp to break comments into pages after X nr of comments and we have X+1 comments , wp only shows that last comment instead of showing X and move the comment from bottom onto the next page. Any help would be appreciated since it is a big deal for what I am trying to use it. | ok.. so I did it like this. Maybe will help some. Used the code from stackexchange-url ("Last comment page first with full number of comments?") but altered it a bit to fit my needs. So this goes into your template page where you call the comments (or you can wrap it in a function and put it into functions.php) <code> ... | Is it possible to make wp insert last comment onto another page | wordpress |
I built my own contact form (no plugins) and want to have a secure way to get an emailadress from my option page. get_option and other built in WP stuff doesn't work from within my process.php file. I tried to make a query to WP-Database like that: <code> $query = "SELECT * FROM wp_options WHERE option_name = 'nothing_... | Add this at the start of your <code> process.php </code> file to get access to <code> get_option </code> and other wordpress functions: <code> define( 'WP_USE_THEMES', false ); require('wp-blog-header.php'); </code> You might have to change the path to <code> wp-blog-header.php </code> . | Get value from db for custom contact form | wordpress |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.