Tag Info

New answers tagged

0

I'm afraid this is the problem: Wrong: <?php if ( $depth + 1) { ?> Correct: <?php if ( $depth > 1) { ?> That is what I think...


2

You can do this easy way or hard way. Hard way would be you creating custom functions to remove all menu classes and add FontAwesome icons accordingly. And easy way would be this. Go to Appearance > Menus And add FontAwesome icons in menu items. Like this. Note: You don't need to change page titles on each page. Just menu labels.


-1

Okay, so here is the complete query for displaying popular posts of current week. I am using meta_query to limit query results within current week only. It will get all posts from current week and then sort them by post views count added by custom field wpb_post_views_count that you used in your question. // Current week's popular posts $query_args = ...


0

How accurate does it have to be? You'll need to do some kind of incriment counter, and some kind of cleanup function. To be 100%, you will have to keep 7 data points for each post if you want it to be accurate. Keep an 8th (the computed sum), for efficiency. Then your cleanup function should drop the last data point and recalculate the sum once a day. You ...


2

include the conditional tag is_paged() within your if statement; example: if ( $i == 1 && !is_paged() ) :


0

It's not related to WordPress, but basic PHP understanding. But I'm answering to provide you the hint. You're doing the thing. Just embrace the whole div with the conditional: <?php $image = get_field('headOfDepartment_pic'); ?> <?php if( $image ) : ?> <div> <img src="<?php echo $image['url']; ?>" alt="<?php echo ...


-1

