Tag Info

New answers tagged

0

Well what is part of the blog and what belongs to the rest of the site will probably differ so it is hard to split. E.g. is header and footer the same? Anything else that is shared? Anyway, here are two options: 1.Separate instances If the blog and the rest of the site look totally different you may consider separate WordPress installs or a Multisite ...


0

So this is what I needed: <?php $terms = get_the_terms( $post->ID , 'board' ); foreach ( $terms as $term ) { echo $term->name; } ?>


-1

You have to add jquery.form.min.js it work for me , Hope it works for you.


0

I see three options here, but before I start, just a few notes on your code Do not use $wp_query as your query variable. This is the global query variable used by the main query which also holds the main query object. The way you have used it breaks the main query object and sets your custom query to it. You should avoid this method at all times as many ...


0

Change your query code to this: add_filter( 'post_limits', 'my_post_limits' ); // The Query $wp_query = new WP_Query( $args ); remove_filter( 'post_limits', 'my_post_limits' ); In your theme/functions.php, add this: function my_post_limits( $limit, $query ) { return 'LIMIT 0, 30'; }


11

I don't think there exist one, but you could create your own, wpse_empty_trash, with something like this: /** * Add a custom hook 'wpse_empty_trash' */ add_action( 'load-edit.php', function() { add_action( 'before_delete_post', function ( $post_id ) { if( 'trash' === get_post_status( $post_id ) && filter_input( ...


0

I added the line set_time_limit(600); to my php.ini file in MAMP. In order to do this I had to copy the php.ini file from MAMP/conf/php5.6.3 and paste it in MAMP/bin/php/php5.6.3.


1

