New answers tagged

0

Try this code <div class="container"> <!-- Example row of columns --> <div class="row front-posts"> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <div class="line2"></div> <?php endwhile; ?> <?php endif; ?> <?php wp_reset_query(); ?> <!-- Start ...


1

There is no Page attributes because it's not a page and by default WordPress doesn't have an attribute to select template for post. The page templates are coded in the theme that you are using.It seems that the theme has a template called Full Width defined as page template so you are able to select it for pages. To not display the sidebar in the single ...


0

We can use simply https://wordpress.org/plugins/find-posts-using-attachment/ I hope it is the best way!


1

This is a partial answer, because as I mentioned in my comment I'm not sure why your code is requiring two 'really bad words' at the moment. It's also an untested attempt. I'll deal with your first question: how to send a user back to the posts page and display a suitable error message, rather than an error about editing posts in the trash. A way to do ...


-1

Use this code: $args = array( 'post_type' => 'food', 'orderby' => 'meta_value_num', 'meta_key' => 'listing_price', 'order' => 'DESC', 'posts_per_page' => $count, 'paged' => $paged, ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ): while ( $loop->have_posts() ...


1

I did this for a client and it looked like this: The PHP code: <dl class="tree-accordion"> <?php $currentyear = date("Y"); $years = range($currentyear, 1950); foreach($years as $year) { ?> <dt><a href=""><i class="fa fa-fw fa-plus-square-o" aria-hidden="true"></i> <?php echo $year; ?></a&...


0

Putting aside the objections to order by taxonomy, eloquently given by @Otto in http://wordpress.stackexchange.com/a/14309/25886, I suppose his answer has merit. His reference to http://scribu.net/wordpress/sortable-taxonomy-columns.html in particular, with a post on sortable taxonomy columns. The folllowing code is by @mikeschinkel: function ...


0

You can indeed add a filter to get_next_posts_link, but it has a different name, namely next_posts_link_attributes Complete code would look like this: add_filter('next_posts_link_attributes', 'wpse_230552'); function wpse_230552() { return 'class="iamclass"'; }


0

It looks like the filter's name is next_posts_link_attributes but not get_next_posts_link as that the name of the function. So try instead: add_filter( 'next_posts_link_attributes', 'wpse_next_posts_link_attributes' ); where wpse_next_posts_link_attributes() is your filter callback. Example (untested): function wpse_next_posts_link_attributes( $...


0

You have to edit your post template and add external url. try replacing the_permalink() by your url. <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > <?php if ( has_post_thumbnail($post->ID) ) { the_post_thumbnail('thumbnail'); echo get_post($post->...


0

Alright so this isn't too difficult, first we will just check if the menu item is a taxonomy then get the count and display it! function ggstyle_menu_item_count( $output, $item, $depth, $args ) { // Check if the item is a Category or Custom Taxonomy if( $item->type == 'taxonomy' ) { $object = get_term($item->object_id, $item->object)...


0

You don't need php at all to achieve what you are after. This can be done with just css. This shows the title and excerpt by default. .wrap .wp-tiles-byline-fade-in .wp-tiles-tile-with-image .wp-tiles-byline { opacity: 1; } This hides the excerpt again now that we have revealed it. .wrap .wp-tiles-byline-fade-in .wp-tiles-tile-with-image .wp-tiles-...


-1

I found out what was causing this problem. I had a plugin installed called Simple Posts Generator which I used to generate 10 sample posts for testing purposes. Since I generated the articles all at the same time, the post_date value in the database was the same for each post, which confused Wordpress as to what post should come first. I fixed it by going ...


1

nopaging=true override posts_per_page and sets it to -1 which will return all posts. Remove that and you should be fine


-1

You can always add to the address : /edit.php?post_type=properties&orderby=date&order=desc


0

Another option would be to use the_content filter along with some sort of parser, such as PHPDOMDocument, to remove the unneccessary tags. Pseudocode: function parse_my_content($html) { $phpdom = new \DOMDocument; $phpdom->loadHTML($html); // do some parser magic .... $result = $phpdom->saveHTML(); return $result; } add_filter('...


1

Even though the recommendations have been updated to: To run WordPress we recommend your host supports: PHP version 5.6 or greater MySQL version 5.6 or greater OR MariaDB version 10.0 or greater the minimum requirements are not there yet: WordPress server requirements for Version 3.2+: PHP version 5.2.4 or greater MySQL ...


2

You can do something like this : // remove the script from the queue if were are on the post ID 11 add_action('wp_enqueue_scripts', 'remove_script_specific_post'); function remove_script_specific_post(){ if( 11==get_the_ID() ){ wp_dequeue_script('my_script_handle'); } } Provided that the script has been added with wp_enqueue_script


1

This has to work, Im using it in several projects: add_filter( 'excerpt_more', 'my_excerpt_more' ); function my_excerpt_more( $more ) { return ''; } Just copy-paste it to your functions.php. Little bonus snippet that you might need: add_filter( 'excerpt_length', 'my_excerpt_length' ); function my_excerpt_length( $length ) { return 50; } ...


0

There is date_query which can handle this and an SQL query is not a good practice when you can take advantage of WordPress Query API: $pid = 1; // post ID here $args = array( 'posts_per_page' => -1, 'post_type' => 'post', 'date_query' => array( array( 'year' => get_the_date('Y', $pid), 'month' => ...


0

From my point of view you are trying to make a pagination on a page, which can also mean wordpress is trashing your page/paged var, this can be easily solved by adding a filter adding a custom vars page/paged add_filter('query_vars', function( $vars ){ //!!SUPER IMPORTANT!! - always *APPEND* $vars array (NOT re-assign) $vars[] = 'page'; $vars[] ...


0

Well, comments ( if i remember correct and nothing has changed from v4 ) are custom post types, so u can add post_meta to it, like response => true ( positive ) or false ( negative ). Then u could make custom query ( WP_Comment_Query ) to get comments for certain post with meta parametrs ( ak. Custom Field Parameters ) You would need 2 queries, 1 returning ...


3

We can use the content_paginationcodex filter to modify the paginated content without modifying the globals directly: add_filter( 'content_pagination', function( $pages ) { // Target only the correct utm_campaign GET parameter if( 'nonextpagecampaign' !== filter_input( INPUT_GET, 'utm_campaign', FILTER_SANITIZE_STRING ) ) return $pages; ...


4

You can use the_post hook to remove <!--nextpage-->. In this case: add_action( 'the_post', 'campaign_remove_nextpage', 99); function campaign_remove_nextpage ( $post ) { if ( ($_GET['utm_campaign']== 'nonextpagecampaign') && (false !== strpos( $post->post_content, '<!--nextpage-->' )) ) { // Reset the global $pages: ...


1

If $size is already an array in your original code as it looks to be, then the argument passed will become array(array(150,150)) instead of just array(150,150) and fail, so you can just do: <?php $title=get_the_title(); the_post_thumbnail( $size, array( 'alt' =>$title) ); ?>


4

Since you are already getting the ID of the newly created post ($post_id), you just need to get the URL and redirect after the submission. Using get_permalink( $post_id ) you can get post's URL. Also, you can get rid of the header() function to send a new HTTP header, and use WordPress' own function for redirect - wp_redirect(). wp_redirect( ...


0

The WordPress admin area uses capabilities to determine which user role can see what pages etc. You can use custom written code or several plugins to control to capabilities by each user. I'd suggest using the Members plugin for some easy control.


0

Assuming that you are talking about a custom post type the answer is right in the codex. Generate a template called single-{post-type}.php and WP takes care of the rest.


1

If you want to change the single page page-{page-slug} is a good choice if you want the page template for specific page only and not multiple pages. Check out his custom page template for specific page If you are talking about custom post type We can use single-$posttype.php , here $posttype is your custom post type slug. WordPress template Hierarchy ...


0

Pagination is result of combining two factors: page size and offset. In common case page size is constant and offset is page size times current page. Is it possible to build highly elaborate pagination you describe? Technically yes. That would be matter to adjusting page size and offset in a more elaborate fashion. However specific of such implementation ...


0

I Believe this are the Custom Post type of wordpress. Custom post type will work in same way as the post is working, you can make different category for each post type and also will able to create different archive and single page. I am posting a sample post type code if you want to experiment more on this. This code you simply copy and past into function....


0

WordPress Core post types are post and page that are visible in the admin menu. Other than these can be either a registered custom post type or a menu page. A menu page can be added with the add_menu_page() function, and a similar thing can be done using register_post_type(), where a registered post type gets its own menu item where the following arguments ...


0

This is a little two-liner I use a lot utilizing wp_trim_words. I constantly finding myself needing the abbreviation and read more functionalities outside of the loop. Some one else may find this useful. So this is what I use to: Get the Excerpt by POST ID Get Post Content If no Excerpt has been set, Set the Word length of the Excerpt Choose the Content ...


3

Why to edit the whole form ? Filters are good because they gives you the current output and you just need to add your string to it then return it back to WordPress. In above example you are not using it so let use it. Example:- add_filter('the_password_form', function( $form ){ $my_html = '<h2><br>Password Protected Area</h2>'; ...


2

First check your template or source code to find the classes added to the article as a whole (or any html element that wraps around the whole post. It probably looks a bit like this: <article class="my-article"> <title class="my-title">TITLE</title> <img src="..." class="my-featured-image"/> <div class="my-content"> POST TEXT &...


0

Ok so I finally managed to get it working, my map now displays, thanks to you people. What I did is : I changed the path to the absolute path of the scripts. Indeed, using a relative URL was a bad idea. I have changed my script, which now looks like that : document.addEventListener("DOMContentLoaded", function() { map_init(); }, false); var map; ...


3

The correct method of doing this since Wordpress 4.4 is simply the following: add_filter( "get_next_post_where", function($where, $in_same_term, $excluded_terms, $taxonomy, $post){ $where .= " AND p.post_author='".$post->post_author."'"; return $where; }, 10, 5); add_filter( "get_previous_post_where", function($where, $in_same_term, $excluded_terms, ...


2

Newlines are not valid inside json strings. However you are outputting this code or otherwise checking it for sanity is somehow adding newlines into your long strings here. Check that your strings really are all one line and not broken up into multiple lines.


-1

If what you want is is a full page refresh then you don't need ajax at all and inserting the htt-equip html meta will do the trick <meta http-equiv="refresh" content="5" > (content is time in seconds IIRC) You just hook on wp_head and insert it. function wpse_228671_wp_head() { echo '<meta http-equiv="refresh" content="5" >'; } add_action('...


0

$categories = get_categories( array( 'child_of' => 10 ); foreach ( $categories as $category ) { $args = array( 'posts_per_page' => 5, 'offset' => 0, 'category' => category , 'category_name' => '', 'orderby' => 'date', 'order' => 'DESC', ...


0

as long as the slugs from your articles taxonomy map exactly to the slugs in your default category you should be able to do something like this for each article: $article_cats = wp_get_object_terms( $article_id, 'article-category' ); $new_cats = array(); foreach( $article_cats AS $t ) { $new_cats[] = $t->slug; }...


0

yess SOLVED i modified add_filter( 'posts_where', 'find_by_title_filter', 10, 2 ); function find_by_title_filter( $where, &$wp_query ) { global $wpdb; if ( $find_title_arg = $wp_query->get( 'find_title' ) ) { $where .= " AND SUBSTR(" . $wpdb->posts . ".post_title,1,1) LIKE '%$find_title_arg%' "; } return $where; }


0

You can use custom filters in $args (not tested) add_filter( 'posts_where', 'find_by_title_filter', 10, 2 ); function find_by_title_filter( $where, &$wp_query ) { global $wpdb; if ( $find_title_arg = $wp_query->get( 'find_title' ) ) { $where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'%' . esc_sql( $wpdb->esc_like( $...


0

this one works for me, including the scripts on a customsubmenu page anyway: add_action('admin_menu', 'register_my_custom_submenu_pages'); function register_my_custom_submenu_pages() { $email_menu = add_submenu_page( 'edit.php?post_type=events', 'Email Users', 'Email Users', 'edit_others_posts', 'email', 'email_callback' ); add_action( '...


2

the_permalink(), the_title() by default echo their value. As you want to store that value in a variable you will need to return the values instead. get_the_permalink(), get_the_title() are two similar functions that return the value instead of echo. So you new code may look something like this: $list = '<li class="ubermenu-submenu ubermenu-submenu-id-...


1

You need a custom query for that. Basically, just a query that pulls 1 result from the posts table where the post type is your custom post type: global $wpdb; // the name you gave to your custom post type $post_type = 'my_custom_post_type'; // this is the query string that we'll use with the $wpdb class // selecting from the posts table where the ...


3

Based on what you're asking and what I am understanding there is the_modified_date() or if you just want the value get_the_modified_date(). If you ever want the creation date you could use post_date and post_date_gmt. Several questions on this: How to get post creation date? What is considered the post's creation date for wp_insert_post? If you are ...


0

The issue with your desired structure (and that categories without base are common request but commonly unreliable) is ambiguity. Each rewrite rule is like a tiny program, explaining WP how to turn URL into query variables. It is very important that WP can reliably distinguish which of the rules should handle particular URL. In plain words the usual case ...



Top 50 recent answers are included