Use filter single_template to change template file and function in_category to check is this post in category. add_filter( 'single_template', 'my_single_template' ); function my_single_template($single_template) { if (in_category(1)) { $file = get_template_directory().'/single-cat-1.php'; if ( file_exists($file) ) { return ...


0

You can use this function to add category specific single template pages on your website. This goes in functions.php You can define as many single templates as you want. function wpse_category_single_template( $single_template ) { global $post; $all_cats = get_the_category(); if ( $all_cats[0]->cat_ID == '1' ) { if ( ...


2

You can use the callback argument for a completely customized rendering of your comment/trackback function wpse168639commentCb( $comment, $args, $depth ) { // do whatever you want in here: // Dump what you got: var_dump( $comment, $args, $depth ); } wp_list_comments( array( # other arguments... 'callback' => 'wpse168639commentCb', ) ...


4

If you're looking to duplicate the shortcode method mentioned in your question, you could do something like this. Either of the following two options can be added to your themes functions.php file. Basic "Box" // Add Box Shortcode function wpse_168480_box_shortcode( $atts , $content = null ) { return '<div class="myBox">'.$content.'</div>'; ...


0

As suggested by @FiazHusyn, I went for the custom taxonomy archive template approach. On top of that I gave the custom taxonomy archive template, it's own custom sidebar template. Here's how to do that: Copy/paste your theme's archive.php and rename the copy to taxonomy-your_taxname.php; Copy/paste your theme's sidebar.php and rename the copy to ...


0

I got my solution. <?php // move pagination links above other end-of-post content additions, like related posts etc. function move_pagination( $content ) { if ( is_single() ) { $pagination = wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', ...


1

Use custom archive template for your custom taxonomy. so if your taxonomy is 'XYZ' , its archive page will be taxonomy-XYZ.php. Now in this custom archive page for your custom taxonomy, you can choose to add /remove sidebar as per your requirement.


0

Depending on your theme, you may look into the template where your comments output reside and include calling pagination before it. For example in TwentyEleven comments output is governed by comments.php


0

Look for a plugin that automatically creates posts from an RSS feed. For instance, the plugin RSS Post Importer, should do what you want. It will allow you to import posts to a specific category, which you can then display on the presentation page.


0

The reason your custom fields are only showing up when there is post content is due to this line: <?php if( get_the_content() ):?><h3> Everything after that line will only appear if get_the_content() returns something truthy. The reason being that you're using a shorthand if statement and not closing to before the custom field logic Try this: ...


1

Probably you can achieve this easily with the plugin you mentioned, Advanced Custom Fields. But if you can code a bit, there is a way to easily implement this with no plugin. You can create a metabox with custom fields and attach it to the homepage custom post type, if that's how you have it set up, or to the page that's assigned as the front page for your ...


0

Again, I'm not familiar with Advanced Custom Fields but you may be able to store the returned value into a variable then test if that variable is empty, like so: <?php $pista1a = types_render_field("pista-1a", array("argument1"=>"value1","argument2"=>"value2","argument2"=>"value2")); ?> <ul> <?php if( ! empty( $pista1a ) ) : ...


1

Very old, but this still come up when searching, so I will add that my article WooCommerce Customize Checkout Fields here is a sample of adding a new checkout field: // Add a new checkout field function kia_filter_checkout_fields($fields){ $fields['extra_fields'] = array( 'some_field' => array( 'type' => 'text', ...


0

Okay so i did manage to add some custom css selectively on pages that load the medialement player by adding this to my functions.php file: function custom_player() { wp_enqueue_style( 'custom-player', get_stylesheet_directory_uri() . '/wp-mediaelement.css' ); $custom_css = " /*here goes the css*/ ...


-3

Have you tried utilising "Panels" and then "Sections"? $wp_customize->add_panel..........


1

If you put the code below on your functions you should be able to filter the global $title easily on the admin_head action. <?php add_action( 'admin_head', 'q167372_dash_name' ); function q167372_dash_name( ){ if ( $GLOBALS['pagenow'] != 'index.php' ){ return; } $GLOBALS['title'] = __( 'Your new Title' ); }


2

Thanks guys, I found a solution: It's as easy as adding the post_type_category element to the arguments object within register_post_type(): $args = array( 'label' => 'sausages', 'description' => 'Sausages', 'labels' => $labels, 'post_type_category' => 'food', 'supports' => ...


1

I am make some assumptions here on where you are needing this but you could use is_post_type_archive() to check for archive pages and is_singular() for individual single posts both take either an string or array of post types. $post_types_group_one = array('movies', 'apples', 'sausages' ); $post_types_group_two = array('movies', 'apples', 'sausages', ...


1

I'm assuming you're not using a plugin to register your post types and doing them yourself. WordPress doesn't have an easy way to group or categorize post types together like what you're asking for. What I would suggest is to use built in attributes in a custom way. For example, when registering your post type there is a field called description. I don't see ...


0

Look at the filter for rewrite_rules_array and add a re-write rule to re-write /products/category-name/sub-category-name/product-name to index.php?pagename=product-name. You might need to grab the category-name and sub-category-name too if your product-names are not unique. Then add a query var for product-name using the query_vars filter. Once you've ...


0

It looks like you have all the pieces you need to make this work - you just need to connect them. Try the snippet below /** * get_post_meta returns either the value of the custom field or false * so we need to be sure we have the string before trying to output the shortcode */ $meta = get_post_meta($post->ID, 'intSlider', true); ?> <div ...


0

EDIT (Please see the original answer for full explanation of the code) The code in my original answer works as expected, but triggers a known bug with usort (Check the bug report here #50688) WARNING Error: [2] usort(): Array was modified by the user comparison function This bug is triggered only when the fields parameter is set in the arguments in ...


0

Apparently you can with the Genesis Framework by setting the width #wrap {width:960px;} and remove all viewport css. Note: Do this on child theme. I read this on a developer's forum.


0

If you want to use one file as a "taxonomy" template, but want to style posts differently by post type, I'd advise using an if statement. I'm not sure how far you're going, but if you're just changing the loop for example, it would look something like this: Using this question as reference. <?php while ( have_posts() ) : the_post(); if( ...


0

Try something like this from another post: query_posts( array( 'post_type' => 'custompost', 'posts_per_page' => 4, 'meta_key' => 'mydate', 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_query' => array( array( 'key' ...


0

Working code: $display_count = 2; global $wp_query, $paged; $pages = $wp_query->max_num_pages; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $offset = $page - 1; $showposts = 10; $args = array( 'showposts' => 20, 'post_type' => 'any', 'post__in' => $WPIDs, 'orderby' => 'meta_value', ...



Top 50 recent answers are included