logo
down
shadow

Display post as featured if taxanomy matches current category


Display post as featured if taxanomy matches current category

By : user2948155
Date : November 14 2020, 04:48 PM
help you fix your problem I'm not very familiar with ACF and haven't yet used it. I had a look at some documentation etc, and this is what I've found:
ACF TAXONOMY FIELD
code :
$field = get_field($field_name, $post_id, $format_value); 
$cat_id = get_queried_object_id(); // Assumption that category ID is saved by ACF

$args = [
    'posts_per_page' => 1,
    'orderby'        => 'modified',
    'meta_key'       => 'feature_in_category',
    'meta_value_num' => $cat_id, // Assumption that category ID is saved by ACF
];
$q = new WP_Query( $args );

if( $q->have_posts() ) {
    while( $q->have_posts() ) {
        $q->the_post();

        // YOUR TEMPLATE TAGS AND MARKUP

    }
    wp_reset_postdata();
}
$category = get_queried_object()->name; // For category name
$category = get_queried_object()->slug; // For category slug
'meta_value_num' => $cat_id, // Assumption that category ID is saved by ACF
'meta_value' => $category, 
$cat_id = get_queried_object_id();
$args = [
        'posts_per_page' => 1,
        'orderby'        => 'modified',
        'meta_query' => [
                [                        
                        'key' => 'feature_in_category',
                        'value' => $cat_id,
                        'compare' => 'IN'
                ]
        ]
];


Share : facebook icon twitter icon
Magento Featured Item Based on Current Category

Magento Featured Item Based on Current Category


By : Dimitris Karteris
Date : March 29 2020, 07:55 AM
How to display popular post by view in current category?

How to display popular post by view in current category?


By : Ajay Singh Rajpoot
Date : March 29 2020, 07:55 AM
like below fixes the issue The question title is a bit confusing. there is a way of getting the "popular" posts by comment count but that "by view" in the title of your question suggest you are looking for a different way to go about it?
.
code :
<?php
    $category = get_category( get_query_var( 'cat' ) );
    $curCatId = $category->cat_ID;

    $args = array(
        'numberposts'   => 10,
        'cat'           => $curCatId,
        'meta_key'      => 'views',
        'orderby'       => 'meta_value_num',
        'order'         => 'DESC'
    );
    $popPosts = get_posts( $args );


    echo '<ul>';
    foreach ( $popPosts as $popPost ) {
        setup_postdata( $popPost );

        echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';

    }
    echo '</ul>';   

wp_reset_postdata();
?>
<?php
    $category = get_category( get_query_var( 'cat' ) );
    $curCatId = $category->cat_ID;

    $args = array(
        'numberposts'   => 10,
        'cat'           => $curCatId,
        'orderby'       => 'comment_count'
    );
    $popPosts = get_posts( $args );

    echo '<ul>';
    foreach ( $popPosts as $popPost ) {
        setup_postdata( $popPost );

        echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';

    }
    echo '</ul>';   

wp_reset_postdata();
?>
How to display post featured images on category page?

How to display post featured images on category page?


By : Supercedes
Date : March 29 2020, 07:55 AM
it helps some times Hi this is my query for display post details on category page. i displayed post tile & post content. i don't know how to display post image.. any one can help? , You can do somting like this:
code :
<?php if(isset($_REQUEST['datepost']))
 {
 $date = $_POST['date'];

 $res=mysql_query("SELECT * FROM  `wp_posts` WHERE DATE_FORMAT(post_date,  '%m/%d/%Y' ) =  '".$date."' AND post_type = 'post' AND post_status='publish'  ORDER BY post_date DESC");


 while($pageposts=mysql_fetch_array($res))
 {
 echo $pageposts['post_title'];
 echo "\n<br />";
 echo $pageposts['post_content'];
 echo "\n<br />";
 echo get_the_post_thumbnail($pageposts['ID'], 'thumbnail' ); 
 }

 exit();
 }
 ?>
wp_get_attachment_image_src( get_post_thumbnail_id( $pageposts['ID'] ), 'thumbnail' );
<?php 
if ( have_posts() ) {
    while ( have_posts() ) {
        $post=the_post(); 
        the_title(); 
        echo "\n<br />";
        the_content();
        get_the_post_thumbnail();

    } 
}
?>
How to display post featured image under category tab in WordPress

How to display post featured image under category tab in WordPress


By : Edward Moss
Date : March 29 2020, 07:55 AM
it should still fix some issue Assuming you have theme support for post thumbnails and within the loop:
code :
 echo get_the_post_thumbnail( 'thumbnail' );
Display all category names for current post in wordpress

Display all category names for current post in wordpress


By : Pavel RND
Date : March 29 2020, 07:55 AM
Does that help You didn't define count and separator variable it seems, try like this, change separator variable as per your need.
code :
$categories = get_the_category( get_the_ID() ) // if you are using custom taxonomy replace with get_the_terms( get_the_ID(), 'your-taxonomy'); 
$separator = '|'; // define separator variable 
$count = count($categories); // define count
if ( ! empty( $categories ) ) { // check if not empty
    foreach ( $categories as $i=>$category ) {
      echo esc_html( $category->name );
      if ( $i < $count - 1 )
      echo $separator;
   }
}
Related Posts Related Posts :
  • How to add Smarty templating engine to CodeIgniters 3 framework?
  • Am I maxing out possible data insert
  • Redirect to homepage without changing address bar URL
  • What is the best user-Id Value for a MySql "users" table
  • PHP $_COOKIE is only available in one directory
  • php regular expressions documantation
  • cannot import too large sql file to mysql
  • not getting appilcation/json in content-type in header
  • Only the first data display from my database but other shows but not on a table
  • Is it possible to have a print button link as the content of the mail
  • how to extract full mail address in imap php
  • Alternative to output buffering to put eval'd code into a variable
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org