Support » Installing WordPress » Need Help with JNews Theme WordPress

  • lifefoodandtravel

    (@lifefoodandtravel)


    Hi All,

    I’m using JNews WordPress theme and I would like to customize the Category pages to display Sub-Categories rather than posts, after doing a lot of research, I don’t think that functionality is part of the theme. I did come across the following information in the posted image but I am not sure how to go about implementing this. I’m very new to WordPress and development. Any help would be much appreciated!

    I’m looking to build sections in the Categories and Sub-category pages.

    1. In Category pages: Create sections for each Sub-category
    2. In Sub-cat pages: Created section for relevant tags/posts

    /***Info Provided by JNews Team**
    ************************************/

    add_filter(‘the_category’,’check_category’,99);

    function check_category($content){

    $pattern=’/\/category\//’;

    $replacement=’category-‘;

    preg_replace ( $pattern , $replacement , $content);

    return $content;

    }

Viewing 7 replies - 1 through 7 (of 7 total)
  • If you’re using the JNews WordPress theme and want to customize Category pages to display Sub-Categories instead of posts, the code snippet you provided seems to be a step in the right direction. It appears to be a filter that modifies the category links. However, there’s a slight issue with the code. It seems like there’s a missing space in the function name. Here’s the corrected version:

    add_filter(‘the_category’, ‘check_category’, 99);

    function check_category($content){
        $pattern = ‘/\/category\//’;
        $replacement = ‘category-‘;
        
        preg_replace($pattern, $replacement, $content);
        
        return $content;
    }

    This code aims to modify the category links by replacing “/category/” with “category-“. However, this alone won’t achieve the complete customization you’re looking for. It’s a good starting point, but you might need additional code to achieve the desired layout for Category and Sub-category pages.

    If you have any questions or need further clarification, feel free to ask.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Support of all commercial themes and plugins is out of scope for these forums. While we will not close your post, we also cannot guarantee any support at all, be that by volunteers or the developers. We recommend you instead use the developer’s official contact for their premium offerings, as that is the most direct line..

    https://themeforest.net/item/jnews-one-stop-solution-for-web-publishing/20566392/support

    Thread Starter lifefoodandtravel

    (@lifefoodandtravel)

    Thanks so much @humajackson! I am very new to WordPress, I was able to set up the site but this category part is still very confusing to me.

    I am not sure where exactly do I need to insert the code and how to go about creating the “customized page template” for each category per the attached image.

    iamrizwankhan

    (@iamrizwankhan)

    To customize your JNews WordPress theme to display sub-categories instead of posts on category pages. The provided code attempts to achieve this by creating sections for each sub-category on category pages and sections for relevant tags/posts on sub-category pages.

    To implement this solution:

    1. Open your theme’s functions.php file (consider using a child theme if applicable).
    2. Paste the provided code at the end of the file.
    3. Save the changes.

    It might need further customization based on your specific needs. Test it in a safe environment, and if you encounter issues or need additional assistance, feel free to seek help from the JNews community or support channels.

    Thread Starter lifefoodandtravel

    (@lifefoodandtravel)

    Thanks @iamrizwankhan, I did add the code to the functions.php but I am not sure about creating custom page templates for each category, that’s the part I am stuck at. Would you be able to help me with that?

    Identify Categories: Firstly, identify the categories for which you want custom templates.
    Create Template Files: In your theme folder, duplicate the page.php file and rename it with the format category-{slug}.php (replace {slug} with the category slug).
    Edit Template Files: Open each newly created file and customize them according to your needs. You can modify the loop or add specific content as required.
    Assign Templates: In the WordPress admin panel, go to the ‘Edit Category’ page for each category. On the right side, you’ll find a ‘Template’ dropdown. Select the corresponding template you’ve created.
    Save Changes: Don’t forget to save your changes. Test: Visit category pages on your site and check if the custom templates are applied.

    Thread Starter lifefoodandtravel

    (@lifefoodandtravel)

    Thanks again @iamrizwankhan, I did setup everything, the only thing is left to figure out is how I can make the following code work: I did add the code to the functions.php file but what else do I need to do? Tt doesn’t seem to work. Sorry, I’m not great with coding but really good with HTML and CSS. and responsive design. WordPress is very new to me. However, I am learning and trying to figure things out on my own too.

    add_filter(‘the_category’,’check_category’,99);

    function check_category($content){

    $pattern=’/\/category\//’;

    $replacement=’category-‘;

    preg_replace ( $pattern , $replacement , $content);

    return $content;

    }

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.