The new_to_publish hook has one argument: $post. Use that to get the post id. Here is your editted code: add_action( 'new_to_publish', 'send_notification', 1, 1 ); function send_notification( $post ){ $post_id = $post->ID;; global $wpdb; $sel2 = mysql_query("select * from gcm_users"); while($data1 = ...


0

It looks like you're calling preparePDF( $wp_query ) inside your callback, but $wp_query isn't defined and the global $wp_query shouldn't be accessible there without global $wp_query. Try instead preparePDF( $query ) and use wp_reset_postsdata() to restore the global $post object. Another important thing is that you must run your preparePDF() function ...


0

You can use this function in your child theme functions.php or as a plugin to show 15 posts per page on mobile devices. function custom_posts_per_page($query) { if (wp_is_mobile()) { $query->set('posts_per_page', 15); } //endif } //function //this adds the function above to the 'pre_get_posts' action add_action('pre_get_posts', ...


1

The proper argument to your tax query is terms, not term. You can see this in one of the examples in the Codex: $args = array( 'post_type' => 'post', 'tax_query' => array( array( 'taxonomy' => 'people', 'field' => 'slug', 'terms' => 'bob', ), ), ); $query = new WP_Query( ...


1

There are two possible solutions: CSS edit and File edit. CSS edit(Not the best solution, but works) .post-blocks .block-info span { display: none; } It is not possible for us to write the file edit code since we don't have access to your admin panel. Install WhatTheFile plugin to find out the template that renders the code for the page and edit the ...


1

Ref. https://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column Just use the WP built in action called "manage_posts_custom_column" and in callback check for the correct column and add simple_field value with the function simple_fields_value : add_action( 'manage_posts_custom_column' , 'add_new_column_data_in_posts', 10, ...


1

The function second parameter is the "$post_id". Ref. http://simple-fields.com/documentation/api/getting-values/simple_fields_value/ simple_fields_value("simple_field_slug", $post_id)


0

Google will reveal all, if you know what your looking for. You can get all comment authors by using the get_comments() function. In fact the first example listed there will exactly what you want. <?php $comments = get_comments('post_id=15'); foreach($comments as $comment) : echo($comment->comment_author); endforeach; ?>


0

Thanks for your help but unfortunately for some reason it is listing all the items of my work portfolio theme and not the number I want. The code I provided is for the front page: http://www.cyberjunkiesinteractive.com/


1

If you check the documentation for WP_Query you will notice that post_count, which you are using, returns the number of posts being displayed. That is what you see, but not what you want. found_posts returns the total number of results for the query, which is what you want. $post_count The number of posts being displayed. $found_posts ...


0

This answer is going to integrate the one from jjarolim The correct whole query is SELECT DATE(post_date) AS date, concat(post_title) titles, COUNT(*) AS count FROM wp_posts WHERE post_status = 'publish' AND post_parent = 0 AND post_type = 'post' GROUP BY DATE(post_date) ORDER BY DATE(post_date)


0

please help my answer to format the source, was not possible from mobile. The! The WP API have hooks, like rest_prepare_page to enhance the endpoints. For each post type give it different hooks the follow code example add the tags to post and page and illustrate, how it works. /** * Add properties to posts and pages endpoints. */function ...


0

Yes "posts_per_page" can change the number of posts shown. Where can you add it to your code? You can add this parameter to your $args variable. To add it to your $args variable you can do this: $args = array( 'post_type' => 'portfolio', 'posts_per_page' => 12 ); "12" is the number of posts per page that will be shown. Change this whatever ...


0

Just because I added the question here, I found it ... So ... easy... so irritating... but I hope this answer will help anyone else with this issue quicker! changed 'hierarchical' => true to 'hierarchical' => false for the custom post type!


0

For this to work, you will need to implement some kind of post view system. If you haven't incorporated one yet, have a look at one I have post recently here. You can modify and abuse that code to suite your needs Once that is in place, it is really easy to sort your posts by post views. From your question, it does seem that you are already making use of ...


0

I would suggest you to use WP_Query for this purpose. An example of this query is here in this plugin which fetches only relevant posts instead of using further PHP functions. You can choose a faster way to go on, Alphabetic Pagination Plugin


1

the_content() will output the formatted post to the web browser, if the tag is used in the post it will only display the post up to this point and will out put a "Read More" link. There are some additional flags in the method to control this behaviour. See more here. Alternatively, you may load the output of the content into a variable, if this is what ...


0

You can add the custom post type term to the single.php In your case, create new files single-mathematics.php and single-mechanical.php Copy the single.php code, paste in these files and edit it for full-width/no-sidebar. WordPress will automatically search for these files when the custom post type page is loaded.


0

There are multiple ways to go about this, but one way I would consider if I were you would be to do it like this. On the index.php or whatever page the posts appear on do the following three times each with different categories: $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $arguments = array( 'category_name' => 'category' ...


0

It's because of the extra class row wrapped. After the container class <div class="container"> Remove this code of class row <div class="row"> and also remove the extra closing div if added for it. The sidebar will be positioned to the right side.


2

Whenever you add a new item to WordPress Menu ( Appearance -> Menu ) it creates a new Post of Post Type nav_menu_item and gets assigned a post meta called _menu_item_object_id with the main Post ID. For example, if I create a page called "Home" it gets assigned a Post ID of 2. Now, when I go to Menus and add the page to a menu, WordPress creates a new ...


0

The shortest possible answer would be to correct 'post_author' to 'author', since that is the key WP is looking for. If a key is incorrect or misspelled it will be ignored, as was the case with 'post_author'.


3

You can add to the end of theme's header.php file this: if( is_single() ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); get_template_part( '404' ); exit(); } Note that the get_template_part( '404' ) function needs 404.php file in your theme directory.


2

It's showing you the first 5 posts because that's how many posts are on page 1, and you never told it how many posts per page to load, so it used the default posts per page you set under settings. You'll want to modify the get_posts call to have the posts_per_page parameter. However, I will note the following problems: get_posts doesn't cache the way ...


0

I posted a working solution as of WordPress 4.2 here: Adding Sticky functionality to Custom Post Type Archives Basically, it implies installing a small plugin and add a code snippet.


2

You'll want to use WP_Query, along with the data parameters e.g. years: $years = array( 2015,2014,2013,2012 ); echo '<table>'; foreach ( $years as $year ) { $q = new WP_Query( array( 'year' => $year, 'fields' => 'ids' ) ); echo '<tr><td>'.$year.'</td><td>'. ...


2

the fastest way imho would be to create a custom sql statement: global $wpdb; $rows = $wpdb->query('SELECT DATE(post_date) AS date, COUNT(*) AS count FROM ' . $wpdb->posts . ' GROUP BY DATE(post_date) ORDER BY DATE(post_date)'); foreach ($rows as $row) { echo $row->date . ': ' . $row->count . '<br>'; }


1

I believe you are using wordpress on your website...To add read more text u just need to use the wordpress visual editor. In this the 12 no. button is used to add read more text...Use this to add read more, there may be possibility that while adding code you are making some error..


0

I'm not sure how WP's admin interface handles this (e.g. the scenario I referenced in the question), but I found a way to accomplish this: //Disable KSES kses_remove_filters(); $update_rval = wp_update_post($updates); //Reenable KSES kses_init_filters(); Note that "kses" functions are part of Wordpress' defense against evil code. So, use this ...


1

Once a post is moved to the trash and deleted, it's gone from the database. The only way to recover it is from an earlier database backup. Do you have a backup? Does your webhost have a backup?


0

So digging around a little i couldn't find a solution where the WP_Query wasn't used, so i just stuck with the query method, Using WP_Query this snippet will display the latest post that is published by the user that is logged in. $user_id = get_current_user_id(); $args=array( 'post_type' => 'POSTTYPE', 'post_status' => 'published', ...


0

You can use get_terms. In your case, something like this ought to get you started: $term_list = get_terms( 'taxonomy_name', 'hide_empty=0&orderby=name' ); foreach( $term_list as $term ) { echo "<li>" . $term->name . $term->description . "</li>"; }


2

I don't think you need so many transients set, one for each category. You can only use one, that is enough. Transients are quite expensive to set as it requires additional db queries, so you would want to cut down on the use. As always, I like to keep my templates simple, short and sweet, so I tend to write custom functions to move the bulk of the code ...



Top 50 recent answers are included